From dbcc0fb54c045336f3fd8382a5d32f11d15712e0 Mon Sep 17 00:00:00 2001 From: "vangelis@chromium.org" Date: Wed, 25 Jan 2012 03:28:08 +0000 Subject: [PATCH] Source/WebCore: [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): 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 | 18 ++++++ .../graphics/chromium/TiledLayerChromium.cpp | 2 +- .../graphics/chromium/TiledLayerChromium.h | 2 + Source/WebKit/chromium/ChangeLog | 24 ++++++++ Source/WebKit/chromium/WebKit.gypi | 1 + .../chromium/tests/FakeCCLayerTreeHostClient.h | 54 ++++++++++++++++++ Source/WebKit/chromium/tests/LayerChromiumTest.cpp | 15 +---- .../chromium/tests/TiledLayerChromiumTest.cpp | 65 ++++++++++++++++++++++ 8 files changed, 166 insertions(+), 15 deletions(-) create mode 100755 Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 62743b6..02457cc 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2012-01-24 Vangelis Kokkevis + + [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 Invalidate r105697, r105766, r105809 and r105805 diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp index 30acf72..6385d68 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp @@ -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 diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h index c12e91a..1f9f695 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h @@ -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; diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 11dd478..ea0de0f 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,27 @@ +2012-01-24 Vangelis Kokkevis + + 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 Unreviewed: removing WebWorker.h again after r105684. diff --git a/Source/WebKit/chromium/WebKit.gypi b/Source/WebKit/chromium/WebKit.gypi index 588a2c7..7025990 100644 --- a/Source/WebKit/chromium/WebKit.gypi +++ b/Source/WebKit/chromium/WebKit.gypi @@ -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 index 0000000..b93ab1d --- /dev/null +++ b/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h @@ -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 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 diff --git a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp index 753816b..43083a1 100644 --- a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp @@ -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 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() diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp index 409d927..b850f82 100644 --- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp @@ -27,8 +27,10 @@ #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::create(&fakeCCLayerTreeHostClient, CCSettings()); + + // Create two 300 x 300 tiled layers. + IntSize contentBounds(300, 300); + IntRect contentRect(IntPoint::zero(), contentBounds); + + RefPtr rootLayer = adoptRef(new FakeTiledLayerChromium(ccLayerTreeHost->contentsTextureManager())); + RefPtr 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 -- 2.7.4