Title: [110968] trunk/Source
Revision
110968
Author
commit-qu...@webkit.org
Date
2012-03-16 01:39:41 -0700 (Fri, 16 Mar 2012)

Log Message

[chromium] Quads that become fully opaque after culling should not use blending
https://bugs.webkit.org/show_bug.cgi?id=81235

Patch by Dana Jansens <dan...@chromium.org> on 2012-03-16
Reviewed by Adrienne Walker.

Source/WebCore:

Unit test: CCLayerTreeHostImplTest.blendingOffWhenDrawingOpaqueLayers

* platform/graphics/chromium/cc/CCDrawQuad.h:
(WebCore::CCDrawQuad::needsBlending):

Source/WebKit/chromium:

* tests/CCLayerTreeHostImplTest.cpp:
(WebKit::BlendStateCheckLayer::appendQuads):
(WebKit::BlendStateCheckLayer::setQuadRect):
(WebKit::BlendStateCheckLayer::setQuadVisibleRect):
(WebKit::BlendStateCheckLayer::setOpaqueContents):
(WebKit::BlendStateCheckLayer::setOpaqueContentRect):
(WebKit::BlendStateCheckLayer::BlendStateCheckLayer):
(BlendStateCheckLayer):
(WebKit::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110967 => 110968)


--- trunk/Source/WebCore/ChangeLog	2012-03-16 08:36:56 UTC (rev 110967)
+++ trunk/Source/WebCore/ChangeLog	2012-03-16 08:39:41 UTC (rev 110968)
@@ -1,3 +1,15 @@
+2012-03-16  Dana Jansens  <dan...@chromium.org>
+
+        [chromium] Quads that become fully opaque after culling should not use blending
+        https://bugs.webkit.org/show_bug.cgi?id=81235
+
+        Reviewed by Adrienne Walker.
+
+        Unit test: CCLayerTreeHostImplTest.blendingOffWhenDrawingOpaqueLayers
+
+        * platform/graphics/chromium/cc/CCDrawQuad.h:
+        (WebCore::CCDrawQuad::needsBlending):
+
 2012-03-16  Xiaomei Ji  <x...@chromium.org>
 
         Using ICU break iterator to simplify visual word movement implementation.

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.h (110967 => 110968)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.h	2012-03-16 08:36:56 UTC (rev 110967)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.h	2012-03-16 08:39:41 UTC (rev 110968)
@@ -51,9 +51,9 @@
     const IntRect& layerRect() const { return m_sharedQuadState->layerRect(); }
     const IntRect& clipRect() const { return m_sharedQuadState->clipRect(); }
     float opacity() const { return m_sharedQuadState->opacity(); }
-    // For the purposes of culling, what part of the contents of this quad are opaque?
+    // For the purposes of blending, what part of the contents of this quad are opaque?
     IntRect opaqueRect() const;
-    bool needsBlending() const { return m_needsBlending || opaqueRect() != m_quadRect; }
+    bool needsBlending() const { return m_needsBlending || !opaqueRect().contains(m_quadVisibleRect); }
     bool isLayerAxisAlignedIntRect() const { return m_sharedQuadState->isLayerAxisAlignedIntRect(); }
 
     // Allows changing the rect that gets drawn to make it smaller. Parameter passed

Modified: trunk/Source/WebKit/chromium/ChangeLog (110967 => 110968)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-03-16 08:36:56 UTC (rev 110967)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-03-16 08:39:41 UTC (rev 110968)
@@ -1,3 +1,20 @@
+2012-03-16  Dana Jansens  <dan...@chromium.org>
+
+        [chromium] Quads that become fully opaque after culling should not use blending
+        https://bugs.webkit.org/show_bug.cgi?id=81235
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCLayerTreeHostImplTest.cpp:
+        (WebKit::BlendStateCheckLayer::appendQuads):
+        (WebKit::BlendStateCheckLayer::setQuadRect):
+        (WebKit::BlendStateCheckLayer::setQuadVisibleRect):
+        (WebKit::BlendStateCheckLayer::setOpaqueContents):
+        (WebKit::BlendStateCheckLayer::setOpaqueContentRect):
+        (WebKit::BlendStateCheckLayer::BlendStateCheckLayer):
+        (BlendStateCheckLayer):
+        (WebKit::TEST_F):
+
 2012-03-15  Hans Wennborg  <h...@chromium.org>
 
         Speech _javascript_ API: SpeechRecognition, Controller and Client

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (110967 => 110968)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2012-03-16 08:36:56 UTC (rev 110967)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2012-03-16 08:39:41 UTC (rev 110968)
@@ -31,7 +31,7 @@
 #include "LayerRendererChromium.h"
 #include "cc/CCLayerImpl.h"
 #include "cc/CCSingleThreadProxy.h"
-#include "cc/CCSolidColorDrawQuad.h"
+#include "cc/CCTileDrawQuad.h"
 #include <gtest/gtest.h>
 
 using namespace WebCore;
@@ -517,8 +517,13 @@
     {
         m_quadsAppended = true;
 
-        Color color = m_opaqueColor ? Color::white : Color(0, 0, 0, 0);
-        OwnPtr<CCDrawQuad> testBlendingDrawQuad = CCSolidColorDrawQuad::create(sharedQuadState, IntRect(5, 5, 5, 5), color);
+        IntRect opaqueRect;
+        if (opaque() || m_opaqueContents)
+            opaqueRect = m_quadRect;
+        else
+            opaqueRect = m_opaqueContentRect;
+        OwnPtr<CCDrawQuad> testBlendingDrawQuad = CCTileDrawQuad::create(sharedQuadState, m_quadRect, opaqueRect, 0, IntPoint(), IntSize(1, 1), 0, false, false, false, false, false);
+        testBlendingDrawQuad->setQuadVisibleRect(m_quadVisibleRect);
         EXPECT_EQ(m_blend, testBlendingDrawQuad->needsBlending());
         EXPECT_EQ(m_hasRenderSurface, !!renderSurface());
     }
@@ -532,7 +537,10 @@
 
     bool quadsAppended() const { return m_quadsAppended; }
 
-    void setOpaqueColor(bool opaqueColor) { m_opaqueColor = opaqueColor; }
+    void setQuadRect(const IntRect& rect) { m_quadRect = rect; }
+    void setQuadVisibleRect(const IntRect& rect) { m_quadVisibleRect = rect; }
+    void setOpaqueContents(bool opaque) { m_opaqueContents = opaque; }
+    void setOpaqueContentRect(const IntRect& rect) { m_opaqueContentRect = rect; }
 
 private:
     explicit BlendStateCheckLayer(int id)
@@ -540,7 +548,9 @@
         , m_blend(false)
         , m_hasRenderSurface(false)
         , m_quadsAppended(false)
-        , m_opaqueColor(true)
+        , m_opaqueContents(false)
+        , m_quadRect(5, 5, 5, 5)
+        , m_quadVisibleRect(5, 5, 5, 5)
     {
         setAnchorPoint(FloatPoint(0, 0));
         setBounds(IntSize(10, 10));
@@ -550,7 +560,10 @@
     bool m_blend;
     bool m_hasRenderSurface;
     bool m_quadsAppended;
-    bool m_opaqueColor;
+    bool m_opaqueContents;
+    IntRect m_quadRect;
+    IntRect m_opaqueContentRect;
+    IntRect m_quadVisibleRect;
 };
 
 // https://bugs.webkit.org/show_bug.cgi?id=75783
@@ -573,28 +586,28 @@
 
     // Opaque layer, drawn without blending.
     layer1->setOpaque(true);
-    layer1->setOpaqueColor(true);
+    layer1->setOpaqueContents(true);
     layer1->setExpectation(false, false);
     m_hostImpl->drawLayers();
     EXPECT_TRUE(layer1->quadsAppended());
 
-    // Layer with translucent content, but solid color is opaque, so drawn without blending.
+    // Layer with translucent content, but opaque content, so drawn without blending.
     layer1->setOpaque(false);
-    layer1->setOpaqueColor(true);
+    layer1->setOpaqueContents(true);
     layer1->setExpectation(false, false);
     m_hostImpl->drawLayers();
     EXPECT_TRUE(layer1->quadsAppended());
 
     // Layer with translucent content and painting, so drawn with blending.
     layer1->setOpaque(false);
-    layer1->setOpaqueColor(false);
+    layer1->setOpaqueContents(false);
     layer1->setExpectation(true, false);
     m_hostImpl->drawLayers();
     EXPECT_TRUE(layer1->quadsAppended());
 
     // Layer with translucent opacity, drawn with blending.
     layer1->setOpaque(true);
-    layer1->setOpaqueColor(true);
+    layer1->setOpaqueContents(true);
     layer1->setOpacity(0.5);
     layer1->setExpectation(true, false);
     m_hostImpl->drawLayers();
@@ -602,7 +615,7 @@
 
     // Layer with translucent opacity and painting, drawn with blending.
     layer1->setOpaque(true);
-    layer1->setOpaqueColor(false);
+    layer1->setOpaqueContents(false);
     layer1->setOpacity(0.5);
     layer1->setExpectation(true, false);
     m_hostImpl->drawLayers();
@@ -613,11 +626,11 @@
 
     // 2 opaque layers, drawn without blending.
     layer1->setOpaque(true);
-    layer1->setOpaqueColor(true);
+    layer1->setOpaqueContents(true);
     layer1->setOpacity(1);
     layer1->setExpectation(false, false);
     layer2->setOpaque(true);
-    layer2->setOpaqueColor(true);
+    layer2->setOpaqueContents(true);
     layer2->setOpacity(1);
     layer2->setExpectation(false, false);
     m_hostImpl->drawLayers();
@@ -627,7 +640,7 @@
     // Parent layer with translucent content, drawn with blending.
     // Child layer with opaque content, drawn without blending.
     layer1->setOpaque(false);
-    layer1->setOpaqueColor(false);
+    layer1->setOpaqueContents(false);
     layer1->setExpectation(true, false);
     layer2->setExpectation(false, false);
     m_hostImpl->drawLayers();
@@ -637,7 +650,7 @@
     // Parent layer with translucent content but opaque painting, drawn without blending.
     // Child layer with opaque content, drawn without blending.
     layer1->setOpaque(false);
-    layer1->setOpaqueColor(true);
+    layer1->setOpaqueContents(true);
     layer1->setExpectation(false, false);
     layer2->setExpectation(false, false);
     m_hostImpl->drawLayers();
@@ -650,7 +663,7 @@
     // Child layer with opaque content, drawn without blending (parent surface
     // carries the inherited opacity).
     layer1->setOpaque(true);
-    layer1->setOpaqueColor(true);
+    layer1->setOpaqueContents(true);
     layer1->setOpacity(0.5);
     layer1->setExpectation(false, true);
     layer2->setExpectation(false, false);
@@ -661,11 +674,11 @@
     // Draw again, but with child non-opaque, to make sure
     // layer1 not culled.
     layer1->setOpaque(true);
-    layer1->setOpaqueColor(true);
+    layer1->setOpaqueContents(true);
     layer1->setOpacity(1);
     layer1->setExpectation(false, false);
     layer2->setOpaque(true);
-    layer2->setOpaqueColor(true);
+    layer2->setOpaqueContents(true);
     layer2->setOpacity(0.5);
     layer2->setExpectation(true, false);
     m_hostImpl->drawLayers();
@@ -677,7 +690,7 @@
     layer1->setOpacity(1);
     layer1->setExpectation(false, false);
     layer2->setOpaque(false);
-    layer2->setOpaqueColor(false);
+    layer2->setOpaqueContents(false);
     layer2->setOpacity(1);
     layer2->setExpectation(true, false);
     m_hostImpl->drawLayers();
@@ -689,12 +702,53 @@
     layer1->setOpacity(1);
     layer1->setExpectation(false, false);
     layer2->setOpaque(false);
-    layer2->setOpaqueColor(true);
+    layer2->setOpaqueContents(true);
     layer2->setOpacity(1);
     layer2->setExpectation(false, false);
     m_hostImpl->drawLayers();
     EXPECT_TRUE(layer1->quadsAppended());
     EXPECT_TRUE(layer2->quadsAppended());
+
+    // Layer with partially opaque contents, drawn with blending.
+    layer1->setOpaque(false);
+    layer1->setQuadRect(IntRect(5, 5, 5, 5));
+    layer1->setQuadVisibleRect(IntRect(5, 5, 5, 5));
+    layer1->setOpaqueContents(false);
+    layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5));
+    layer1->setExpectation(true, false);
+    m_hostImpl->drawLayers();
+    EXPECT_TRUE(layer1->quadsAppended());
+
+    // Layer with partially opaque contents partially culled, drawn with blending.
+    layer1->setOpaque(false);
+    layer1->setQuadRect(IntRect(5, 5, 5, 5));
+    layer1->setQuadVisibleRect(IntRect(5, 5, 5, 2));
+    layer1->setOpaqueContents(false);
+    layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5));
+    layer1->setExpectation(true, false);
+    m_hostImpl->drawLayers();
+    EXPECT_TRUE(layer1->quadsAppended());
+
+    // Layer with partially opaque contents culled, drawn with blending.
+    layer1->setOpaque(false);
+    layer1->setQuadRect(IntRect(5, 5, 5, 5));
+    layer1->setQuadVisibleRect(IntRect(7, 5, 3, 5));
+    layer1->setOpaqueContents(false);
+    layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5));
+    layer1->setExpectation(true, false);
+    m_hostImpl->drawLayers();
+    EXPECT_TRUE(layer1->quadsAppended());
+
+    // Layer with partially opaque contents and translucent contents culled, drawn without blending.
+    layer1->setOpaque(false);
+    layer1->setQuadRect(IntRect(5, 5, 5, 5));
+    layer1->setQuadVisibleRect(IntRect(5, 5, 2, 5));
+    layer1->setOpaqueContents(false);
+    layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5));
+    layer1->setExpectation(false, false);
+    m_hostImpl->drawLayers();
+    EXPECT_TRUE(layer1->quadsAppended());
+
 }
 
 class ReshapeTrackerContext: public FakeWebGraphicsContext3D {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to