diff options
author | Feng Qian <fqian@google.com> | 2009-06-17 12:12:20 -0700 |
---|---|---|
committer | Feng Qian <fqian@google.com> | 2009-06-17 12:12:20 -0700 |
commit | 5f1ab04193ad0130ca8204aadaceae083aca9881 (patch) | |
tree | 5a92cd389e2cfe7fb67197ce14b38469462379f8 /WebCore/platform/graphics/cg | |
parent | 194315e5a908cc8ed67d597010544803eef1ac59 (diff) | |
download | external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.zip external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.gz external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.bz2 |
Get WebKit r44544.
Diffstat (limited to 'WebCore/platform/graphics/cg')
-rw-r--r-- | WebCore/platform/graphics/cg/GraphicsContextCG.cpp | 42 | ||||
-rw-r--r-- | WebCore/platform/graphics/cg/ImageSourceCG.cpp | 43 |
2 files changed, 50 insertions, 35 deletions
diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index 4b8a555..ab8eb3c 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -116,10 +116,9 @@ void GraphicsContext::drawRect(const IntRect& rect) CGContextRef context = platformContext(); - if (fillColor().alpha()) - CGContextFillRect(context, rect); + CGContextFillRect(context, rect); - if (strokeStyle() != NoStroke && strokeColor().alpha()) { + if (strokeStyle() != NoStroke) { // We do a fill of four rects to simulate the stroke of a border. Color oldFillColor = fillColor(); if (oldFillColor != strokeColor()) @@ -142,7 +141,7 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) if (paintingDisabled()) return; - if (strokeStyle() == NoStroke || !strokeColor().alpha()) + if (strokeStyle() == NoStroke) return; float width = strokeThickness(); @@ -277,7 +276,7 @@ void GraphicsContext::drawEllipse(const IntRect& rect) void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan) { - if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha()) + if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f) return; CGContextRef context = platformContext(); @@ -366,7 +365,7 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool antialiased) { - if (paintingDisabled() || !fillColor().alpha() && (strokeThickness() <= 0 || strokeStyle() == NoStroke)) + if (paintingDisabled()) return; if (npoints <= 1) @@ -491,8 +490,7 @@ void GraphicsContext::fillPath() CGContextRef context = platformContext(); switch (m_common->state.fillColorSpace) { case SolidColorSpace: - if (fillColor().alpha()) - fillPathWithFillRule(context, fillRule()); + fillPathWithFillRule(context, fillRule()); break; case PatternColorSpace: applyFillPattern(); @@ -519,8 +517,7 @@ void GraphicsContext::strokePath() CGContextRef context = platformContext(); switch (m_common->state.strokeColorSpace) { case SolidColorSpace: - if (strokeColor().alpha()) - CGContextStrokePath(context); + CGContextStrokePath(context); break; case PatternColorSpace: applyStrokePattern(); @@ -544,8 +541,7 @@ void GraphicsContext::fillRect(const FloatRect& rect) CGContextRef context = platformContext(); switch (m_common->state.fillColorSpace) { case SolidColorSpace: - if (fillColor().alpha()) - CGContextFillRect(context, rect); + CGContextFillRect(context, rect); break; case PatternColorSpace: applyFillPattern(); @@ -565,20 +561,18 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color) { if (paintingDisabled()) return; - if (color.alpha()) { - CGContextRef context = platformContext(); - Color oldFillColor = fillColor(); - if (oldFillColor != color) - setCGFillColor(context, color); - CGContextFillRect(context, rect); - if (oldFillColor != color) - setCGFillColor(context, oldFillColor); - } + CGContextRef context = platformContext(); + Color oldFillColor = fillColor(); + if (oldFillColor != color) + setCGFillColor(context, color); + CGContextFillRect(context, rect); + if (oldFillColor != color) + setCGFillColor(context, oldFillColor); } void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color) { - if (paintingDisabled() || !color.alpha()) + if (paintingDisabled()) return; CGContextRef context = platformContext(); @@ -782,8 +776,7 @@ void GraphicsContext::strokeRect(const FloatRect& r, float lineWidth) CGContextRef context = platformContext(); switch (m_common->state.strokeColorSpace) { case SolidColorSpace: - if (strokeColor().alpha()) - CGContextStrokeRectWithWidth(context, r, lineWidth); + CGContextStrokeRectWithWidth(context, r, lineWidth); break; case PatternColorSpace: applyStrokePattern(); @@ -1199,4 +1192,3 @@ void GraphicsContext::setCompositeOperation(CompositeOperator mode) #endif } - diff --git a/WebCore/platform/graphics/cg/ImageSourceCG.cpp b/WebCore/platform/graphics/cg/ImageSourceCG.cpp index c059985..7cb8799 100644 --- a/WebCore/platform/graphics/cg/ImageSourceCG.cpp +++ b/WebCore/platform/graphics/cg/ImageSourceCG.cpp @@ -33,10 +33,12 @@ #include "MIMETypeRegistry.h" #include "SharedBuffer.h" #include <ApplicationServices/ApplicationServices.h> +#include <wtf/UnusedParam.h> namespace WebCore { static const CFStringRef kCGImageSourceShouldPreferRGB32 = CFSTR("kCGImageSourceShouldPreferRGB32"); +static const CFStringRef kCGImageSourceDoNotCacheImageBlocks = CFSTR("kCGImageSourceDoNotCacheImageBlocks"); ImageSource::ImageSource() : m_decoder(0) @@ -48,11 +50,24 @@ ImageSource::~ImageSource() clear(true); } -void ImageSource::clear(bool, size_t, SharedBuffer* data, bool allDataReceived) +void ImageSource::clear(bool destroyAllFrames, size_t, SharedBuffer* data, bool allDataReceived) { - // We always destroy the decoder, because there is no API to get it to - // selectively release some of the frames it's holding, and if we don't - // release any of them, we use too much memory on large images. +#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + // Recent versions of ImageIO discard previously decoded image frames if the client + // application no longer holds references to them, so there's no need to throw away + // the decoder unless we're explicitly asked to destroy all of the frames. + + if (!destroyAllFrames) + return; +#else + // Older versions of ImageIO hold references to previously decoded image frames. + // There is no API to selectively release some of the frames it is holding, and + // if we don't release the frames we use too much memory on large images. + // Destroying the decoder is the only way to release previous frames. + + UNUSED_PARAM(destroyAllFrames); +#endif + if (m_decoder) { CFRelease(m_decoder); m_decoder = 0; @@ -66,9 +81,9 @@ static CFDictionaryRef imageSourceOptions() static CFDictionaryRef options; if (!options) { - const void* keys[2] = { kCGImageSourceShouldCache, kCGImageSourceShouldPreferRGB32 }; - const void* values[2] = { kCFBooleanTrue, kCFBooleanTrue }; - options = CFDictionaryCreate(NULL, keys, values, 2, + const void* keys[3] = { kCGImageSourceShouldCache, kCGImageSourceShouldPreferRGB32, kCGImageSourceDoNotCacheImageBlocks }; + const void* values[3] = { kCFBooleanTrue, kCFBooleanTrue, kCFBooleanTrue }; + options = CFDictionaryCreate(NULL, keys, values, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } return options; @@ -227,9 +242,17 @@ float ImageSource::frameDurationAtIndex(size_t index) bool ImageSource::frameHasAlphaAtIndex(size_t) { - // Might be interesting to do this optimization on Mac some day, but for now we're just using this - // for the Cairo source, since it uses our decoders, and our decoders can answer this question. - // FIXME: Could return false for JPEG and other non-transparent image formats. + if (!m_decoder) + return false; + + CFStringRef imageType = CGImageSourceGetType(m_decoder); + + // Return false if there is no image type or the image type is JPEG, because + // JPEG does not support alpha transparency. + if (!imageType || CFEqual(imageType, CFSTR("public.jpeg"))) + return false; + + // FIXME: Could return false for other non-transparent image formats. // FIXME: Could maybe return false for a GIF Frame if we have enough info in the GIF properties dictionary // to determine whether or not a transparent color was defined. return true; |