Title: [191117] trunk/Source/WebCore
Revision
191117
Author
simon.fra...@apple.com
Date
2015-10-15 10:20:10 -0700 (Thu, 15 Oct 2015)

Log Message

Move ImageBuffer:clip() into GraphicsContextCG
https://bugs.webkit.org/show_bug.cgi?id=150140

Reviewed by Zalan Bujtas.

Move the guts of CG's ImageBuffer:clip() into GraphicsContextCG.

* platform/graphics/GraphicsContext.h:
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::clipToNativeImage):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::clip):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (191116 => 191117)


--- trunk/Source/WebCore/ChangeLog	2015-10-15 16:54:49 UTC (rev 191116)
+++ trunk/Source/WebCore/ChangeLog	2015-10-15 17:20:10 UTC (rev 191117)
@@ -1,3 +1,18 @@
+2015-10-14  Simon Fraser  <simon.fra...@apple.com>
+
+        Move ImageBuffer:clip() into GraphicsContextCG
+        https://bugs.webkit.org/show_bug.cgi?id=150140
+
+        Reviewed by Zalan Bujtas.
+
+        Move the guts of CG's ImageBuffer:clip() into GraphicsContextCG.
+
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::clipToNativeImage):
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::clip):
+
 2015-10-14  Brady Eidson  <beid...@apple.com>
 
         Modern IDB: Add basic transaction committing.

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (191116 => 191117)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2015-10-15 16:54:49 UTC (rev 191116)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2015-10-15 17:20:10 UTC (rev 191117)
@@ -262,6 +262,8 @@
 
         WEBCORE_EXPORT void drawNativeImage(PassNativeImagePtr, const FloatSize& selfSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
 
+        void clipToNativeImage(PassNativeImagePtr, const FloatRect& destRect, const FloatSize& bufferSize);
+
         // Allow font smoothing (LCD antialiasing). Not part of the graphics state.
         void setAllowsFontSmoothing(bool);
         

Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (191116 => 191117)


--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp	2015-10-15 16:54:49 UTC (rev 191116)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp	2015-10-15 17:20:10 UTC (rev 191117)
@@ -345,6 +345,18 @@
     }
 }
 
+void GraphicsContext::clipToNativeImage(PassNativeImagePtr image, const FloatRect& destRect, const FloatSize& bufferSize)
+{
+    CGContextRef context = platformContext();
+    // FIXME: This image needs to be grayscale to be used as an alpha mask here.
+    CGContextTranslateCTM(context, destRect.x(), destRect.y() + bufferSize.height());
+    CGContextScaleCTM(context, 1, -1);
+    CGContextClipToRect(context, FloatRect(FloatPoint(0, bufferSize.height() - destRect.height()), destRect.size()));
+    CGContextClipToMask(context, FloatRect(FloatPoint(), bufferSize), image);
+    CGContextScaleCTM(context, 1, -1);
+    CGContextTranslateCTM(context, -destRect.x(), -destRect.y() - destRect.height());
+}
+
 // Draws a filled rectangle with a stroked border.
 void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness)
 {

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (191116 => 191117)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2015-10-15 16:54:49 UTC (rev 191116)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2015-10-15 17:20:10 UTC (rev 191117)
@@ -266,16 +266,8 @@
 void ImageBuffer::clip(GraphicsContext& contextToClip, const FloatRect& rect) const
 {
     FloatSize backingStoreSizeInUserSpace = scaleSizeToUserSpace(rect.size(), m_data.backingStoreSize, internalSize());
-
-    CGContextRef platformContextToClip = contextToClip.platformContext();
-    // FIXME: This image needs to be grayscale to be used as an alpha mask here.
     RetainPtr<CGImageRef> image = copyNativeImage(DontCopyBackingStore);
-    CGContextTranslateCTM(platformContextToClip, rect.x(), rect.y() + backingStoreSizeInUserSpace.height());
-    CGContextScaleCTM(platformContextToClip, 1, -1);
-    CGContextClipToRect(platformContextToClip, FloatRect(FloatPoint(0, backingStoreSizeInUserSpace.height() - rect.height()), rect.size()));
-    CGContextClipToMask(platformContextToClip, FloatRect(FloatPoint(), backingStoreSizeInUserSpace), image.get());
-    CGContextScaleCTM(platformContextToClip, 1, -1);
-    CGContextTranslateCTM(platformContextToClip, -rect.x(), -rect.y() - rect.height());
+    contextToClip.clipToNativeImage(image.get(), rect, backingStoreSizeInUserSpace);
 }
 
 PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem coordinateSystem) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to