Source/WebCore: [chromium] Ignore m_skipsDraw in TiledLayerChromium::drawsContent()
authorvangelis@chromium.org <vangelis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jan 2012 03:28:08 +0000 (03:28 +0000)
committervangelis@chromium.org <vangelis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jan 2012 03:28:08 +0000 (03:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76735

This is to add skipped layers to their RenderSurface's layer list so that they
are considered in the next update. Without this change, m_skipsDraw = false sticks
with the layer for the remainder of its lifetime.

Reviewed by James Robinson.

Tests: Unit test (TiledLayerChromiumTest.cpp)

* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::drawsContent):
* platform/graphics/chromium/TiledLayerChromium.h:
(WebCore::TiledLayerChromium::skipsDraw):

Source/WebKit/chromium: Adding a test to verify that m_skipsDraw gets reset between frames for
tiled layers.
https://bugs.webkit.org/show_bug.cgi?id=76735

Reviewed by James Robinson.

* WebKit.gypi:
* tests/FakeCCLayerTreeHostClient.h: Added.
(WebCore::FakeCCLayerTreeHostClient::updateAnimations):
(WebCore::FakeCCLayerTreeHostClient::layout):
(WebCore::FakeCCLayerTreeHostClient::applyScrollAndScale):
(WebCore::FakeCCLayerTreeHostClient::createLayerTreeHostContext3D):
(WebCore::FakeCCLayerTreeHostClient::didRecreateGraphicsContext):
(WebCore::FakeCCLayerTreeHostClient::didCommitAndDrawFrame):
(WebCore::FakeCCLayerTreeHostClient::didCompleteSwapBuffers):
(WebCore::FakeCCLayerTreeHostClient::scheduleComposite):
* tests/LayerChromiumTest.cpp:
* tests/TiledLayerChromiumTest.cpp:
(WTF::FakeTiledLayerChromium::skipsDraw):
(WTF::FakeTiledLayerChromium::paintContentsIfDirty):
(WTF::TEST):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gypi
Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h [new file with mode: 0755]
Source/WebKit/chromium/tests/LayerChromiumTest.cpp
Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

index 62743b6..02457cc 100644 (file)
@@ -1,3 +1,21 @@
+2012-01-24  Vangelis Kokkevis  <vangelis@chromium.org>
+
+        [chromium] Ignore m_skipsDraw in TiledLayerChromium::drawsContent()
+        https://bugs.webkit.org/show_bug.cgi?id=76735
+
+        This is to add skipped layers to their RenderSurface's layer list so that they
+        are considered in the next update. Without this change, m_skipsDraw = false sticks
+        with the layer for the remainder of its lifetime.
+
+        Reviewed by James Robinson.
+
+        Tests: Unit test (TiledLayerChromiumTest.cpp)
+
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::drawsContent):
+        * platform/graphics/chromium/TiledLayerChromium.h:
+        (WebCore::TiledLayerChromium::skipsDraw):
+
 2012-01-24  Kentaro Hara  <haraken@chromium.org>
 
         Invalidate r105697, r105766, r105809 and r105805
index 30acf72..6385d68 100644 (file)
@@ -160,7 +160,7 @@ bool TiledLayerChromium::drawsContent() const
     if (m_tilingOption == NeverTile && m_tiler->numTiles() > 1)
         return false;
 
-    return !m_skipsDraw;
+    return true;
 }
 
 bool TiledLayerChromium::needsContentsScale() const
index c12e91a..1f9f695 100644 (file)
@@ -88,6 +88,8 @@ protected:
     // After preparing an update, returns true if more pre-painting is needed.
     bool needsIdlePaint(const IntRect& layerRect);
 
+    bool skipsDraw() const { return m_skipsDraw; }
+
     virtual void protectVisibleTileTextures();
 
     virtual TextureManager* textureManager() const;
index 11dd478..ea0de0f 100644 (file)
@@ -1,3 +1,27 @@
+2012-01-24  Vangelis Kokkevis  <vangelis@chromium.org>
+
+        Adding a test to verify that m_skipsDraw gets reset between frames for
+        tiled layers.
+        https://bugs.webkit.org/show_bug.cgi?id=76735
+
+        Reviewed by James Robinson.
+
+        * WebKit.gypi:
+        * tests/FakeCCLayerTreeHostClient.h: Added.
+        (WebCore::FakeCCLayerTreeHostClient::updateAnimations):
+        (WebCore::FakeCCLayerTreeHostClient::layout):
+        (WebCore::FakeCCLayerTreeHostClient::applyScrollAndScale):
+        (WebCore::FakeCCLayerTreeHostClient::createLayerTreeHostContext3D):
+        (WebCore::FakeCCLayerTreeHostClient::didRecreateGraphicsContext):
+        (WebCore::FakeCCLayerTreeHostClient::didCommitAndDrawFrame):
+        (WebCore::FakeCCLayerTreeHostClient::didCompleteSwapBuffers):
+        (WebCore::FakeCCLayerTreeHostClient::scheduleComposite):
+        * tests/LayerChromiumTest.cpp:
+        * tests/TiledLayerChromiumTest.cpp:
+        (WTF::FakeTiledLayerChromium::skipsDraw):
+        (WTF::FakeTiledLayerChromium::paintContentsIfDirty):
+        (WTF::TEST):
+
 2012-01-24  Dmitry Lomov  <dslomov@google.com>
 
         Unreviewed: removing WebWorker.h again after r105684.
index 588a2c7..7025990 100644 (file)
@@ -86,6 +86,7 @@
             'tests/CCTimerTest.cpp',
             'tests/CompositorFakeGraphicsContext3D.h',
             'tests/CompositorFakeWebGraphicsContext3D.h',
+            'tests/FakeCCLayerTreeHostClient.h',
             'tests/FakeGraphicsContext3DTest.cpp',
             'tests/FakeWebGraphicsContext3D.h',
             'tests/FloatQuadTest.cpp',
diff --git a/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h b/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h
new file mode 100755 (executable)
index 0000000..b93ab1d
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef FakeCCLayerTreeHostClient_h
+#define FakeCCLayerTreeHostClient_h
+
+#include "config.h"
+
+#include "cc/CCLayerTreeHost.h"
+#include "CompositorFakeGraphicsContext3D.h"
+
+namespace WebCore {
+
+class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient {
+public:
+    virtual void updateAnimations(double frameBeginTime) { }
+    virtual void layout() { }
+    virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { }
+    virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D()
+    {
+        GraphicsContext3D::Attributes attrs;
+        return createCompositorMockGraphicsContext3D(attrs);
+    }
+    virtual void didRecreateGraphicsContext(bool success) { }
+    virtual void didCommitAndDrawFrame() { }
+    virtual void didCompleteSwapBuffers() { }
+
+    // Used only in the single-threaded path.
+    virtual void scheduleComposite() { }
+};
+
+}
+#endif // FakeCCLayerTreeHostClient_h
\ No newline at end of file
index 753816b..43083a1 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "cc/CCLayerTreeHost.h"
 #include "CCLayerTreeTestCommon.h"
+#include "FakeCCLayerTreeHostClient.h"
 #include "LayerPainterChromium.h"
 #include "NonCompositedContentHost.h"
 #include "WebCompositor.h"
@@ -50,20 +51,6 @@ using ::testing::AnyNumber;
 
 namespace {
 
-class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient {
-public:
-    virtual void updateAnimations(double frameBeginTime) { }
-    virtual void layout() { }
-    virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { }
-    virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() { return 0; }
-    virtual void didRecreateGraphicsContext(bool success) { }
-    virtual void didCommitAndDrawFrame() { }
-    virtual void didCompleteSwapBuffers() { }
-
-    // Used only in the single-threaded path.
-    virtual void scheduleComposite() { }
-};
-
 class MockCCLayerTreeHost : public CCLayerTreeHost {
 public:
     MockCCLayerTreeHost()
index 409d927..b850f82 100644 (file)
 #include "TiledLayerChromium.h"
 
 #include "CCLayerTreeTestCommon.h"
+#include "FakeCCLayerTreeHostClient.h"
 #include "LayerTextureUpdater.h"
 #include "TextureManager.h"
+#include "WebCompositor.h"
 #include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread
 #include "cc/CCTextureUpdater.h"
 #include "cc/CCTiledLayerImpl.h"
@@ -128,10 +130,20 @@ public:
         return TiledLayerChromium::needsIdlePaint(rect);
     }
 
+    bool skipsDraw() const
+    {
+        return TiledLayerChromium::skipsDraw();
+    }
+
     FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpdater.get(); }
 
     virtual TextureManager* textureManager() const { return m_textureManager; }
 
+    virtual void paintContentsIfDirty()
+    {
+        prepareToUpdate(visibleLayerRect());
+    }
+
 private:
     virtual void createTextureUpdater(const CCLayerTreeHost*) { }
 
@@ -395,4 +407,57 @@ TEST(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled)
     EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect());
 }
 
+TEST(TiledLayerChromiumTest, skipsDrawGetsReset)
+{
+    // Initialize without threading support.
+    WebKit::WebCompositor::initialize(0);
+    FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient;
+    RefPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLayerTreeHostClient, CCSettings());
+
+    // Create two 300 x 300 tiled layers.
+    IntSize contentBounds(300, 300);
+    IntRect contentRect(IntPoint::zero(), contentBounds);
+
+    RefPtr<FakeTiledLayerChromium> rootLayer = adoptRef(new FakeTiledLayerChromium(ccLayerTreeHost->contentsTextureManager()));
+    RefPtr<FakeTiledLayerChromium> childLayer = adoptRef(new FakeTiledLayerChromium(ccLayerTreeHost->contentsTextureManager()));
+    rootLayer->addChild(childLayer);
+
+    rootLayer->setBounds(contentBounds);
+    rootLayer->setPosition(FloatPoint(150, 150));
+    childLayer->setBounds(contentBounds);
+    childLayer->setPosition(FloatPoint(150, 150));
+    rootLayer->invalidateRect(contentRect);
+    childLayer->invalidateRect(contentRect);
+
+    // We have enough memory for only one of the two layers.
+    int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel.
+
+    FakeTextureAllocator textureAllocator;
+    CCTextureUpdater updater(&textureAllocator);
+
+    ccLayerTreeHost->setRootLayer(rootLayer);
+    ccLayerTreeHost->setViewportSize(IntSize(300, 300));
+    ccLayerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(memoryLimit);
+    ccLayerTreeHost->updateLayers();
+    ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater);
+
+    // We'll skip the root layer.
+    EXPECT_TRUE(rootLayer->skipsDraw());
+    EXPECT_FALSE(childLayer->skipsDraw());
+
+    ccLayerTreeHost->commitComplete();
+
+    // Remove the child layer.
+    rootLayer->removeAllChildren();
+
+    // Need to set the max limit again as it gets overwritten by updateLayers().
+    ccLayerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(memoryLimit);
+    ccLayerTreeHost->updateLayers();
+    EXPECT_FALSE(rootLayer->skipsDraw());
+
+    ccLayerTreeHost->setRootLayer(0);
+    ccLayerTreeHost.clear();
+    WebKit::WebCompositor::shutdown();
+}
+
 } // namespace