Chromium Code Reviews| Index: ui/gfx/compositor/layer.cc |
| diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc |
| index 8266bffc684f000fea7878179f3e821b8847f926..78e64e8543f27831cc745cd1167fa9ddee3e4c35 100644 |
| --- a/ui/gfx/compositor/layer.cc |
| +++ b/ui/gfx/compositor/layer.cc |
| @@ -8,7 +8,6 @@ |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "ui/base/animation/animation.h" |
| #include "ui/gfx/compositor/layer_animator.h" |
| #include "ui/gfx/canvas_skia.h" |
| #include "ui/gfx/interpolated_transform.h" |
| @@ -106,43 +105,37 @@ bool Layer::Contains(const Layer* other) const { |
| return false; |
| } |
| -void Layer::SetAnimation(Animation* animation) { |
| - if (animation) { |
| - if (!animator_.get()) |
| - animator_.reset(new LayerAnimator(this)); |
| - animation->Start(); |
| - animator_->SetAnimation(animation); |
| - } else { |
| - animator_.reset(); |
| +void Layer::SetAnimator(LayerAnimator* animator) { |
| + animator->SetDelegate(this); |
| + animator_.reset(animator); |
| +} |
| + |
| +LayerAnimator* Layer::GetAnimator() { |
| + if (!animator_.get()) { |
|
sky
2011/10/19 00:06:33
no {}
|
| + SetAnimator(LayerAnimator::CreateDefaultAnimator()); |
| } |
| + return animator_.get(); |
| } |
| void Layer::SetTransform(const ui::Transform& transform) { |
| - StopAnimatingIfNecessary(LayerAnimator::TRANSFORM); |
| - if (animator_.get() && animator_->IsRunning()) { |
| - animator_->AnimateTransform(transform); |
| - return; |
| - } |
| - SetTransformImmediately(transform); |
| + if (animator_.get()) |
| + animator_->SetTransform(transform); |
| + else |
| + SetTransformImmediately(transform); |
| } |
| void Layer::SetBounds(const gfx::Rect& bounds) { |
| - StopAnimatingIfNecessary(LayerAnimator::LOCATION); |
| - if (animator_.get() && animator_->IsRunning() && |
| - bounds.size() == bounds_.size()) { |
| - animator_->AnimateToPoint(bounds.origin()); |
| - return; |
| - } |
| - SetBoundsImmediately(bounds); |
| + if (animator_.get()) |
| + animator_->SetBounds(bounds); |
| + else |
| + SetBoundsImmediately(bounds); |
| } |
| void Layer::SetOpacity(float opacity) { |
| - StopAnimatingIfNecessary(LayerAnimator::OPACITY); |
| - if (animator_.get() && animator_->IsRunning()) { |
| - animator_->AnimateOpacity(opacity); |
| - return; |
| - } |
| - SetOpacityImmediately(opacity); |
| + if (animator_.get()) |
| + animator_->SetOpacity(opacity); |
| + else |
| + SetOpacityImmediately(opacity); |
| } |
| void Layer::SetVisible(bool visible) { |
| @@ -350,7 +343,7 @@ void Layer::RecomputeHole() { |
| // Free up texture memory if the hole fills bounds of layer. |
| if (!ShouldDraw() && !layer_updated_externally_) |
| - texture_ = NULL; |
| + DropTextures(); |
|
sky
2011/10/19 00:06:33
Why do we want to do drop all child textures here?
|
| } |
| bool Layer::IsCompletelyOpaque() const { |
| @@ -432,29 +425,6 @@ bool Layer::GetTransformRelativeTo(const Layer* ancestor, |
| return p == ancestor; |
| } |
| -void Layer::StopAnimatingIfNecessary( |
| - LayerAnimator::AnimationProperty property) { |
| - if (!animator_.get() || !animator_->IsRunning() || |
| - !animator_->got_initial_tick()) { |
| - return; |
| - } |
| - |
| - if (property != LayerAnimator::LOCATION && |
| - animator_->IsAnimating(LayerAnimator::LOCATION)) { |
| - SetBoundsImmediately( |
| - gfx::Rect(animator_->GetTargetPoint(), bounds_.size())); |
| - } |
| - if (property != LayerAnimator::OPACITY && |
| - animator_->IsAnimating(LayerAnimator::OPACITY)) { |
| - SetOpacityImmediately(animator_->GetTargetOpacity()); |
| - } |
| - if (property != LayerAnimator::TRANSFORM && |
| - animator_->IsAnimating(LayerAnimator::TRANSFORM)) { |
| - SetTransformImmediately(animator_->GetTargetTransform()); |
| - } |
| - animator_.reset(); |
| -} |
| - |
| void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { |
| bounds_ = bounds; |
| @@ -491,16 +461,32 @@ void Layer::SetOpacityImmediately(float opacity) { |
| } |
| } |
| -void Layer::SetBoundsFromAnimator(const gfx::Rect& bounds) { |
| +void Layer::SetBoundsFromAnimation(const gfx::Rect& bounds) { |
| SetBoundsImmediately(bounds); |
| } |
| -void Layer::SetTransformFromAnimator(const Transform& transform) { |
| +void Layer::SetTransformFromAnimation(const Transform& transform) { |
| SetTransformImmediately(transform); |
| } |
| -void Layer::SetOpacityFromAnimator(float opacity) { |
| +void Layer::SetOpacityFromAnimation(float opacity) { |
| SetOpacityImmediately(opacity); |
| } |
| +void Layer::ScheduleDrawForAnimation() { |
| + ScheduleDraw(); |
| +} |
| + |
| +const gfx::Rect& Layer::GetBoundsForAnimation() const { |
| + return bounds(); |
| +} |
| + |
| +const Transform& Layer::GetTransformForAnimation() const { |
| + return transform(); |
| +} |
| + |
| +const float Layer::GetOpacityForAnimation() const { |
| + return opacity(); |
| +} |
| + |
| } // namespace ui |