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

Unified Diff: ui/gfx/compositor/layer.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.h
diff --git a/ui/gfx/compositor/layer.h b/ui/gfx/compositor/layer.h
index 865a427ddcbcc252273804e1bb8419390eca7a75..9c401fb5788baae755804d83b2ea641d3e5259a6 100644
--- a/ui/gfx/compositor/layer.h
+++ b/ui/gfx/compositor/layer.h
@@ -8,18 +8,23 @@
#include <vector>
+#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/transform.h"
#include "ui/gfx/compositor/compositor.h"
+#include "ui/gfx/compositor/layer_animator_delegate.h"
#include "ui/gfx/compositor/layer_delegate.h"
class SkCanvas;
namespace ui {
+class Animation;
class Compositor;
+class LayerAnimator;
class Texture;
// Layer manages a texture, transform and a set of child Layers. Any View that
@@ -30,7 +35,7 @@ class Texture;
// NOTE: unlike Views, each Layer does *not* own its children views. If you
// delete a Layer and it has children, the parent of each child layer is set to
// NULL, but the children are not deleted.
-class COMPOSITOR_EXPORT Layer {
+class COMPOSITOR_EXPORT Layer : public LayerAnimatorDelegate {
public:
enum TextureParam {
LAYER_HAS_NO_TEXTURE = 0,
@@ -60,6 +65,15 @@ class COMPOSITOR_EXPORT Layer {
// Returns true if this Layer contains |other| somewhere in its children.
bool Contains(const Layer* other) const;
+ // Sets the animation to use for changes to opacity, position or transform.
+ // That is, if you invoke this with non-NULL |animation| is started and any
+ // changes to opacity, position or transform are animated between the current
+ // value and target value. If the current animation is NULL or completed,
+ // changes are immediate.
+ // Layer takes ownership of |animation| and installs it's own delegate on the
+ // animation.
+ void SetAnimation(Animation* animation);
+
// The transform, relative to the parent.
void SetTransform(const ui::Transform& transform);
const ui::Transform& transform() const { return transform_; }
@@ -68,6 +82,9 @@ class COMPOSITOR_EXPORT Layer {
void SetBounds(const gfx::Rect& bounds);
const gfx::Rect& bounds() const { return bounds_; }
+ float opacity() const { return opacity_; }
+ void SetOpacity(float opacity);
+
// Sets |visible_|. The Layer is drawn by Draw() only when visible_ is true.
bool visible() const { return visible_; }
void set_visible(bool visible) { visible_ = visible; }
@@ -136,9 +153,6 @@ class COMPOSITOR_EXPORT Layer {
// (e.g. the GPU process on TOUCH_UI).
bool layer_updated_externally() const { return layer_updated_externally_; }
- float opacity() const { return opacity_; }
- void SetOpacity(float alpha);
-
private:
// TODO(vollick): Eventually, if a non-leaf node has an opacity of less than
// 1.0, we'll render to a separate texture, and then apply the alpha.
@@ -174,6 +188,17 @@ class COMPOSITOR_EXPORT Layer {
// should have valid alpha.
bool has_valid_alpha_channel() const { return !layer_updated_externally_; }
+ // Following are invoked from the animation or if no animation exists to
+ // update the values immediately.
+ void SetBoundsImmediately(const gfx::Rect& bounds);
+ void SetTransformImmediately(const ui::Transform& transform);
+ void SetOpacityImmediately(float opacity);
+
+ // LayerAnimatorDelegate overrides:
+ virtual void SetBoundsFromAnimator(const gfx::Rect& bounds) OVERRIDE;
+ virtual void SetTransformFromAnimator(const Transform& transform) OVERRIDE;
+ virtual void SetOpacityFromAnimator(float opacity) OVERRIDE;
+
Compositor* compositor_;
scoped_refptr<ui::Texture> texture_;
@@ -204,6 +229,8 @@ class COMPOSITOR_EXPORT Layer {
LayerDelegate* delegate_;
+ scoped_ptr<LayerAnimator> animator_;
+
DISALLOW_COPY_AND_ASSIGN(Layer);
};

Powered by Google App Engine
This is Rietveld 408576698