[chromium] Use opaque contents for paint culling
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 19:51:20 +0000 (19:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 19:51:20 +0000 (19:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81676

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

Source/WebCore:

UnitTest: CCLayerTreeHostTestContentLayerOcclusion

* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::paintLayerContents):

Source/WebKit/chromium:

* tests/CCLayerTreeHostTest.cpp:
(WTF::TestLayerChromium::opaqueContentsRegion):
(WTF::TestLayerChromium::setOpaqueContentsRect):
(TestLayerChromium):
(CCLayerTreeHostTestContentLayerOcclusion):
(WTF::CCLayerTreeHostTestContentLayerOcclusion::CCLayerTreeHostTestContentLayerOcclusion):
(WTF::CCLayerTreeHostTestContentLayerOcclusion::beginTest):
(WTF::CCLayerTreeHostTestContentLayerOcclusion::afterTest):
(WTF):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

index 7dc4527f8e0a61317010f82f256f408061749012..ee567e01cc7157d499c10d27574e4e83bf9ee3ac 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-20  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Use opaque contents for paint culling
+        https://bugs.webkit.org/show_bug.cgi?id=81676
+
+        Reviewed by Adrienne Walker.
+
+        UnitTest: CCLayerTreeHostTestContentLayerOcclusion
+
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::paintLayerContents):
+
 2012-03-20  Dan Bernstein  <mitz@apple.com>
 
         Build fix after r111419.
index d1fd89efec4eaf240dbc88381a8548ec4cd41b7b..a142be30992a9e78464379740241a5fea4c56258 100644 (file)
@@ -548,7 +548,7 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList
     typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
 
     CCOcclusionTracker occlusionTracker(IntRect(IntPoint(), viewportSize()));
-    occlusionTracker.setUsePaintTracking(false); // FIXME: Remove this to turn on paint tracking for paint culling
+    occlusionTracker.setUsePaintTracking(true); // FIXME: Remove this after m19 branch.
 
     CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList);
     for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) {
index be4ebba4378438fd60a822c255f1885a5e487a50..b2531c7271fc9235fb91ecf3e97d29e21726db76 100644 (file)
@@ -1,3 +1,20 @@
+2012-03-20  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Use opaque contents for paint culling
+        https://bugs.webkit.org/show_bug.cgi?id=81676
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::TestLayerChromium::opaqueContentsRegion):
+        (WTF::TestLayerChromium::setOpaqueContentsRect):
+        (TestLayerChromium):
+        (CCLayerTreeHostTestContentLayerOcclusion):
+        (WTF::CCLayerTreeHostTestContentLayerOcclusion::CCLayerTreeHostTestContentLayerOcclusion):
+        (WTF::CCLayerTreeHostTestContentLayerOcclusion::beginTest):
+        (WTF::CCLayerTreeHostTestContentLayerOcclusion::afterTest):
+        (WTF):
+
 2012-03-20  W. James MacLean  <wjmaclean@chromium.org>
 
         [chromium] Tune fling physics curve. [Not for review yet]
index 3fda2c9ee7acaf0bee367deb5e6b1d93a8d1cb56..1c342dbe9f9fe49edd8c6ee33f1fadd14166fdd1 100644 (file)
@@ -1664,6 +1664,9 @@ public:
 
     virtual bool drawsContent() const { return true; }
 
+    virtual Region opaqueContentsRegion() const { return intersection(m_opaqueContentsRect, visibleLayerRect()); }
+    void setOpaqueContentsRect(const IntRect& opaqueContentsRect) { m_opaqueContentsRect = opaqueContentsRect; }
+
     const Region& occludedScreenSpace() const { return m_occludedScreenSpace; }
     void clearOccludedScreenSpace() { m_occludedScreenSpace = Region(); }
 
@@ -1671,6 +1674,7 @@ private:
     TestLayerChromium() : LayerChromium() { }
 
     Region m_occludedScreenSpace;
+    IntRect m_opaqueContentsRect;
 };
 
 static void setLayerPropertiesForTesting(TestLayerChromium* layer, LayerChromium* parent, const TransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque)
@@ -1887,6 +1891,46 @@ public:
 
 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerOcclusion)
 
+class CCLayerTreeHostTestContentLayerOcclusion : public CCLayerTreeHostTest {
+public:
+    CCLayerTreeHostTestContentLayerOcclusion() { }
+
+    virtual void beginTest()
+    {
+        RefPtr<TestLayerChromium> rootLayer = TestLayerChromium::create();
+        RefPtr<TestLayerChromium> child = TestLayerChromium::create();
+
+        TransformationMatrix identityMatrix;
+        setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);
+        setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(50, 50), false);
+
+        child->setOpaqueContentsRect(IntRect(10, 10, 20, 20));
+
+        m_layerTreeHost->setRootLayer(rootLayer);
+        m_layerTreeHost->setViewportSize(rootLayer->bounds());
+        m_layerTreeHost->updateLayers();
+        m_layerTreeHost->commitComplete();
+
+        EXPECT_EQ_RECT(IntRect(), child->occludedScreenSpace().bounds());
+        EXPECT_EQ(0u, child->occludedScreenSpace().rects().size());
+
+        EXPECT_EQ_RECT(IntRect(40, 40, 20, 20), rootLayer->occludedScreenSpace().bounds());
+        EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());
+
+        // Kill the layerTreeHost immediately.
+        m_layerTreeHost->setRootLayer(0);
+        m_layerTreeHost.clear();
+
+        endTest();
+    }
+
+    virtual void afterTest()
+    {
+    }
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestContentLayerOcclusion)
+
 class CCLayerTreeHostTestLayerOcclusionWithFilters : public CCLayerTreeHostTest {
 public:
     CCLayerTreeHostTestLayerOcclusionWithFilters() { }