diff options
Diffstat (limited to 'Source/WebKit/chromium/tests/LayerChromiumTest.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/LayerChromiumTest.cpp | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp index d8858cc12..a93eac7fa 100644 --- a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp @@ -26,13 +26,14 @@ #include "LayerChromium.h" -#include "cc/CCLayerTreeHost.h" #include "CCLayerTreeTestCommon.h" #include "FakeCCLayerTreeHostClient.h" #include "LayerPainterChromium.h" #include "NonCompositedContentHost.h" #include "WebCompositor.h" +#include "cc/CCLayerImpl.h" #include "cc/CCLayerTreeHost.h" +#include "cc/CCSingleThreadProxy.h" #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -77,7 +78,7 @@ protected: { // Initialize without threading support. WebKit::WebCompositor::initialize(0); - m_layerTreeHost = adoptRef(new MockCCLayerTreeHost); + m_layerTreeHost = adoptPtr(new MockCCLayerTreeHost); } virtual void TearDown() @@ -145,7 +146,7 @@ protected: verifyTestTreeInitialState(); } - RefPtr<MockCCLayerTreeHost> m_layerTreeHost; + OwnPtr<MockCCLayerTreeHost> m_layerTreeHost; RefPtr<LayerChromium> m_parent, m_child1, m_child2, m_child3, m_grandChild1, m_grandChild2, m_grandChild3; }; @@ -504,8 +505,7 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) // All properties need to be set to new values in order for setNeedsCommit to be called. EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPoint(FloatPoint(1.23f, 4.56f))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPointZ(0.7f)); - EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBackgroundColor(Color(0.4f, 0.4f, 0.4f))); - EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBackgroundCoversViewport(true)); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBackgroundColor(Color(0.4f, 0.4f, 0.4f, 1.0f))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMasksToBounds(true)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMaskLayer(dummyLayer.get())); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpacity(0.5f)); @@ -521,6 +521,7 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer")); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDrawCheckerboardForMissingTiles(!testLayer->drawCheckerboardForMissingTiles())); // The above tests should not have caused a change to the needsDisplay flag. EXPECT_FALSE(testLayer->needsDisplay()); @@ -530,6 +531,29 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) EXPECT_TRUE(testLayer->needsDisplay()); } +TEST_F(LayerChromiumTest, verifyPushPropertiesAccumulatesUpdateRect) +{ + DebugScopedSetImplThread setImplThread; + + RefPtr<LayerChromium> testLayer = LayerChromium::create(); + OwnPtr<CCLayerImpl> implLayer = CCLayerImpl::create(1); + + testLayer->setNeedsDisplayRect(FloatRect(FloatPoint::zero(), FloatSize(5, 5))); + testLayer->pushPropertiesTo(implLayer.get()); + EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(5, 5)), implLayer->updateRect()); + + // The CCLayerImpl's updateRect should be accumulated here, since we did not do anything to clear it. + testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5))); + testLayer->pushPropertiesTo(implLayer.get()); + EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(15, 15)), implLayer->updateRect()); + + // If we do clear the CCLayerImpl side, then the next updateRect should be fresh without accumulation. + implLayer->resetAllChangeTrackingForSubtree(); + testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5))); + testLayer->pushPropertiesTo(implLayer.get()); + EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)), implLayer->updateRect()); +} + class LayerChromiumWithContentScaling : public LayerChromium { public: explicit LayerChromiumWithContentScaling() @@ -537,12 +561,12 @@ public: { } - virtual bool needsContentsScale() const + virtual bool needsContentsScale() const OVERRIDE { return true; } - virtual void setNeedsDisplayRect(const FloatRect& dirtyRect) + virtual void setNeedsDisplayRect(const FloatRect& dirtyRect) OVERRIDE { m_lastNeedsDisplayRect = dirtyRect; LayerChromium::setNeedsDisplayRect(dirtyRect); @@ -577,9 +601,9 @@ TEST_F(LayerChromiumTest, checkContentsScaleChangeTriggersNeedsDisplay) class FakeCCLayerTreeHost : public CCLayerTreeHost { public: - static PassRefPtr<FakeCCLayerTreeHost> create() + static PassOwnPtr<FakeCCLayerTreeHost> create() { - RefPtr<FakeCCLayerTreeHost> host = adoptRef(new FakeCCLayerTreeHost); + OwnPtr<FakeCCLayerTreeHost> host(adoptPtr(new FakeCCLayerTreeHost)); // The initialize call will fail, since our client doesn't provide a valid GraphicsContext3D, but it doesn't matter in the tests that use this fake so ignore the return value. host->initialize(); return host.release(); @@ -626,7 +650,7 @@ TEST(LayerChromiumLayerTreeHostTest, enteringTree) assertLayerTreeHostMatchesForSubtree(parent.get(), 0); - RefPtr<FakeCCLayerTreeHost> layerTreeHost = FakeCCLayerTreeHost::create(); + OwnPtr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create()); // Setting the root layer should set the host pointer for all layers in the tree. layerTreeHost->setRootLayer(parent.get()); @@ -645,7 +669,7 @@ TEST(LayerChromiumLayerTreeHostTest, addingLayerSubtree) { WebKit::WebCompositor::initialize(0); RefPtr<LayerChromium> parent = LayerChromium::create(); - RefPtr<FakeCCLayerTreeHost> layerTreeHost = FakeCCLayerTreeHost::create(); + OwnPtr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create()); layerTreeHost->setRootLayer(parent.get()); @@ -687,14 +711,14 @@ TEST(LayerChromiumLayerTreeHostTest, changeHost) child->setReplicaLayer(replica.get()); replica->setMaskLayer(mask.get()); - RefPtr<FakeCCLayerTreeHost> firstLayerTreeHost = FakeCCLayerTreeHost::create(); + OwnPtr<FakeCCLayerTreeHost> firstLayerTreeHost(FakeCCLayerTreeHost::create()); firstLayerTreeHost->setRootLayer(parent.get()); assertLayerTreeHostMatchesForSubtree(parent.get(), firstLayerTreeHost.get()); // Now re-root the tree to a new host (simulating what we do on a context lost event). // This should update the host pointers for all layers in the tree. - RefPtr<FakeCCLayerTreeHost> secondLayerTreeHost = FakeCCLayerTreeHost::create(); + OwnPtr<FakeCCLayerTreeHost> secondLayerTreeHost(FakeCCLayerTreeHost::create()); secondLayerTreeHost->setRootLayer(parent.get()); assertLayerTreeHostMatchesForSubtree(parent.get(), secondLayerTreeHost.get()); @@ -719,13 +743,13 @@ TEST(LayerChromiumLayerTreeHostTest, changeHostInSubtree) secondChild->addChild(secondGrandChild); firstParent->addChild(secondChild); - RefPtr<FakeCCLayerTreeHost> firstLayerTreeHost = FakeCCLayerTreeHost::create(); + OwnPtr<FakeCCLayerTreeHost> firstLayerTreeHost(FakeCCLayerTreeHost::create()); firstLayerTreeHost->setRootLayer(firstParent.get()); assertLayerTreeHostMatchesForSubtree(firstParent.get(), firstLayerTreeHost.get()); // Now reparent the subtree starting at secondChild to a layer in a different tree. - RefPtr<FakeCCLayerTreeHost> secondLayerTreeHost = FakeCCLayerTreeHost::create(); + OwnPtr<FakeCCLayerTreeHost> secondLayerTreeHost(FakeCCLayerTreeHost::create()); secondLayerTreeHost->setRootLayer(secondParent.get()); secondParent->addChild(secondChild); @@ -758,7 +782,7 @@ TEST(LayerChromiumLayerTreeHostTest, replaceMaskAndReplicaLayer) mask->addChild(maskChild); replica->addChild(replicaChild); - RefPtr<FakeCCLayerTreeHost> layerTreeHost = FakeCCLayerTreeHost::create(); + OwnPtr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create()); layerTreeHost->setRootLayer(parent.get()); assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); |