[chromium] Partially filled pixels do not occlude pixels below them.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jan 2012 02:21:02 +0000 (02:21 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jan 2012 02:21:02 +0000 (02:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76658

Patch by Dana Jansens <danakj@chromium.org> on 2012-01-20
Reviewed by James Robinson.

Source/WebCore:

Test: compositing/culling/tile-occlusion-boundaries.html

* platform/graphics/chromium/cc/CCQuadCuller.cpp:
(WebCore::enclosedIntRect):
(WebCore::CCQuadCuller::cullOccludedQuads):

LayoutTests:

* compositing/culling/tile-occlusion-boundaries-expected.png: Added.
* compositing/culling/tile-occlusion-boundaries-expected.txt: Added.
* compositing/culling/tile-occlusion-boundaries.html: Added.
* compositing/resources/green.jpg: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105561 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/compositing/culling/tile-occlusion-boundaries-expected.png [new file with mode: 0644]
LayoutTests/compositing/culling/tile-occlusion-boundaries-expected.txt [new file with mode: 0644]
LayoutTests/compositing/culling/tile-occlusion-boundaries.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.cpp

index d7b7957..a0ade6f 100644 (file)
@@ -1,3 +1,15 @@
+2012-01-20  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Partially filled pixels do not occlude pixels below them.
+        https://bugs.webkit.org/show_bug.cgi?id=76658
+
+        Reviewed by James Robinson.
+
+        * compositing/culling/tile-occlusion-boundaries-expected.png: Added.
+        * compositing/culling/tile-occlusion-boundaries-expected.txt: Added.
+        * compositing/culling/tile-occlusion-boundaries.html: Added.
+        * compositing/resources/green.jpg: Added.
+
 2012-01-20  Adam Barth  <abarth@webkit.org>
 
         Add a Chromium-specific baselines for
diff --git a/LayoutTests/compositing/culling/tile-occlusion-boundaries-expected.png b/LayoutTests/compositing/culling/tile-occlusion-boundaries-expected.png
new file mode 100644 (file)
index 0000000..052b46d
Binary files /dev/null and b/LayoutTests/compositing/culling/tile-occlusion-boundaries-expected.png differ
diff --git a/LayoutTests/compositing/culling/tile-occlusion-boundaries-expected.txt b/LayoutTests/compositing/culling/tile-occlusion-boundaries-expected.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/LayoutTests/compositing/culling/tile-occlusion-boundaries.html b/LayoutTests/compositing/culling/tile-occlusion-boundaries.html
new file mode 100644 (file)
index 0000000..d339185
--- /dev/null
@@ -0,0 +1,31 @@
+<html>
+<head>
+  <style>
+    .scaled { /* Ends up 255.5px by 255.5px */
+      position:relative;
+      left: 128; top: 128;
+      width:511px;
+      height:511px;
+      -webkit-transform: translateZ(0px) scale(0.5);
+    }
+    body { position:relative; }
+  </style>
+
+  <script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController) {
+      layoutTestController.dumpAsText(true);
+    }
+  </script>
+</head>
+
+<body style="margin:0; padding:0;">
+<!--
+   If the test passes you should see a solid green square with no blue on its edges.
+
+   The image sits such that it completely fills a tile in the white background layer. However some of the edge pixels of the box are only partially
+   filled, so they end up being blended with part of the pixel behind them. If culling treats them as opaque, then the background tile below is culled
+   inappropriately, and the edge pixels come out mixed with blue since the partial pixels behind were not filled.
+-->
+<img class="scaled green" src="../../fast/images/resources/green.jpg"></img>
+</body>
+</html>
index 0f43619..e3d862a 100644 (file)
@@ -1,3 +1,16 @@
+2012-01-20  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Partially filled pixels do not occlude pixels below them.
+        https://bugs.webkit.org/show_bug.cgi?id=76658
+
+        Reviewed by James Robinson.
+
+        Test: compositing/culling/tile-occlusion-boundaries.html
+
+        * platform/graphics/chromium/cc/CCQuadCuller.cpp:
+        (WebCore::enclosedIntRect):
+        (WebCore::CCQuadCuller::cullOccludedQuads):
+
 2012-01-20  Ami Fischman  <fischman@chromium.org>
 
         Small cleanup of {get,put}CurrentFrame for  WebMediaPlayerClientImpl/CCVideoLayerImpl.
index 079aa7f..d30ffc8 100644 (file)
@@ -35,6 +35,8 @@
 #include "cc/CCRenderPass.h"
 #include "cc/CCRenderSurfaceDrawQuad.h"
 
+using namespace std;
+
 namespace std {
 
 // Specialize for OwnPtr<CCDrawQuad> since Vector doesn't know how to reverse a Vector of OwnPtr<T> in general.
@@ -60,6 +62,18 @@ static bool regionContainsRect(const Region& region, const IntRect& rect)
     return rectRegion.isEmpty();
 }
 
+static IntRect enclosedIntRect(const FloatRect& rect)
+{
+    float x = ceilf(rect.x());
+    float y = ceilf(rect.y());
+    // A rect of width 0 should not become a rect of width -1.
+    float width = max<float>(floorf(rect.maxX()) - x, 0);
+    float height = max<float>(floorf(rect.maxY()) - y, 0);
+
+    return IntRect(clampToInteger(x), clampToInteger(y),
+                   clampToInteger(width), clampToInteger(height));
+}
+
 void CCQuadCuller::cullOccludedQuads(CCQuadList& quadList)
 {
     if (!quadList.size())
@@ -77,8 +91,10 @@ void CCQuadCuller::cullOccludedQuads(CCQuadList& quadList)
 
         bool keepQuad = !regionContainsRect(opaqueCoverageThusFar, quadRect);
 
-        if (keepQuad && drawQuad->drawsOpaque() && drawQuad->isLayerAxisAlignedIntRect())
-            opaqueCoverageThusFar.unite(Region(quadRect));
+        if (keepQuad && drawQuad->drawsOpaque() && drawQuad->isLayerAxisAlignedIntRect()) {
+            IntRect opaqueRect = enclosedIntRect(drawQuad->quadTransform().mapRect(FloatRect(drawQuad->quadRect())));
+            opaqueCoverageThusFar.unite(opaqueRect);
+        }
 
         if (keepQuad)
             culledList.append(quadList[i].release());