diff options
author | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-13 16:35:17 +0000 |
---|---|---|
committer | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-13 16:35:17 +0000 |
commit | 436158733477a44f6c89b6c0c4035bfba5b83b61 (patch) | |
tree | 366b42051b7414de50397c4961b32e7b67ef0953 | |
parent | 372a3371caca852bcc805cea44a60c90772a40af (diff) | |
download | chromium_src-436158733477a44f6c89b6c0c4035bfba5b83b61.zip chromium_src-436158733477a44f6c89b6c0c4035bfba5b83b61.tar.gz chromium_src-436158733477a44f6c89b6c0c4035bfba5b83b61.tar.bz2 |
Do not push properties that are animated on impl only.
We currently avoid pushing properties when the main thread layer indicates that
it is animating. This code was incorrectly left behind after we started
animating on the main thread. Recently, we've added support for impl-only
animations. We should never push during one of these animations.
BUG=
Review URL: https://chromiumcodereview.appspot.com/12413020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187875 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/layer.cc | 6 | ||||
-rw-r--r-- | cc/layer_impl.cc | 18 | ||||
-rw-r--r-- | cc/layer_impl.h | 2 | ||||
-rw-r--r-- | cc/layer_unittest.cc | 57 |
4 files changed, 77 insertions, 6 deletions
diff --git a/cc/layer.cc b/cc/layer.cc index 53ad044..434ef2b 100644 --- a/cc/layer.cc +++ b/cc/layer.cc @@ -576,8 +576,9 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); layer->SetTouchEventHandlerRegion(touch_event_handler_region_); layer->SetContentsOpaque(contents_opaque_); - if (!OpacityIsAnimating()) + if (!layer->OpacityIsAnimatingOnImplOnly()) layer->SetOpacity(opacity_); + DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); layer->SetPosition(position_); layer->SetIsContainerForFixedPositionLayers( is_container_for_fixed_position_layers_); @@ -585,8 +586,9 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { layer->SetPreserves3d(preserves_3d()); layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); layer->SetSublayerTransform(sublayer_transform_); - if (!TransformIsAnimating()) + if (!layer->TransformIsAnimatingOnImplOnly()) layer->SetTransform(transform_); + DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); layer->SetScrollable(scrollable_); layer->SetScrollOffset(scroll_offset_); diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc index ff1ac7c..dd0a21e 100644 --- a/cc/layer_impl.cc +++ b/cc/layer_impl.cc @@ -333,8 +333,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); layer->SetTouchEventHandlerRegion(touch_event_handler_region_); layer->SetContentsOpaque(contents_opaque_); - if (!OpacityIsAnimating()) - layer->SetOpacity(opacity_); + layer->SetOpacity(opacity_); layer->SetPosition(position_); layer->SetIsContainerForFixedPositionLayers( is_container_for_fixed_position_layers_); @@ -342,8 +341,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { layer->SetPreserves3d(preserves_3d()); layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); layer->SetSublayerTransform(sublayer_transform_); - if (!TransformIsAnimating()) - layer->SetTransform(transform_); + layer->SetTransform(transform_); layer->SetScrollable(scrollable_); layer->SetScrollOffset(scroll_offset_); @@ -717,6 +715,12 @@ bool LayerImpl::OpacityIsAnimating() const { return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); } +bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { + Animation* opacity_animation = + layer_animation_controller_->GetAnimation(Animation::Opacity); + return opacity_animation && opacity_animation->is_impl_only(); +} + void LayerImpl::SetPosition(gfx::PointF position) { if (position_ == position) return; @@ -755,6 +759,12 @@ bool LayerImpl::TransformIsAnimating() const { return layer_animation_controller_->IsAnimatingProperty(Animation::Transform); } +bool LayerImpl::TransformIsAnimatingOnImplOnly() const { + Animation* transform_animation = + layer_animation_controller_->GetAnimation(Animation::Transform); + return transform_animation && transform_animation->is_impl_only(); +} + void LayerImpl::SetContentBounds(gfx::Size content_bounds) { if (this->content_bounds() == content_bounds) return; diff --git a/cc/layer_impl.h b/cc/layer_impl.h index b2d6d99..bfd8053 100644 --- a/cc/layer_impl.h +++ b/cc/layer_impl.h @@ -150,6 +150,7 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver { void SetOpacity(float opacity); float opacity() const { return opacity_; } bool OpacityIsAnimating() const; + bool OpacityIsAnimatingOnImplOnly() const; void SetPosition(gfx::PointF position); gfx::PointF position() const { return position_; } @@ -327,6 +328,7 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver { void SetTransform(const gfx::Transform& transform); const gfx::Transform& transform() const { return transform_; } bool TransformIsAnimating() const; + bool TransformIsAnimatingOnImplOnly() const; void set_update_rect(const gfx::RectF& update_rect) { update_rect_ = update_rect; diff --git a/cc/layer_unittest.cc b/cc/layer_unittest.cc index 816ea9e..c62ad09 100644 --- a/cc/layer_unittest.cc +++ b/cc/layer_unittest.cc @@ -10,6 +10,7 @@ #include "cc/layer_tree_host.h" #include "cc/math_util.h" #include "cc/single_thread_proxy.h" +#include "cc/test/animation_test_common.h" #include "cc/test/fake_impl_proxy.h" #include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_layer_tree_host_impl.h" @@ -643,6 +644,62 @@ TEST_F(LayerTest, verifyPushPropertiesCausesSurfacePropertyChangedForOpacity) EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); } +TEST_F(LayerTest, verifyPushPropertiesDoesNotCauseSurfacePropertyChangedDuringImplOnlyTransformAnimation) +{ + scoped_refptr<Layer> testLayer = Layer::Create(); + scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.activeTree(), 1); + + scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create(); + implLayer->layer_animation_controller()->SetAnimationRegistrar(registrar.get()); + + addAnimatedTransformToController(*implLayer->layer_animation_controller(), 1.0, 0, 100); + + gfx::Transform transform; + transform.Rotate(45.0); + testLayer->SetTransform(transform); + + EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); + testLayer->PushPropertiesTo(implLayer.get()); + EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); + + implLayer->ResetAllChangeTrackingForSubtree(); + addAnimatedTransformToController(*implLayer->layer_animation_controller(), 1.0, 0, 100); + implLayer->layer_animation_controller()->GetAnimation(Animation::Transform)->set_is_impl_only(true); + transform.Rotate(45.0); + testLayer->SetTransform(transform); + + EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); + testLayer->PushPropertiesTo(implLayer.get()); + EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); +} + +TEST_F(LayerTest, verifyPushPropertiesDoesNotCauseSurfacePropertyChangedDuringImplOnlyOpacityAnimation) +{ + scoped_refptr<Layer> testLayer = Layer::Create(); + scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.activeTree(), 1); + + scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create(); + implLayer->layer_animation_controller()->SetAnimationRegistrar(registrar.get()); + + addOpacityTransitionToController(*implLayer->layer_animation_controller(), 1.0, 0.3f, 0.7f, false); + + testLayer->SetOpacity(0.5f); + + EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); + testLayer->PushPropertiesTo(implLayer.get()); + EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); + + implLayer->ResetAllChangeTrackingForSubtree(); + addOpacityTransitionToController(*implLayer->layer_animation_controller(), 1.0, 0.3f, 0.7f, false); + implLayer->layer_animation_controller()->GetAnimation(Animation::Opacity)->set_is_impl_only(true); + testLayer->SetOpacity(0.75f); + + EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); + testLayer->PushPropertiesTo(implLayer.get()); + EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); +} + + TEST_F(LayerTest, maskAndReplicaHasParent) { scoped_refptr<Layer> parent = Layer::Create(); |