summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-03 03:03:11 +0000
committerajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-03 03:03:11 +0000
commit5d8bec73db031fb0cd49a413d412b2aad9a6be63 (patch)
tree71cad131c3ea47d0b7f44a37880620cd00f436d9 /cc
parent7c5015180b89b698222a796084ce2bf07473217e (diff)
downloadchromium_src-5d8bec73db031fb0cd49a413d412b2aad9a6be63.zip
chromium_src-5d8bec73db031fb0cd49a413d412b2aad9a6be63.tar.gz
chromium_src-5d8bec73db031fb0cd49a413d412b2aad9a6be63.tar.bz2
cc: Disallow scroll offset animations when impl-scrolling isn't supported
SingleThreadProxy doesn't support directly changing scroll offsets on the impl layer tree (since it doesn't send scroll deltas from the impl side back to the main-thread side). This means that scroll offset animations should be disallowed by cc when using SingleThreadProxy. BUG=243871 Review URL: https://codereview.chromium.org/368883003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281140 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/animation/animation_registrar.cc3
-rw-r--r--cc/animation/animation_registrar.h8
-rw-r--r--cc/layers/layer.cc6
-rw-r--r--cc/test/fake_proxy.cc2
-rw-r--r--cc/test/fake_proxy.h1
-rw-r--r--cc/trees/layer_tree_host.cc4
-rw-r--r--cc/trees/layer_tree_host_impl.cc2
-rw-r--r--cc/trees/layer_tree_host_unittest_animation.cc17
-rw-r--r--cc/trees/proxy.h2
-rw-r--r--cc/trees/single_thread_proxy.cc4
-rw-r--r--cc/trees/single_thread_proxy.h1
-rw-r--r--cc/trees/thread_proxy.cc4
-rw-r--r--cc/trees/thread_proxy.h1
13 files changed, 48 insertions, 7 deletions
diff --git a/cc/animation/animation_registrar.cc b/cc/animation/animation_registrar.cc
index 05f522c..7af5fea 100644
--- a/cc/animation/animation_registrar.cc
+++ b/cc/animation/animation_registrar.cc
@@ -8,7 +8,8 @@
namespace cc {
-AnimationRegistrar::AnimationRegistrar() {}
+AnimationRegistrar::AnimationRegistrar() : supports_scroll_animations_(false) {
+}
AnimationRegistrar::~AnimationRegistrar() {
AnimationControllerMap copy = all_animation_controllers_;
diff --git a/cc/animation/animation_registrar.h b/cc/animation/animation_registrar.h
index 579b11f..36c45c7 100644
--- a/cc/animation/animation_registrar.h
+++ b/cc/animation/animation_registrar.h
@@ -51,12 +51,20 @@ class CC_EXPORT AnimationRegistrar {
return all_animation_controllers_;
}
+ void set_supports_scroll_animations(bool supports_scroll_animations) {
+ supports_scroll_animations_ = supports_scroll_animations;
+ }
+
+ bool supports_scroll_animations() { return supports_scroll_animations_; }
+
private:
AnimationRegistrar();
AnimationControllerMap active_animation_controllers_;
AnimationControllerMap all_animation_controllers_;
+ bool supports_scroll_animations_;
+
DISALLOW_COPY_AND_ASSIGN(AnimationRegistrar);
};
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index e00d2c5..82978da 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -14,6 +14,7 @@
#include "base/time/time.h"
#include "cc/animation/animation.h"
#include "cc/animation/animation_events.h"
+#include "cc/animation/animation_registrar.h"
#include "cc/animation/keyframed_animation_curve.h"
#include "cc/animation/layer_animation_controller.h"
#include "cc/layers/layer_client.h"
@@ -1099,6 +1100,11 @@ bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
if (!layer_animation_controller_->animation_registrar())
return false;
+ if (animation->target_property() == Animation::ScrollOffset &&
+ !layer_animation_controller_->animation_registrar()
+ ->supports_scroll_animations())
+ return false;
+
UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer",
!layer_tree_host_);
layer_animation_controller_->AddAnimation(animation.Pass());
diff --git a/cc/test/fake_proxy.cc b/cc/test/fake_proxy.cc
index 7799ff3..facf831 100644
--- a/cc/test/fake_proxy.cc
+++ b/cc/test/fake_proxy.cc
@@ -32,6 +32,8 @@ void FakeProxy::SetMaxPartialTextureUpdates(size_t max) {
max_partial_texture_updates_ = max;
}
+bool FakeProxy::SupportsImplScrolling() const { return false; }
+
bool FakeProxy::CommitPendingForTesting() { return false; }
scoped_ptr<base::Value> FakeProxy::AsValue() const {
diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h
index 1d62c6f..004962e 100644
--- a/cc/test/fake_proxy.h
+++ b/cc/test/fake_proxy.h
@@ -40,6 +40,7 @@ class FakeProxy : public Proxy {
virtual void Stop() OVERRIDE {}
virtual void ForceSerializeOnSwapBuffers() OVERRIDE {}
virtual size_t MaxPartialTextureUpdates() const OVERRIDE;
+ virtual bool SupportsImplScrolling() const OVERRIDE;
virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {}
virtual bool CommitPendingForTesting() OVERRIDE;
virtual scoped_ptr<base::Value> AsValue() const OVERRIDE;
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 5f45c17..48f4864 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -143,6 +143,10 @@ void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) {
proxy_ = proxy.Pass();
proxy_->Start();
+ if (settings_.accelerated_animation_enabled) {
+ animation_registrar_->set_supports_scroll_animations(
+ proxy_->SupportsImplScrolling());
+ }
}
LayerTreeHost::~LayerTreeHost() {
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index c4f268dd..efd0560 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -258,6 +258,8 @@ LayerTreeHostImpl::LayerTreeHostImpl(
transfer_buffer_memory_limit_(0u) {
DCHECK(proxy_->IsImplThread());
DidVisibilityChange(this, visible_);
+ animation_registrar_->set_supports_scroll_animations(
+ proxy_->SupportsImplScrolling());
SetDebugState(settings.initial_debug_state);
diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc
index 1542a14..64dd31d 100644
--- a/cc/trees/layer_tree_host_unittest_animation.cc
+++ b/cc/trees/layer_tree_host_unittest_animation.cc
@@ -1073,8 +1073,9 @@ class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
MULTI_THREAD_TEST_F(
LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations);
-// Verifies that when scroll offset is animated on the impl thread, updates
-// are sent back to the main thread.
+// Verifies that scroll offset animations are only accepted when impl-scrolling
+// is supported, and that when scroll offset animations are accepted,
+// scroll offset updates are sent back to the main thread.
class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated
: public LayerTreeHostAnimationTest {
public:
@@ -1104,7 +1105,12 @@ class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated
scoped_ptr<Animation> animation(Animation::Create(
curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
animation->set_needs_synchronized_start_time(true);
- scroll_layer_->AddAnimation(animation.Pass());
+ bool animation_added = scroll_layer_->AddAnimation(animation.Pass());
+ bool impl_scrolling_supported =
+ layer_tree_host()->proxy()->SupportsImplScrolling();
+ EXPECT_EQ(impl_scrolling_supported, animation_added);
+ if (!impl_scrolling_supported)
+ EndTest();
break;
}
default:
@@ -1121,9 +1127,8 @@ class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated
scoped_refptr<FakeContentLayer> scroll_layer_;
};
-// SingleThreadProxy doesn't send scroll updates from LayerTreeHostImpl to
-// LayerTreeHost.
-MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestScrollOffsetChangesArePropagated);
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostAnimationTestScrollOffsetChangesArePropagated);
// Ensure that animation time is correctly updated when animations are frozen
// because of checkerboarding.
diff --git a/cc/trees/proxy.h b/cc/trees/proxy.h
index 4066513..838e44f 100644
--- a/cc/trees/proxy.h
+++ b/cc/trees/proxy.h
@@ -89,6 +89,8 @@ class CC_EXPORT Proxy {
// Maximum number of sub-region texture updates supported for each commit.
virtual size_t MaxPartialTextureUpdates() const = 0;
+ virtual bool SupportsImplScrolling() const = 0;
+
virtual scoped_ptr<base::Value> AsValue() const = 0;
virtual void SetDebugState(const LayerTreeDebugState& debug_state) = 0;
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index c254311..9469d59 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -391,6 +391,10 @@ void SingleThreadProxy::ForceSerializeOnSwapBuffers() {
}
}
+bool SingleThreadProxy::SupportsImplScrolling() const {
+ return false;
+}
+
bool SingleThreadProxy::ShouldComposite() const {
DCHECK(Proxy::IsImplThread());
return layer_tree_host_impl_->visible() &&
diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h
index 4b95331..306578f 100644
--- a/cc/trees/single_thread_proxy.h
+++ b/cc/trees/single_thread_proxy.h
@@ -47,6 +47,7 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
virtual void Stop() OVERRIDE;
virtual size_t MaxPartialTextureUpdates() const OVERRIDE;
virtual void ForceSerializeOnSwapBuffers() OVERRIDE;
+ virtual bool SupportsImplScrolling() const OVERRIDE;
virtual scoped_ptr<base::Value> AsValue() const OVERRIDE;
virtual bool CommitPendingForTesting() OVERRIDE;
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
index d62b96e..56ce577 100644
--- a/cc/trees/thread_proxy.cc
+++ b/cc/trees/thread_proxy.cc
@@ -662,6 +662,10 @@ void ThreadProxy::ForceSerializeOnSwapBuffersOnImplThread(
completion->Signal();
}
+bool ThreadProxy::SupportsImplScrolling() const {
+ return true;
+}
+
void ThreadProxy::SetDebugState(const LayerTreeDebugState& debug_state) {
Proxy::ImplThreadTaskRunner()->PostTask(
FROM_HERE,
diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h
index 390116c..74accef 100644
--- a/cc/trees/thread_proxy.h
+++ b/cc/trees/thread_proxy.h
@@ -166,6 +166,7 @@ class CC_EXPORT ThreadProxy : public Proxy,
virtual void Stop() OVERRIDE;
virtual size_t MaxPartialTextureUpdates() const OVERRIDE;
virtual void ForceSerializeOnSwapBuffers() OVERRIDE;
+ virtual bool SupportsImplScrolling() const OVERRIDE;
virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE;
virtual scoped_ptr<base::Value> AsValue() const OVERRIDE;
virtual bool CommitPendingForTesting() OVERRIDE;