From 65f03d4f644ce73618e5f4f50dd694b26f55ae12 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Fri, 13 May 2011 16:23:25 +0100 Subject: Merge WebKit at r75993: Initial merge by git. Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3 --- .../platform/graphics/cg/GraphicsContextCG.cpp | 47 +++++++++++++++++----- .../graphics/cg/GraphicsContextPlatformPrivateCG.h | 5 +++ .../WebCore/platform/graphics/cg/ImageBufferCG.cpp | 11 +++-- .../platform/graphics/cg/PDFDocumentImage.h | 5 +++ 4 files changed, 54 insertions(+), 14 deletions(-) (limited to 'Source/WebCore/platform/graphics/cg') diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index acd912f..eddf735 100644 --- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -546,21 +546,46 @@ void GraphicsContext::fillPath(const Path& path) CGContextRef context = platformContext(); - CGContextBeginPath(context); - CGContextAddPath(context, path.platformPath()); - if (m_state.fillGradient) { - CGContextSaveGState(context); - if (fillRule() == RULE_EVENODD) - CGContextEOClip(context); - else - CGContextClip(context); - CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform()); - m_state.fillGradient->paint(this); - CGContextRestoreGState(context); + if (hasShadow()) { + FloatRect rect = path.boundingRect(); + CGLayerRef layer = CGLayerCreateWithContext(context, CGSizeMake(rect.width(), rect.height()), 0); + CGContextRef layerContext = CGLayerGetContext(layer); + + CGContextTranslateCTM(layerContext, -rect.x(), -rect.y()); + CGContextBeginPath(layerContext); + CGContextAddPath(layerContext, path.platformPath()); + CGContextConcatCTM(layerContext, m_state.fillGradient->gradientSpaceTransform()); + + if (fillRule() == RULE_EVENODD) + CGContextEOClip(layerContext); + else + CGContextClip(layerContext); + + m_state.fillGradient->paint(layerContext); + CGContextDrawLayerAtPoint(context, CGPointMake(rect.left(), rect.top()), layer); + CGLayerRelease(layer); + } else { + CGContextBeginPath(context); + CGContextAddPath(context, path.platformPath()); + CGContextSaveGState(context); + CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform()); + + if (fillRule() == RULE_EVENODD) + CGContextEOClip(context); + else + CGContextClip(context); + + m_state.fillGradient->paint(this); + CGContextRestoreGState(context); + } + return; } + CGContextBeginPath(context); + CGContextAddPath(context, path.platformPath()); + if (m_state.fillPattern) applyFillPattern(); fillPathWithFillRule(context, fillRule()); diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h b/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h index 1d0a99f..d4fa32e 100644 --- a/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h +++ b/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h @@ -23,6 +23,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef GraphicsContextPlatformPrivateCG_h +#define GraphicsContextPlatformPrivateCG_h + #include #include @@ -84,3 +87,5 @@ public: }; } + +#endif // GraphicsContextPlatformPrivateCG_h diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp index 75a36e5..023d098 100644 --- a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp +++ b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp @@ -54,6 +54,8 @@ using namespace std; namespace WebCore { #if USE(IOSURFACE_CANVAS_BACKING_STORE) +static const int maxIOSurfaceDimension = 4096; + static RetainPtr createIOSurface(const IntSize& size) { unsigned pixelFormat = 'BGRA'; @@ -110,12 +112,15 @@ ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace imageColorSpace, Render , m_size(size) , m_accelerateRendering(renderingMode == Accelerated) { -#if !USE(IOSURFACE_CANVAS_BACKING_STORE) - ASSERT(renderingMode == Unaccelerated); -#endif success = false; // Make early return mean failure. if (size.width() < 0 || size.height() < 0) return; +#if USE(IOSURFACE_CANVAS_BACKING_STORE) + if (size.width() >= maxIOSurfaceDimension || size.height() >= maxIOSurfaceDimension) + m_accelerateRendering = false; +#else + ASSERT(renderingMode == Unaccelerated); +#endif unsigned bytesPerRow = size.width(); if (bytesPerRow > 0x3FFFFFFF) // Protect against overflow diff --git a/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h b/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h index 790d620..ecd57be 100644 --- a/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h +++ b/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h @@ -23,6 +23,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef PDFDocumentImage_h +#define PDFDocumentImage_h + #include "Image.h" #include "FloatRect.h" @@ -76,3 +79,5 @@ namespace WebCore { } #endif // PLATFORM(CG) + +#endif // PDFDocumentImage_h -- cgit v1.1