Title: [119725] trunk/Source
Revision
119725
Author
[email protected]
Date
2012-06-07 08:09:22 -0700 (Thu, 07 Jun 2012)

Log Message

[chromium] In each composited frame, didDraw() should only be called on layers for which willDraw() was called
https://bugs.webkit.org/show_bug.cgi?id=88469

Reviewed by James Robinson.

Source/WebCore:

Unit test: CCLayerTreeHostImplTest.didDrawNotCalledOnScissoredLayer

* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::shouldDrawLayer):
(WebCore):
(WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
(WebCore::CCLayerTreeHostImpl::didDrawAllLayers):

Source/WebKit/chromium:

* tests/CCLayerTreeHostImplTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (119724 => 119725)


--- trunk/Source/WebCore/ChangeLog	2012-06-07 14:54:57 UTC (rev 119724)
+++ trunk/Source/WebCore/ChangeLog	2012-06-07 15:09:22 UTC (rev 119725)
@@ -1,3 +1,18 @@
+2012-06-06  Dana Jansens  <[email protected]>
+
+        [chromium] In each composited frame, didDraw() should only be called on layers for which willDraw() was called
+        https://bugs.webkit.org/show_bug.cgi?id=88469
+
+        Reviewed by James Robinson.
+
+        Unit test: CCLayerTreeHostImplTest.didDrawNotCalledOnScissoredLayer
+
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::shouldDrawLayer):
+        (WebCore):
+        (WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
+        (WebCore::CCLayerTreeHostImpl::didDrawAllLayers):
+
 2012-06-07  Alexei Filippov  <[email protected]>
 
         Web Inspector: sorting of object fields is broken in heap profiler

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-06-07 14:54:57 UTC (rev 119724)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-06-07 15:09:22 UTC (rev 119725)
@@ -261,6 +261,11 @@
     }
 }
 
+static inline bool shouldDrawLayer(CCLayerImpl* layer)
+{
+    return !layer->visibleLayerRect().isEmpty() && !layer->scissorRect().isEmpty();
+}
+
 bool CCLayerTreeHostImpl::calculateRenderPasses(CCRenderPassList& passes, CCLayerList& renderSurfaceLayerList)
 {
     ASSERT(passes.isEmpty());
@@ -305,7 +310,7 @@
         if (it.representsContributingRenderSurface() && !it->renderSurface()->scissorRect().isEmpty()) {
             CCRenderPass* contributingRenderPass = surfacePassMap.get(it->renderSurface());
             pass->appendQuadsForRenderSurfaceLayer(*it, contributingRenderPass, &occlusionTracker);
-        } else if (it.representsItself() && !it->visibleLayerRect().isEmpty() && !it->scissorRect().isEmpty()) {
+        } else if (it.representsItself() && shouldDrawLayer(*it)) {
             it->willDraw(m_layerRenderer.get(), context());
             pass->appendQuadsForLayer(*it, &occlusionTracker, hadMissingTiles);
         }
@@ -435,7 +440,7 @@
 
     CCLayerIteratorType end = CCLayerIteratorType::end(&frame.renderSurfaceLayerList);
     for (CCLayerIteratorType it = CCLayerIteratorType::begin(&frame.renderSurfaceLayerList); it != end; ++it) {
-        if (it.representsItself() && !it->visibleLayerRect().isEmpty())
+        if (it.representsItself() && shouldDrawLayer(*it))
             it->didDraw();
     }
 }

Modified: trunk/Source/WebKit/chromium/ChangeLog (119724 => 119725)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-06-07 14:54:57 UTC (rev 119724)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-06-07 15:09:22 UTC (rev 119725)
@@ -1,3 +1,12 @@
+2012-06-06  Dana Jansens  <[email protected]>
+
+        [chromium] In each composited frame, didDraw() should only be called on layers for which willDraw() was called
+        https://bugs.webkit.org/show_bug.cgi?id=88469
+
+        Reviewed by James Robinson.
+
+        * tests/CCLayerTreeHostImplTest.cpp:
+
 2012-06-07  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r119694.

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (119724 => 119725)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2012-06-07 14:54:57 UTC (rev 119724)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp	2012-06-07 15:09:22 UTC (rev 119725)
@@ -454,6 +454,12 @@
     bool didDrawCalled() const { return m_didDrawCalled; }
     bool willDrawCalled() const { return m_willDrawCalled; }
 
+    void clearDidDrawCheck()
+    {
+        m_didDrawCalled = false;
+        m_willDrawCalled = false;
+    }
+
 protected:
     explicit DidDrawCheckLayer(int id)
         : CCTiledLayerImpl(id)
@@ -1411,6 +1417,59 @@
     }
 }
 
+TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnScissoredLayer)
+{
+    CCSettings settings;
+    settings.partialSwapEnabled = true;
+
+    RefPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new PartialSwapContext()), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
+    myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
+    myHostImpl->setViewportSize(IntSize(10, 10));
+
+    myHostImpl->setRootLayer(DidDrawCheckLayer::create(1));
+    DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(myHostImpl->rootLayer());
+    root->setMasksToBounds(true);
+
+    root->addChild(DidDrawCheckLayer::create(2));
+    DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[0].get());
+
+    CCLayerTreeHostImpl::FrameData frame;
+
+    EXPECT_FALSE(root->willDrawCalled());
+    EXPECT_FALSE(root->didDrawCalled());
+    EXPECT_FALSE(layer->willDrawCalled());
+    EXPECT_FALSE(layer->didDrawCalled());
+
+    // We should draw everything the first frame.
+    EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
+    myHostImpl->drawLayers(frame);
+    myHostImpl->didDrawAllLayers(frame);
+
+    EXPECT_TRUE(root->willDrawCalled());
+    EXPECT_TRUE(root->didDrawCalled());
+    EXPECT_TRUE(layer->willDrawCalled());
+    EXPECT_TRUE(layer->didDrawCalled());
+
+    root->clearDidDrawCheck();
+    layer->clearDidDrawCheck();
+
+    EXPECT_FALSE(root->willDrawCalled());
+    EXPECT_FALSE(root->didDrawCalled());
+    EXPECT_FALSE(layer->willDrawCalled());
+    EXPECT_FALSE(layer->didDrawCalled());
+
+    // Drawing again, we should scissor out everything since there is no damage.
+    EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
+    myHostImpl->drawLayers(frame);
+    myHostImpl->didDrawAllLayers(frame);
+
+    EXPECT_FALSE(root->willDrawCalled());
+    EXPECT_FALSE(root->didDrawCalled());
+    EXPECT_FALSE(layer->willDrawCalled());
+    EXPECT_FALSE(layer->didDrawCalled());
+}
+
 // Make sure that context lost notifications are propagated through the tree.
 class ContextLostNotificationCheckLayer : public CCLayerImpl {
 public:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to