| Index: ui/gfx/compositor/layer.cc
|
| ===================================================================
|
| --- ui/gfx/compositor/layer.cc (revision 107719)
|
| +++ ui/gfx/compositor/layer.cc (working copy)
|
| @@ -18,7 +18,7 @@
|
| #include "ui/gfx/compositor/compositor_cc.h"
|
| #endif
|
| #include "ui/gfx/canvas_skia.h"
|
| -#include "ui/gfx/compositor/layer_animator.h"
|
| +#include "ui/gfx/compositor/layer_animation_manager.h"
|
| #include "ui/gfx/interpolated_transform.h"
|
| #include "ui/gfx/point3.h"
|
|
|
| @@ -135,48 +135,51 @@
|
| return false;
|
| }
|
|
|
| -void Layer::SetAnimator(LayerAnimator* animator) {
|
| - if (animator)
|
| - animator->SetDelegate(this);
|
| - animator_.reset(animator);
|
| +void Layer::SetAnimation(Animation* animation) {
|
| + if (animation) {
|
| + if (!animator_.get())
|
| + animator_.reset(new LayerAnimationManager(this));
|
| + animation->Start();
|
| + animator_->SetAnimation(animation);
|
| + } else {
|
| + animator_.reset();
|
| + }
|
| }
|
|
|
| -LayerAnimator* Layer::GetAnimator() {
|
| - if (!animator_.get())
|
| - SetAnimator(LayerAnimator::CreateDefaultAnimator());
|
| - return animator_.get();
|
| -}
|
| -
|
| void Layer::SetTransform(const ui::Transform& transform) {
|
| - GetAnimator()->SetTransform(transform);
|
| + StopAnimatingIfNecessary(LayerAnimationManager::TRANSFORM);
|
| + if (animator_.get() && animator_->IsRunning()) {
|
| + animator_->AnimateTransform(transform);
|
| + return;
|
| + }
|
| + SetTransformImmediately(transform);
|
| }
|
|
|
| -Transform Layer::GetTargetTransform() const {
|
| - if (animator_.get() && animator_->is_animating())
|
| - return animator_->GetTargetTransform();
|
| - return transform_;
|
| -}
|
| -
|
| void Layer::SetBounds(const gfx::Rect& bounds) {
|
| - GetAnimator()->SetBounds(bounds);
|
| + StopAnimatingIfNecessary(LayerAnimationManager::LOCATION);
|
| + if (animator_.get() && animator_->IsRunning() &&
|
| + bounds.size() == bounds_.size()) {
|
| + animator_->AnimateToPoint(bounds.origin());
|
| + return;
|
| + }
|
| + SetBoundsImmediately(bounds);
|
| }
|
|
|
| gfx::Rect Layer::GetTargetBounds() const {
|
| - if (animator_.get() && animator_->is_animating())
|
| - return animator_->GetTargetBounds();
|
| + if (animator_.get() && animator_->IsRunning())
|
| + return gfx::Rect(animator_->GetTargetPoint(), bounds_.size());
|
| return bounds_;
|
| }
|
|
|
| void Layer::SetOpacity(float opacity) {
|
| - GetAnimator()->SetOpacity(opacity);
|
| + StopAnimatingIfNecessary(LayerAnimationManager::OPACITY);
|
| + if (animator_.get() && animator_->IsRunning()) {
|
| + animator_->AnimateOpacity(opacity);
|
| + return;
|
| + }
|
| + SetOpacityImmediately(opacity);
|
| }
|
|
|
| -float Layer::GetTargetOpacity() const {
|
| - if (animator_.get() && animator_->is_animating())
|
| - return animator_->GetTargetOpacity();
|
| - return opacity_;
|
| -}
|
| -
|
| void Layer::SetVisible(bool visible) {
|
| if (visible_ == visible)
|
| return;
|
| @@ -593,6 +596,29 @@
|
| return p == ancestor;
|
| }
|
|
|
| +void Layer::StopAnimatingIfNecessary(
|
| + LayerAnimationManager::AnimationProperty property) {
|
| + if (!animator_.get() || !animator_->IsRunning() ||
|
| + !animator_->got_initial_tick()) {
|
| + return;
|
| + }
|
| +
|
| + if (property != LayerAnimationManager::LOCATION &&
|
| + animator_->IsAnimating(LayerAnimationManager::LOCATION)) {
|
| + SetBoundsImmediately(
|
| + gfx::Rect(animator_->GetTargetPoint(), bounds_.size()));
|
| + }
|
| + if (property != LayerAnimationManager::OPACITY &&
|
| + animator_->IsAnimating(LayerAnimationManager::OPACITY)) {
|
| + SetOpacityImmediately(animator_->GetTargetOpacity());
|
| + }
|
| + if (property != LayerAnimationManager::TRANSFORM &&
|
| + animator_->IsAnimating(LayerAnimationManager::TRANSFORM)) {
|
| + SetTransformImmediately(animator_->GetTargetTransform());
|
| + }
|
| + animator_.reset();
|
| +}
|
| +
|
| void Layer::SetBoundsImmediately(const gfx::Rect& bounds) {
|
| bounds_ = bounds;
|
|
|
| @@ -622,39 +648,18 @@
|
| #endif
|
| }
|
|
|
| -void Layer::SetBoundsFromAnimation(const gfx::Rect& bounds) {
|
| +void Layer::SetBoundsFromAnimator(const gfx::Rect& bounds) {
|
| SetBoundsImmediately(bounds);
|
| }
|
|
|
| -void Layer::SetTransformFromAnimation(const Transform& transform) {
|
| +void Layer::SetTransformFromAnimator(const Transform& transform) {
|
| SetTransformImmediately(transform);
|
| }
|
|
|
| -void Layer::SetOpacityFromAnimation(float opacity) {
|
| +void Layer::SetOpacityFromAnimator(float opacity) {
|
| SetOpacityImmediately(opacity);
|
| }
|
|
|
| -void Layer::ScheduleDrawForAnimation() {
|
| - ScheduleDraw();
|
| -}
|
| -
|
| -const gfx::Rect& Layer::GetBoundsForAnimation() const {
|
| - return bounds();
|
| -}
|
| -
|
| -const Transform& Layer::GetTransformForAnimation() const {
|
| - return transform();
|
| -}
|
| -
|
| -float Layer::GetOpacityForAnimation() const {
|
| - return opacity();
|
| -}
|
| -
|
| -void Layer::OnLayerAnimationEnded(LayerAnimationSequence* sequence) {
|
| - if (delegate_)
|
| - delegate_->OnLayerAnimationEnded(sequence);
|
| -}
|
| -
|
| #if defined(USE_WEBKIT_COMPOSITOR)
|
| void Layer::CreateWebLayer() {
|
| web_layer_ = WebKit::WebContentLayer::create(this, this);
|
|
|