Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2678)

Unified Diff: cc/layer_unittest.cc

Issue 12334041: Enable accelerated animations for orphaned layers (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Also test LTH with no registrar Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layer_tree_host.cc ('k') | content/renderer/gpu/render_widget_compositor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_unittest.cc
diff --git a/cc/layer_unittest.cc b/cc/layer_unittest.cc
index 6784858c7fd0f35434d3ff3e13455d88382c31a7..7e19db9a98c2e366654f45731417bc955ac1fe9a 100644
--- a/cc/layer_unittest.cc
+++ b/cc/layer_unittest.cc
@@ -649,6 +649,13 @@ public:
return host.Pass();
}
+ static scoped_ptr<FakeLayerImplTreeHost> create(LayerTreeSettings settings)
+ {
+ scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost(settings));
+ host->initialize(scoped_ptr<Thread>(NULL));
+ return host.Pass();
+ }
+
private:
FakeLayerImplTreeHost(const LayerTreeSettings& settings)
: LayerTreeHost(&m_client, settings)
@@ -844,31 +851,30 @@ static bool addTestAnimation(Layer* layer)
return layer->addAnimation(animation.Pass());
}
-TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost)
+TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutAnimationRegistrar)
{
- // Currently, WebCore assumes that animations will be started immediately / very soon
- // if a composited layer's addAnimation() returns true. However, without a layerTreeHost,
- // layers cannot actually animate yet. So, to prevent violating this WebCore assumption,
- // the animation should not be accepted if the layer doesn't already have a layerTreeHost.
-
scoped_refptr<Layer> layer = Layer::create();
- // Case 1: without a layerTreeHost, the animation should not be accepted.
-#if defined(OS_ANDROID)
- // All animations are enabled on Android to avoid performance regressions.
- // Other platforms will be enabled with http://crbug.com/129683
- EXPECT_TRUE(addTestAnimation(layer.get()));
-#else
+ // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the
+ // animation should not be accepted.
EXPECT_FALSE(addTestAnimation(layer.get()));
-#endif
- scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::create());
+ scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create();
+ layer->layerAnimationController()->setAnimationRegistrar(registrar.get());
+
+ // Case 2: with an AnimationRegistrar, the animation should be accepted.
+ EXPECT_TRUE(addTestAnimation(layer.get()));
+
+ LayerTreeSettings settings;
+ settings.acceleratedAnimationEnabled = false;
+ scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::create(settings));
layerTreeHost->setRootLayer(layer.get());
layer->setLayerTreeHost(layerTreeHost.get());
assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get());
- // Case 2: with a layerTreeHost, the animation should be accepted.
- EXPECT_TRUE(addTestAnimation(layer.get()));
+ // Case 3: with a LayerTreeHost where accelerated animation is disabled, the
+ // animation should be rejected.
+ EXPECT_FALSE(addTestAnimation(layer.get()));
}
} // namespace
« no previous file with comments | « cc/layer_tree_host.cc ('k') | content/renderer/gpu/render_widget_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698