summaryrefslogtreecommitdiffstats
path: root/cc/layer_tree_host_unittest.cc
diff options
context:
space:
mode:
authorshawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-30 20:45:42 +0000
committershawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-30 20:45:42 +0000
commitecc12621a9594424a2ea7347b13e71888fd3c308 (patch)
tree95ce5ab9b1bb67056474b05cb005414749a30ea2 /cc/layer_tree_host_unittest.cc
parent45c5a2068dbd71f7e5510ed5a2ca7b89489585cb (diff)
downloadchromium_src-ecc12621a9594424a2ea7347b13e71888fd3c308.zip
chromium_src-ecc12621a9594424a2ea7347b13e71888fd3c308.tar.gz
chromium_src-ecc12621a9594424a2ea7347b13e71888fd3c308.tar.bz2
Remove root layer specialness in calculateDrawTransforms
This patch is step 2 in removing root layer specialness. The previous patch removed root layer specialness from code outside of CCLayerTreeHostCommon, this patch removes it from within CCLayerTreeHostCommon. One subtle semantics change occurs with this patch, that only affects tests and not real-world code: The root renderSurface now re-parents the root layer's drawTransform. In practice, the root layer's drawTransform is always an identity matrix, so it does not matter. BUG=154442 Review URL: https://chromiumcodereview.appspot.com/11276061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165000 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layer_tree_host_unittest.cc')
-rw-r--r--cc/layer_tree_host_unittest.cc102
1 files changed, 58 insertions, 44 deletions
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index 030ee97..f91cec6 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -651,7 +651,7 @@ public:
virtual void beginTest() OVERRIDE
{
- postAddAnimationToMainThread();
+ postAddAnimationToMainThread(m_layerTreeHost->rootLayer());
}
virtual void afterTest() OVERRIDE
@@ -694,7 +694,7 @@ public:
virtual void beginTest() OVERRIDE
{
- postAddAnimationToMainThread();
+ postAddAnimationToMainThread(m_layerTreeHost->rootLayer());
}
// Use willAnimateLayers to set visible false before the animation runs and
@@ -732,7 +732,7 @@ public:
virtual void beginTest() OVERRIDE
{
- postAddAnimationToMainThread();
+ postAddAnimationToMainThread(m_layerTreeHost->rootLayer());
}
virtual void animateLayers(LayerTreeHostImpl* layerTreeHostImpl, base::TimeTicks monotonicTime) OVERRIDE
@@ -761,40 +761,6 @@ private:
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAddAnimationWithTimingFunction)
-// Ensures that when opacity is being animated, this value does not cause the subtree to be skipped.
-class LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public LayerTreeHostTest {
-public:
- LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity()
- {
- }
-
- virtual void beginTest() OVERRIDE
- {
- m_layerTreeHost->rootLayer()->setDrawOpacity(1);
- m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
- m_layerTreeHost->rootLayer()->setOpacity(0);
- postAddAnimationToMainThread();
- }
-
- virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
- {
- // If the subtree was skipped when preparing to draw, the layer's draw opacity
- // will not have been updated. It should be set to 0 due to the animation.
- // Without the animation, the layer will be skipped since it has zero opacity.
- EXPECT_EQ(0, m_layerTreeHost->rootLayer()->drawOpacity());
- endTest();
- }
-
- virtual void afterTest() OVERRIDE
- {
- }
-};
-
-TEST_F(LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, runMultiThread)
-{
- runTest(true);
-}
-
// Ensures that main thread animations have their start times synchronized with impl thread animations.
class LayerTreeHostTestSynchronizeAnimationStartTimes : public LayerTreeHostTest {
public:
@@ -805,7 +771,7 @@ public:
virtual void beginTest() OVERRIDE
{
- postAddAnimationToMainThread();
+ postAddAnimationToMainThread(m_layerTreeHost->rootLayer());
}
// This is guaranteed to be called before CCLayerTreeHostImpl::animateLayers.
@@ -1155,19 +1121,25 @@ TEST_F(LayerTreeHostTestSetVisible, runMultiThread)
class TestOpacityChangeLayerDelegate : public ContentLayerClient {
public:
- TestOpacityChangeLayerDelegate(LayerTreeHostTest* test)
- : m_test(test)
+ TestOpacityChangeLayerDelegate()
+ : m_testLayer(0)
+ {
+ }
+
+ void setTestLayer(Layer* testLayer)
{
+ m_testLayer = testLayer;
}
virtual void paintContents(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE
{
// Set layer opacity to 0.
- m_test->layerTreeHost()->rootLayer()->setOpacity(0);
+ if (m_testLayer)
+ m_testLayer->setOpacity(0);
}
private:
- LayerTreeHostTest* m_test;
+ Layer* m_testLayer;
};
class ContentLayerWithUpdateTracking : public ContentLayer {
@@ -1203,15 +1175,16 @@ private:
class LayerTreeHostTestOpacityChange : public LayerTreeHostTest {
public:
LayerTreeHostTestOpacityChange()
- : m_testOpacityChangeDelegate(this)
+ : m_testOpacityChangeDelegate()
, m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_testOpacityChangeDelegate))
{
+ m_testOpacityChangeDelegate.setTestLayer(m_updateCheckLayer.get());
}
virtual void beginTest() OVERRIDE
{
- m_layerTreeHost->setRootLayer(m_updateCheckLayer);
m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
+ m_layerTreeHost->rootLayer()->addChild(m_updateCheckLayer);
postSetNeedsCommitToMainThread();
}
@@ -1260,6 +1233,47 @@ private:
virtual ~NoScaleContentLayer() { }
};
+// Ensures that when opacity is being animated, this value does not cause the subtree to be skipped.
+class LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public LayerTreeHostTest {
+public:
+ LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity()
+ : m_updateCheckLayer(ContentLayerWithUpdateTracking::create(&m_client))
+ {
+ }
+
+ virtual void beginTest() OVERRIDE
+ {
+ m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
+ m_layerTreeHost->rootLayer()->addChild(m_updateCheckLayer);
+ m_updateCheckLayer->setOpacity(0);
+ m_updateCheckLayer->setDrawOpacity(0);
+ postAddAnimationToMainThread(m_updateCheckLayer.get());
+ }
+
+ virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
+ {
+ endTest();
+ }
+
+ virtual void afterTest() OVERRIDE
+ {
+ // update() should have been called once, proving that the layer was not skipped.
+ EXPECT_EQ(1, m_updateCheckLayer->paintContentsCount());
+
+ // clear m_updateCheckLayer so LayerTreeHost dies.
+ m_updateCheckLayer = NULL;
+ }
+
+private:
+ MockContentLayerClient m_client;
+ scoped_refptr<ContentLayerWithUpdateTracking> m_updateCheckLayer;
+};
+
+TEST_F(LayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity, runMultiThread)
+{
+ runTest(true);
+}
+
class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers : public LayerTreeHostTest {
public: