diff options
author | Ben Murdoch <benm@google.com> | 2010-06-15 19:36:43 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-06-16 14:52:28 +0100 |
commit | 545e470e52f0ac6a3a072bf559c796b42c6066b6 (patch) | |
tree | c0c14763654d84d37577dde512c3d3b4699a9e86 /WebCore/platform/graphics/cg | |
parent | 719298a66237d38ea5c05f1547123ad8aacbc237 (diff) | |
download | external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.zip external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.gz external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.bz2 |
Merge webkit.org at r61121: Initial merge by git.
Change-Id: Icd6db395c62285be384d137164d95d7466c98760
Diffstat (limited to 'WebCore/platform/graphics/cg')
-rw-r--r-- | WebCore/platform/graphics/cg/GraphicsContextCG.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/ImageBufferCG.cpp | 29 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/ImageSourceCG.cpp | 23 |
3 files changed, 48 insertions, 6 deletions
diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index 2e3f829..c69f222 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -764,7 +764,7 @@ void GraphicsContext::endTransparencyLayer() m_data->m_userToDeviceTransformKnownToBeIdentity = false; } -void GraphicsContext::setPlatformShadow(const IntSize& offset, int blur, const Color& color, ColorSpace colorSpace) +void GraphicsContext::setPlatformShadow(const IntSize& offset, float blur, const Color& color, ColorSpace colorSpace) { if (paintingDisabled()) return; diff --git a/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/WebCore/platform/graphics/cg/ImageBufferCG.cpp index ce11499..fe7f83a 100644 --- a/WebCore/platform/graphics/cg/ImageBufferCG.cpp +++ b/WebCore/platform/graphics/cg/ImageBufferCG.cpp @@ -250,6 +250,14 @@ void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& so putImageData<Premultiplied>(source, sourceRect, destPoint, m_data, m_size); } +static inline CFStringRef jpegUTI() +{ +#if PLATFORM(WIN) + static const CFStringRef kUTTypeJPEG = CFSTR("public.jpeg"); +#endif + return kUTTypeJPEG; +} + static RetainPtr<CFStringRef> utiFromMIMEType(const String& mimeType) { #if PLATFORM(MAC) @@ -261,13 +269,12 @@ static RetainPtr<CFStringRef> utiFromMIMEType(const String& mimeType) // FIXME: Add Windows support for all the supported UTIs when a way to convert from MIMEType to UTI reliably is found. // For now, only support PNG, JPEG, and GIF. See <rdar://problem/6095286>. static const CFStringRef kUTTypePNG = CFSTR("public.png"); - static const CFStringRef kUTTypeJPEG = CFSTR("public.jpeg"); static const CFStringRef kUTTypeGIF = CFSTR("com.compuserve.gif"); if (equalIgnoringCase(mimeType, "image/png")) return kUTTypePNG; if (equalIgnoringCase(mimeType, "image/jpeg")) - return kUTTypeJPEG; + return jpegUTI(); if (equalIgnoringCase(mimeType, "image/gif")) return kUTTypeGIF; @@ -276,7 +283,7 @@ static RetainPtr<CFStringRef> utiFromMIMEType(const String& mimeType) #endif } -String ImageBuffer::toDataURL(const String& mimeType, double) const +String ImageBuffer::toDataURL(const String& mimeType, const double* quality) const { ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); @@ -288,11 +295,23 @@ String ImageBuffer::toDataURL(const String& mimeType, double) const if (!data) return "data:,"; - RetainPtr<CGImageDestinationRef> destination(AdoptCF, CGImageDestinationCreateWithData(data.get(), utiFromMIMEType(mimeType).get(), 1, 0)); + RetainPtr<CFStringRef> uti = utiFromMIMEType(mimeType); + ASSERT(uti); + + RetainPtr<CGImageDestinationRef> destination(AdoptCF, CGImageDestinationCreateWithData(data.get(), uti.get(), 1, 0)); if (!destination) return "data:,"; - CGImageDestinationAddImage(destination.get(), image.get(), 0); + RetainPtr<CFDictionaryRef> imageProperties = 0; + if (CFEqual(uti.get(), jpegUTI()) && quality && *quality >= 0.0 && *quality <= 1.0) { + // Apply the compression quality to the image destination. + RetainPtr<CFNumberRef> compressionQuality(AdoptCF, CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, quality)); + const void* key = kCGImageDestinationLossyCompressionQuality; + const void* value = compressionQuality.get(); + imageProperties.adoptCF(CFDictionaryCreate(0, &key, &value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + } + + CGImageDestinationAddImage(destination.get(), image.get(), imageProperties.get()); CGImageDestinationFinalize(destination.get()); Vector<char> out; diff --git a/WebCore/platform/graphics/cg/ImageSourceCG.cpp b/WebCore/platform/graphics/cg/ImageSourceCG.cpp index 9ad3166..4a7aecc 100644 --- a/WebCore/platform/graphics/cg/ImageSourceCG.cpp +++ b/WebCore/platform/graphics/cg/ImageSourceCG.cpp @@ -29,6 +29,7 @@ #if PLATFORM(CG) #include "ImageSourceCG.h" +#include "IntPoint.h" #include "IntSize.h" #include "MIMETypeRegistry.h" #include "SharedBuffer.h" @@ -196,6 +197,28 @@ IntSize ImageSource::size() const return frameSizeAtIndex(0); } +bool ImageSource::getHotSpot(IntPoint& hotSpot) const +{ + RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions())); + if (!properties) + return false; + + int x = -1, y = -1; + CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(properties.get(), CFSTR("hotspotX")); + if (!num || !CFNumberGetValue(num, kCFNumberIntType, &x)) + return false; + + num = (CFNumberRef)CFDictionaryGetValue(properties.get(), CFSTR("hotspotY")); + if (!num || !CFNumberGetValue(num, kCFNumberIntType, &y)) + return false; + + if (x < 0 || y < 0) + return false; + + hotSpot = IntPoint(x, y); + return true; +} + int ImageSource::repetitionCount() { int result = cAnimationLoopOnce; // No property means loop once. |