Title: [108458] trunk/Source
Revision
108458
Author
[email protected]
Date
2012-02-22 00:54:57 -0800 (Wed, 22 Feb 2012)

Log Message

[chromium] Cull quads outside of the scissoring damage rect
https://bugs.webkit.org/show_bug.cgi?id=79181

Patch by Dana Jansens <[email protected]> on 2012-02-22
Reviewed by James Robinson.

Source/WebCore:

Quads outside of the partial swap cause us to execute GL operations
that actually use a fair amount of CPU time (enough to affect power
usage). Here we cull quads by only keeping their intersection
with the damage rect used for partial swap.

Unit test: CCQuadCuller.cpp

* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::optimizeRenderPasses):
* platform/graphics/chromium/cc/CCQuadCuller.cpp:
(WebCore::CCQuadCuller::cullOccludedQuads):
* platform/graphics/chromium/cc/CCQuadCuller.h:
(CCQuadCuller):
* platform/graphics/chromium/cc/CCRenderPass.cpp:
(WebCore::CCRenderPass::optimizeQuads):
* platform/graphics/chromium/cc/CCRenderPass.h:
(CCRenderPass):

Source/WebKit/chromium:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108457 => 108458)


--- trunk/Source/WebCore/ChangeLog	2012-02-22 08:49:02 UTC (rev 108457)
+++ trunk/Source/WebCore/ChangeLog	2012-02-22 08:54:57 UTC (rev 108458)
@@ -1,3 +1,28 @@
+2012-02-22  Dana Jansens  <[email protected]>
+
+        [chromium] Cull quads outside of the scissoring damage rect
+        https://bugs.webkit.org/show_bug.cgi?id=79181
+
+        Reviewed by James Robinson.
+
+        Quads outside of the partial swap cause us to execute GL operations
+        that actually use a fair amount of CPU time (enough to affect power
+        usage). Here we cull quads by only keeping their intersection
+        with the damage rect used for partial swap.
+
+        Unit test: CCQuadCuller.cpp
+
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::optimizeRenderPasses):
+        * platform/graphics/chromium/cc/CCQuadCuller.cpp:
+        (WebCore::CCQuadCuller::cullOccludedQuads):
+        * platform/graphics/chromium/cc/CCQuadCuller.h:
+        (CCQuadCuller):
+        * platform/graphics/chromium/cc/CCRenderPass.cpp:
+        (WebCore::CCRenderPass::optimizeQuads):
+        * platform/graphics/chromium/cc/CCRenderPass.h:
+        (CCRenderPass):
+
 2012-02-21  Dana Jansens  <[email protected]>
 
         [Chromium] New CCOcclusionTracker class with tests

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (108457 => 108458)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-02-22 08:49:02 UTC (rev 108457)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-02-22 08:54:57 UTC (rev 108458)
@@ -242,8 +242,12 @@
 
 void CCLayerTreeHostImpl::optimizeRenderPasses(CCRenderPassList& passes)
 {
-    for (unsigned i = 0; i < passes.size(); ++i)
-        passes[i]->optimizeQuads();
+    bool haveDamageRect = layerRendererCapabilities().usingPartialSwap;
+
+    for (unsigned i = 0; i < passes.size(); ++i) {
+        FloatRect damageRect = passes[i]->targetSurface()->damageTracker()->currentDamageRect();
+        passes[i]->optimizeQuads(haveDamageRect, damageRect);
+    }
 }
 
 IntSize CCLayerTreeHostImpl::contentSize() const

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.cpp (108457 => 108458)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.cpp	2012-02-22 08:49:02 UTC (rev 108457)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.cpp	2012-02-22 08:54:57 UTC (rev 108458)
@@ -75,7 +75,7 @@
     return rect;
 }
 
-void CCQuadCuller::cullOccludedQuads(CCQuadList& quadList)
+void CCQuadCuller::cullOccludedQuads(CCQuadList& quadList, bool haveDamageRect, const FloatRect& damageRect)
 {
     if (!quadList.size())
         return;
@@ -89,6 +89,8 @@
         CCDrawQuad* drawQuad = quadList[i].get();
 
         FloatRect floatTransformedRect = drawQuad->quadTransform().mapRect(FloatRect(drawQuad->quadRect()));
+        if (haveDamageRect)
+            floatTransformedRect.intersect(damageRect);
         // Inflate rect to be tested to stay conservative.
         IntRect transformedQuadRect(enclosingIntRect(floatTransformedRect));
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.h (108457 => 108458)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.h	2012-02-22 08:49:02 UTC (rev 108457)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.h	2012-02-22 08:54:57 UTC (rev 108458)
@@ -32,7 +32,7 @@
 
 class CCQuadCuller {
 public:
-    static void cullOccludedQuads(CCQuadList&);
+    static void cullOccludedQuads(CCQuadList&, bool haveDamageRect, const FloatRect& damageRect);
 
 private:
     // Make non-instantiable.

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp (108457 => 108458)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp	2012-02-22 08:49:02 UTC (rev 108457)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp	2012-02-22 08:54:57 UTC (rev 108458)
@@ -27,6 +27,7 @@
 
 #include "cc/CCRenderPass.h"
 
+#include "cc/CCDamageTracker.h"
 #include "cc/CCLayerImpl.h"
 #include "cc/CCQuadCuller.h"
 #include "cc/CCRenderSurfaceDrawQuad.h"
@@ -64,9 +65,9 @@
     m_sharedQuadStateList.append(sharedQuadState.release());
 }
 
-void CCRenderPass::optimizeQuads()
+void CCRenderPass::optimizeQuads(bool haveDamageRect, const FloatRect& damageRect)
 {
-    CCQuadCuller::cullOccludedQuads(m_quadList);
+    CCQuadCuller::cullOccludedQuads(m_quadList, haveDamageRect, damageRect);
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h (108457 => 108458)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h	2012-02-22 08:49:02 UTC (rev 108457)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.h	2012-02-22 08:54:57 UTC (rev 108458)
@@ -46,7 +46,7 @@
     void appendQuadsForLayer(CCLayerImpl*);
     void appendQuadsForRenderSurfaceLayer(CCLayerImpl*);
 
-    void optimizeQuads();
+    void optimizeQuads(bool haveDamageRect, const FloatRect& damageRect);
 
     const CCQuadList& quadList() const { return m_quadList; }
     CCRenderSurface* targetSurface() const { return m_targetSurface; }

Modified: trunk/Source/WebKit/chromium/ChangeLog (108457 => 108458)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-02-22 08:49:02 UTC (rev 108457)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-02-22 08:54:57 UTC (rev 108458)
@@ -1,3 +1,14 @@
+2012-02-22  Dana Jansens  <[email protected]>
+
+        [chromium] Cull quads outside of the scissoring damage rect
+        https://bugs.webkit.org/show_bug.cgi?id=79181
+
+        Reviewed by James Robinson.
+
+        * tests/CCQuadCullerTest.cpp:
+        (WebCore::TEST):
+        (WebCore):
+
 2012-02-21  Dana Jansens  <[email protected]>
 
         [Chromium] New CCOcclusionTracker class with tests

Modified: trunk/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp (108457 => 108458)


--- trunk/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp	2012-02-22 08:49:02 UTC (rev 108457)
+++ trunk/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp	2012-02-22 08:54:57 UTC (rev 108458)
@@ -79,7 +79,7 @@
 
     setQuads(rootState.get(), childState.get(), quadList);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 9u);
 }
 
@@ -92,7 +92,7 @@
 
     setQuads(rootState.get(), childState.get(), quadList);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 13u);
 }
 
@@ -105,7 +105,7 @@
 
     setQuads(rootState.get(), childState.get(), quadList);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 13u);
 }
 
@@ -120,7 +120,7 @@
 
     setQuads(rootState.get(), childState.get(), quadList);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 12u);
 
     IntRect quadVisibleRect1 = quadList[1].get()->quadVisibleRect();
@@ -158,7 +158,7 @@
     quadList.append(MakeTileQuad(childState.get(), IntRect(IntPoint(), IntSize(100, 100))));
 
     EXPECT_EQ(quadList.size(), 2u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 2u);
 }
 
@@ -181,7 +181,7 @@
     quadList.append(MakeTileQuad(childState.get(), IntRect(IntPoint(), IntSize(100, 100))));
 
     EXPECT_EQ(quadList.size(), 2u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 2u);
 }
 
@@ -196,7 +196,7 @@
 
     setQuads(rootState.get(), childState.get(), quadList);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 9u);
 }
 
@@ -212,7 +212,7 @@
 
     setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 12u);
 }
 
@@ -228,7 +228,7 @@
 
     setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 12u);
 }
 
@@ -244,7 +244,7 @@
 
     setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 13u);
 }
 
@@ -260,7 +260,7 @@
 
     setQuads(rootState.get(), childState.get(), quadList);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 13u);
 }
 
@@ -282,8 +282,61 @@
 
     setQuads(rootState.get(), childState.get(), quadList);
     EXPECT_EQ(quadList.size(), 13u);
-    CCQuadCuller::cullOccludedQuads(quadList);
+    CCQuadCuller::cullOccludedQuads(quadList, false, IntRect());
     EXPECT_EQ(quadList.size(), 12u);
 }
 
+TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverTile)
+{
+    DECLARE_AND_INITIALIZE_TEST_QUADS
+
+    OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
+    OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+
+    setQuads(rootState.get(), childState.get(), quadList);
+    EXPECT_EQ(quadList.size(), 13u);
+    CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(200, 100, 100, 100));
+    EXPECT_EQ(quadList.size(), 1u);
+}
+
+TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverCulledTile)
+{
+    DECLARE_AND_INITIALIZE_TEST_QUADS
+
+    OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
+    OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+
+    setQuads(rootState.get(), childState.get(), quadList);
+    EXPECT_EQ(quadList.size(), 13u);
+    CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(100, 100, 100, 100));
+    EXPECT_EQ(quadList.size(), 1u);
+}
+
+TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverPartialTiles)
+{
+    DECLARE_AND_INITIALIZE_TEST_QUADS
+
+    OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
+    OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+
+    setQuads(rootState.get(), childState.get(), quadList);
+    EXPECT_EQ(quadList.size(), 13u);
+    CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(50, 50, 200, 200));
+    EXPECT_EQ(quadList.size(), 9u);
+}
+
+TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverNoTiles)
+{
+    DECLARE_AND_INITIALIZE_TEST_QUADS
+
+    OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
+    OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+
+    setQuads(rootState.get(), childState.get(), quadList);
+    EXPECT_EQ(quadList.size(), 13u);
+    CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(500, 500, 100, 100));
+    EXPECT_EQ(quadList.size(), 0u);
+}
+
+
 } // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to