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

Unified Diff: ui/gfx/compositor/layer_animator.h

Issue 7972023: Implicit animations through Layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SetAnimator Created 9 years, 3 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
Index: ui/gfx/compositor/layer_animator.h
diff --git a/ui/gfx/compositor/layer_animator.h b/ui/gfx/compositor/layer_animator.h
index 4570e264d73ae8c60ad5f5e95030ec848a4810b9..170e55061037c5a08c06b65000b871a0dc8073c5 100644
--- a/ui/gfx/compositor/layer_animator.h
+++ b/ui/gfx/compositor/layer_animator.h
@@ -10,17 +10,21 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "third_party/skia/include/core/SkScalar.h"
#include "third_party/skia/include/utils/SkMatrix44.h"
#include "ui/base/animation/animation_delegate.h"
-#include "ui/base/animation/tween.h"
#include "ui/gfx/compositor/compositor_export.h"
-#include "ui/gfx/point.h"
+
+namespace gfx {
+class Point;
+}
namespace ui {
+class Animation;
class Layer;
-class MultiAnimation;
+class LayerAnimatorDelegate;
class Transform;
// LayerAnimator manages animating various properties of a Layer.
@@ -29,11 +33,9 @@ class COMPOSITOR_EXPORT LayerAnimator : public ui::AnimationDelegate {
explicit LayerAnimator(Layer* layer);
virtual ~LayerAnimator();
- ui::Layer* layer() { return layer_; }
+ void SetAnimation(Animation* animation);
- // Sets the duration (in ms) and type of animation. This does not effect
- // existing animations, only newly created animations.
- void SetAnimationDurationAndType(int duration, ui::Tween::Type tween_type);
+ ui::Layer* layer() { return layer_; }
// Animates the layer to the specified point. The point is relative to the
// parent layer.
@@ -48,6 +50,13 @@ class COMPOSITOR_EXPORT LayerAnimator : public ui::AnimationDelegate {
StopAnimating(TRANSFORM);
}
+ void AnimateOpacity(float target_opacity);
+ void StopAnimatingOpacity() {
+ StopAnimating(OPACITY);
+ }
+
+ bool IsRunning() const;
+
// AnimationDelegate:
virtual void AnimationProgressed(const Animation* animation) OVERRIDE;
virtual void AnimationEnded(const Animation* animation) OVERRIDE;
@@ -56,7 +65,8 @@ class COMPOSITOR_EXPORT LayerAnimator : public ui::AnimationDelegate {
// Types of properties that can be animated.
enum AnimationProperty {
LOCATION,
- TRANSFORM
+ OPACITY,
+ TRANSFORM,
};
// Parameters used when animating the location.
@@ -67,35 +77,31 @@ class COMPOSITOR_EXPORT LayerAnimator : public ui::AnimationDelegate {
int target_y;
};
- // Parameters used whe animating the transform.
+ // Parameters used when animating the transform.
struct TransformParams {
- // TODO: make 4x4 whe Transform is updated.
SkMScalar start[16];
SkMScalar target[16];
};
+ // Parameters used when animating the opacity.
+ struct OpacityParams {
+ float start;
+ float target;
+ };
+
union Params {
LocationParams location;
+ OpacityParams opacity;
TransformParams transform;
};
- // Used for tracking the animation of a particular property.
- struct Element {
- Params params;
- ui::MultiAnimation* animation;
- };
-
- typedef std::map<AnimationProperty, Element> Elements;
+ typedef std::map<AnimationProperty, Params> Elements;
// Stops animating the specified property. This does not set the property
// being animated to its final value.
void StopAnimating(AnimationProperty property);
- // Creates an animation.
- ui::MultiAnimation* CreateAndStartAnimation();
-
- // Returns an iterator into |elements_| that matches the specified animation.
- Elements::iterator GetElementByAnimation(const ui::MultiAnimation* animation);
+ LayerAnimatorDelegate* delegate();
// The layer.
Layer* layer_;
@@ -103,11 +109,7 @@ class COMPOSITOR_EXPORT LayerAnimator : public ui::AnimationDelegate {
// Properties being animated.
Elements elements_;
- // Duration in ms for newly created animations.
- int duration_in_ms_;
-
- // Type of animation for newly created animations.
- ui::Tween::Type animation_type_;
+ scoped_ptr<ui::Animation> animation_;
DISALLOW_COPY_AND_ASSIGN(LayerAnimator);
};

Powered by Google App Engine
This is Rietveld 408576698