Title: [109514] trunk
Revision
109514
Author
[email protected]
Date
2012-03-01 22:47:13 -0800 (Thu, 01 Mar 2012)

Log Message

[chromium] Make opaque paint tracker aware of SkCanvas layers
https://bugs.webkit.org/show_bug.cgi?id=79145

Patch by Dana Jansens <[email protected]> on 2012-03-01
Reviewed by Stephen White.

Source/WebCore:

The current opaque paint tracker ignored SkCanvas layers entirely. But
SkCanvas layers can be used to apply things like alpha. So we make it
know about layers, and apply any clipping and SkPaint objects for layers
when tracking a paint.

Image clipping is done via a layer, so we can now also remove the
special-case code around image clipping in PlatformContextSkia and
OpaqueRegionSkia.

Unit test: PlatformContextSkiaTest.contextTransparencyLayerTest

Test: compositing/culling/clear-fixed-iframe.html

* platform/graphics/skia/OpaqueRegionSkia.cpp:
(WebCore::OpaqueRegionSkia::didDrawRect):
(WebCore::OpaqueRegionSkia::didDrawPath):
(WebCore::OpaqueRegionSkia::didDrawPoints):
(WebCore::OpaqueRegionSkia::didDrawBounded):
(WebCore::OpaqueRegionSkia::didDraw):
(WebCore):
* platform/graphics/skia/OpaqueRegionSkia.h:
(OpaqueRegionSkia):
* platform/graphics/skia/PlatformContextSkia.cpp:
* platform/graphics/skia/PlatformContextSkia.h:
(PlatformContextSkia):

Source/WebKit/chromium:

* tests/PlatformContextSkiaTest.cpp:
(WebCore::TEST):
(WebCore):

LayoutTests:

* compositing/culling/clear-fixed-iframe-expected.png: Added.
* compositing/culling/clear-fixed-iframe-expected.txt: Added.
* compositing/culling/clear-fixed-iframe.html: Added.
* compositing/culling/resources/clear-fixed-iframe-content.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (109513 => 109514)


--- trunk/LayoutTests/ChangeLog	2012-03-02 06:43:31 UTC (rev 109513)
+++ trunk/LayoutTests/ChangeLog	2012-03-02 06:47:13 UTC (rev 109514)
@@ -1,3 +1,15 @@
+2012-03-01  Dana Jansens  <[email protected]>
+
+        [chromium] Make opaque paint tracker aware of SkCanvas layers
+        https://bugs.webkit.org/show_bug.cgi?id=79145
+
+        Reviewed by Stephen White.
+
+        * compositing/culling/clear-fixed-iframe-expected.png: Added.
+        * compositing/culling/clear-fixed-iframe-expected.txt: Added.
+        * compositing/culling/clear-fixed-iframe.html: Added.
+        * compositing/culling/resources/clear-fixed-iframe-content.html: Added.
+
 2012-03-01  Hironori Bono  <[email protected]>
 
         Render overflow controls of an RTL element to its left-side.

Added: trunk/LayoutTests/compositing/culling/clear-fixed-iframe-expected.png (0 => 109514)


--- trunk/LayoutTests/compositing/culling/clear-fixed-iframe-expected.png	                        (rev 0)
+++ trunk/LayoutTests/compositing/culling/clear-fixed-iframe-expected.png	2012-03-02 06:47:13 UTC (rev 109514)
@@ -0,0 +1,6 @@
+\x89PNG
+
+
+IHDR X')tEXtchecksumc4ced6fc3879acf1d2567835da54860d\xC9\xF0\xBD
+\xBDIDATx\x9C\xED\xD8A
+\x800A@,:\xD0Q\xE8\xC0xn\xD2\xD0\xCC(\xB8\xE7\xE6\xF6\xF3>7\x80Ϙ=\xE1\xC31{\xC0j@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4\xF6\xED\x9A=`-,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\xD8Z\xAF(\xD9\xD7IEND\xAEB`\x82
\ No newline at end of file

Added: trunk/LayoutTests/compositing/culling/clear-fixed-iframe-expected.txt (0 => 109514)


--- trunk/LayoutTests/compositing/culling/clear-fixed-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/culling/clear-fixed-iframe-expected.txt	2012-03-02 06:47:13 UTC (rev 109514)
@@ -0,0 +1 @@
+

Added: trunk/LayoutTests/compositing/culling/clear-fixed-iframe.html (0 => 109514)


--- trunk/LayoutTests/compositing/culling/clear-fixed-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/culling/clear-fixed-iframe.html	2012-03-02 06:47:13 UTC (rev 109514)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html><head><title>Compositor Iframe Sadface</title>
+<style>
+body { margin: 0; padding: 0; }
+.composited {
+  -webkit-transform: translateZ(0);
+  background-color: green;
+  position:fixed;
+  left:0; top:0; right:0; bottom:0;
+}
+iframe {
+  position:fixed;
+  left: 0; top: 0;
+  width:100%;
+  height: 100%;
+  border:0;
+}
+</style>
+<script type="text/_javascript_">
+  if (window.layoutTestController) {
+    layoutTestController.dumpAsText(true);
+  }
+</script>
+</head>
+
+<body>
+<div class="composited"></div>
+
+<!-- You should see a light green box filling the top/left of the window, inside a darker green background.
+     If the "glass" in the iframe is considered opaque, then drawing errors will occur and tiles become black
+     (light gray with the glass).
+  -->
+<iframe src="" frameborder="0"></iframe>
+</body>
+
+</html>

Added: trunk/LayoutTests/compositing/culling/resources/clear-fixed-iframe-content.html (0 => 109514)


--- trunk/LayoutTests/compositing/culling/resources/clear-fixed-iframe-content.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/culling/resources/clear-fixed-iframe-content.html	2012-03-02 06:47:13 UTC (rev 109514)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html><head><title></title>
+<style>
+body { margin:0; padding:0; }
+
+#glass {
+  opacity:0.4;
+  background-color:white;
+  position:absolute;
+  top:0px; left:0px; right:50px; bottom: 50px;
+}
+</style>
+</head>
+
+<body>
+<div id="glass"></div>
+</body>
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (109513 => 109514)


--- trunk/Source/WebCore/ChangeLog	2012-03-02 06:43:31 UTC (rev 109513)
+++ trunk/Source/WebCore/ChangeLog	2012-03-02 06:47:13 UTC (rev 109514)
@@ -1,3 +1,36 @@
+2012-03-01  Dana Jansens  <[email protected]>
+
+        [chromium] Make opaque paint tracker aware of SkCanvas layers
+        https://bugs.webkit.org/show_bug.cgi?id=79145
+
+        Reviewed by Stephen White.
+
+        The current opaque paint tracker ignored SkCanvas layers entirely. But
+        SkCanvas layers can be used to apply things like alpha. So we make it
+        know about layers, and apply any clipping and SkPaint objects for layers
+        when tracking a paint.
+
+        Image clipping is done via a layer, so we can now also remove the
+        special-case code around image clipping in PlatformContextSkia and
+        OpaqueRegionSkia.
+
+        Unit test: PlatformContextSkiaTest.contextTransparencyLayerTest
+
+        Test: compositing/culling/clear-fixed-iframe.html
+
+        * platform/graphics/skia/OpaqueRegionSkia.cpp:
+        (WebCore::OpaqueRegionSkia::didDrawRect):
+        (WebCore::OpaqueRegionSkia::didDrawPath):
+        (WebCore::OpaqueRegionSkia::didDrawPoints):
+        (WebCore::OpaqueRegionSkia::didDrawBounded):
+        (WebCore::OpaqueRegionSkia::didDraw):
+        (WebCore):
+        * platform/graphics/skia/OpaqueRegionSkia.h:
+        (OpaqueRegionSkia):
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        * platform/graphics/skia/PlatformContextSkia.h:
+        (PlatformContextSkia):
+
 2012-03-02  Kent Tamura  <[email protected]>
 
         Add HTML-capable popup API to ChromeClient

Modified: trunk/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.cpp (109513 => 109514)


--- trunk/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.cpp	2012-03-02 06:43:31 UTC (rev 109513)
+++ trunk/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.cpp	2012-03-02 06:47:13 UTC (rev 109514)
@@ -147,7 +147,7 @@
     return true;
 }
 
-void OpaqueRegionSkia::didDrawRect(const PlatformContextSkia* context, const AffineTransform& transform, const SkRect& fillRect, const SkPaint& paint, const SkBitmap* bitmap)
+void OpaqueRegionSkia::didDrawRect(PlatformContextSkia* context, const AffineTransform& transform, const SkRect& fillRect, const SkPaint& paint, const SkBitmap* bitmap)
 {
     // Any stroking may put alpha in pixels even if the filling part does not.
     if (paint.getStyle() != SkPaint::kFill_Style) {
@@ -169,7 +169,7 @@
     didDraw(context, transform, fillRect, paint, opaque, fillsBounds);
 }
 
-void OpaqueRegionSkia::didDrawPath(const PlatformContextSkia* context, const AffineTransform& transform, const SkPath& path, const SkPaint& paint)
+void OpaqueRegionSkia::didDrawPath(PlatformContextSkia* context, const AffineTransform& transform, const SkPath& path, const SkPaint& paint)
 {
     SkRect rect;
     if (path.isRect(&rect)) {
@@ -188,7 +188,7 @@
     }
 }
 
-void OpaqueRegionSkia::didDrawPoints(const PlatformContextSkia* context, const AffineTransform& transform, SkCanvas::PointMode mode, int numPoints, const SkPoint points[], const SkPaint& paint)
+void OpaqueRegionSkia::didDrawPoints(PlatformContextSkia* context, const AffineTransform& transform, SkCanvas::PointMode mode, int numPoints, const SkPoint points[], const SkPaint& paint)
 {
     if (!numPoints)
         return;
@@ -217,7 +217,7 @@
     }
 }
 
-void OpaqueRegionSkia::didDrawBounded(const PlatformContextSkia* context, const AffineTransform& transform, const SkRect& bounds, const SkPaint& paint)
+void OpaqueRegionSkia::didDrawBounded(PlatformContextSkia* context, const AffineTransform& transform, const SkRect& bounds, const SkPaint& paint)
 {
     bool opaque = paintIsOpaque(paint);
     bool fillsBounds = false;
@@ -231,10 +231,13 @@
     }
 }
 
-void OpaqueRegionSkia::didDraw(const PlatformContextSkia* context, const AffineTransform& transform, const SkRect& rect, const SkPaint& paint, bool drawsOpaque, bool fillsBounds)
+void OpaqueRegionSkia::didDraw(PlatformContextSkia* context, const AffineTransform& transform, const SkRect& rect, const SkPaint& paint, bool drawsOpaque, bool fillsBounds)
 {
     SkRect targetRect = rect;
 
+    bool xfersOpaque = xfermodeIsOpaque(paint, drawsOpaque);
+    bool preservesOpaque = xfermodePreservesOpaque(paint, drawsOpaque);
+
     // Apply the transform to device coordinate space.
     SkMatrix canvasTransform = context->canvas()->getTotalMatrix();
     if (!canvasTransform.mapRect(&targetRect))
@@ -249,17 +252,33 @@
         if (!targetRect.intersect(SkIntToScalar(deviceClip.fLeft), SkIntToScalar(deviceClip.fTop), SkIntToScalar(deviceClip.fRight), SkIntToScalar(deviceClip.fBottom)))
             return;
     }
-    if (!context->clippedToImage().isOpaque())
-        fillsBounds = false;
 
+    // Apply any layers that we are drawing into.
+    for (SkCanvas::LayerIter it(context->canvas(), false); !it.done(); it.next()) {
+        // Apply the layer's clip (which is in device space)
+        const SkRegion& deviceLayerClip = it.clip();
+        if (deviceLayerClip.isEmpty() || !deviceLayerClip.isRect())
+            fillsBounds = false;
+        else {
+            SkIRect clipBounds = it.clip().getBounds();
+            if (!targetRect.intersect(SkIntToScalar(clipBounds.fLeft), SkIntToScalar(clipBounds.fTop), SkIntToScalar(clipBounds.fRight), SkIntToScalar(clipBounds.fBottom)))
+                return;
+        }
+
+        // Make sure the paint stays opaque through the layer.
+        bool drawsOpaque = paintIsOpaque(it.paint());
+        xfersOpaque = xfersOpaque && xfermodeIsOpaque(it.paint(), drawsOpaque);
+        preservesOpaque = preservesOpaque && xfermodePreservesOpaque(it.paint(), drawsOpaque);
+    }
+
     // Apply the transform to the tracking space.
     SkMatrix canvasToTargetTransform = transform;
     if (!canvasToTargetTransform.mapRect(&targetRect))
         fillsBounds = false;
 
-    if (fillsBounds && xfermodeIsOpaque(paint, drawsOpaque))
+    if (fillsBounds && xfersOpaque)
         markRectAsOpaque(targetRect);
-    else if (SkRect::Intersects(targetRect, m_opaqueRect) && !xfermodePreservesOpaque(paint, drawsOpaque))
+    else if (SkRect::Intersects(targetRect, m_opaqueRect) && !preservesOpaque)
         markRectAsNonOpaque(targetRect);
 }
 
@@ -339,4 +358,5 @@
         m_opaqueRect = vertical;
 }
 
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.h (109513 => 109514)


--- trunk/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.h	2012-03-02 06:43:31 UTC (rev 109513)
+++ trunk/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.h	2012-03-02 06:47:13 UTC (rev 109514)
@@ -53,13 +53,15 @@
     // The resulting opaque region as a single rect.
     IntRect asRect() const;
 
-    void didDrawRect(const PlatformContextSkia*, const AffineTransform&, const SkRect&, const SkPaint&, const SkBitmap*);
-    void didDrawPath(const PlatformContextSkia*, const AffineTransform&, const SkPath&, const SkPaint&);
-    void didDrawPoints(const PlatformContextSkia*, const AffineTransform&, SkCanvas::PointMode, int numPoints, const SkPoint[], const SkPaint&);
-    void didDrawBounded(const PlatformContextSkia*, const AffineTransform&, const SkRect&, const SkPaint&);
+    // FIXME: make all the PlatformContextSkia* into a const pointer when Skia fixes LayerIter's SkCanvas*.
 
+    void didDrawRect(PlatformContextSkia*, const AffineTransform&, const SkRect&, const SkPaint&, const SkBitmap*);
+    void didDrawPath(PlatformContextSkia*, const AffineTransform&, const SkPath&, const SkPaint&);
+    void didDrawPoints(PlatformContextSkia*, const AffineTransform&, SkCanvas::PointMode, int numPoints, const SkPoint[], const SkPaint&);
+    void didDrawBounded(PlatformContextSkia*, const AffineTransform&, const SkRect&, const SkPaint&);
+
 private:
-    void didDraw(const PlatformContextSkia*, const AffineTransform&, const SkRect&, const SkPaint&, bool drawsOpaque, bool fillsBounds);
+    void didDraw(PlatformContextSkia*, const AffineTransform&, const SkRect&, const SkPaint&, bool drawsOpaque, bool fillsBounds);
     void didDrawUnbounded(const SkPaint&, bool drawsOpaque);
     void markRectAsOpaque(const SkRect&);
     void markRectAsNonOpaque(const SkRect&);

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp (109513 => 109514)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2012-03-02 06:43:31 UTC (rev 109513)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2012-03-02 06:47:13 UTC (rev 109514)
@@ -267,11 +267,6 @@
     canvas()->clipPath(clipPath, SkRegion::kIntersect_Op, true);
 }
 
-const SkBitmap& PlatformContextSkia::clippedToImage() const
-{
-    return m_state->m_imageBufferClip;
-}
-
 void PlatformContextSkia::restore()
 {
     if (!m_state->m_imageBufferClip.empty()) {

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h (109513 => 109514)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2012-03-02 06:43:31 UTC (rev 109513)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2012-03-02 06:47:13 UTC (rev 109514)
@@ -100,8 +100,6 @@
     // NOTE: |imageBuffer| may be deleted before the |restore| is invoked.
     void beginLayerClippedToImage(const FloatRect&, const ImageBuffer*);
     void clipPathAntiAliased(const SkPath&);
-    // If non-empty, the layer is clipped to the bitmap.
-    const SkBitmap& clippedToImage() const;
 
     // Sets up the common flags on a paint for antialiasing, effects, etc.
     // This is implicitly called by setupPaintFill and setupPaintStroke, but

Modified: trunk/Source/WebKit/chromium/ChangeLog (109513 => 109514)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-03-02 06:43:31 UTC (rev 109513)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-03-02 06:47:13 UTC (rev 109514)
@@ -1,3 +1,14 @@
+2012-03-01  Dana Jansens  <[email protected]>
+
+        [chromium] Make opaque paint tracker aware of SkCanvas layers
+        https://bugs.webkit.org/show_bug.cgi?id=79145
+
+        Reviewed by Stephen White.
+
+        * tests/PlatformContextSkiaTest.cpp:
+        (WebCore::TEST):
+        (WebCore):
+
 2012-03-01  Hironori Bono  <[email protected]>
 
         Render overflow controls of an RTL element to its left-side.

Modified: trunk/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp (109513 => 109514)


--- trunk/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp	2012-03-02 06:43:31 UTC (rev 109513)
+++ trunk/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp	2012-03-02 06:47:13 UTC (rev 109514)
@@ -641,4 +641,44 @@
     EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
 }
 
+TEST(PlatformContextSkiaTest, contextTransparencyLayerTest)
+{
+    SkBitmap bitmap;
+    bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+    bitmap.allocPixels();
+    bitmap.eraseColor(0);
+    SkCanvas canvas(bitmap);
+    AffineTransform transform;
+    transform.scale(2);
+
+    PlatformContextSkia platformContext(&canvas);
+    platformContext.setTrackOpaqueRegion(true);
+    platformContext.setOpaqueRegionTransform(transform);
+    GraphicsContext context(&platformContext);
+    
+    Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+    
+    context.fillRect(FloatRect(20, 20, 10, 10), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+    EXPECT_EQ_RECT(IntRect(40, 40, 20, 20), platformContext.opaqueRegion().asRect());
+    EXPECT_PIXELS_MATCH(bitmap, transform.inverse().mapRect(platformContext.opaqueRegion().asRect()));
+    
+    context.clearRect(FloatRect(20, 20, 10, 10));
+    EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+
+    context.beginTransparencyLayer(0.5);
+    context.save();
+    context.fillRect(FloatRect(20, 20, 10, 10), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+    context.restore();
+    context.endTransparencyLayer();
+    EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+
+    context.clearRect(FloatRect(20, 20, 10, 10));
+    EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+
+    context.beginTransparencyLayer(0.5);
+    context.fillRect(FloatRect(20, 20, 10, 10), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+    context.endTransparencyLayer();
+    EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+}
+
 } // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to