[chromium] Quads that become fully opaque after culling should not use blending
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 08:39:41 +0000 (08:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 08:39:41 +0000 (08:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81235

Patch by Dana Jansens <danakj@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):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCDrawQuad.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp

index 25f5760b1a1625d2c567872bc54a26cb990a2723..87dc08f7ba7f6febd2d66231770fd3f42649a2f1 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-16  Dana Jansens  <danakj@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  <xji@chromium.org>
 
         Using ICU break iterator to simplify visual word movement implementation.
index 1738b4b0e75e7cad95d4cb2f87bc79f5589c02a0..b163393d56c5b1f5851e69d03dc41863a1519a7f 100644 (file)
@@ -51,9 +51,9 @@ public:
     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
index 30acf2fac731a9eb0307a27d25ac09ef6255a54e..7ce6542194e2b1964767adc6e6d3e791a4067c2d 100644 (file)
@@ -1,3 +1,20 @@
+2012-03-16  Dana Jansens  <danakj@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  <hans@chromium.org>
 
         Speech JavaScript API: SpeechRecognition, Controller and Client
index 671ffed9eb451b290739898e0c3fc3111b285f32..a192ba557bf0ea16c21e4c04242cb25d090a1763 100644 (file)
@@ -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 @@ public:
     {
         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 @@ public:
 
     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 @@ private:
         , 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 @@ private:
     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 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
 
     // 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 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
 
     // 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 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
 
     // 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 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
     // 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 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
     // 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 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
     // 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 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
     // 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 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
     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 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
     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 {