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

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

Issue 8247009: Explicit animation support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix VS2010 Created 9 years, 2 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
« no previous file with comments | « ui/gfx/compositor/layer_animation_delegate.h ('k') | ui/gfx/compositor/layer_animation_element.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/compositor/layer_animation_element.h
diff --git a/ui/gfx/compositor/layer_animation_element.h b/ui/gfx/compositor/layer_animation_element.h
new file mode 100644
index 0000000000000000000000000000000000000000..12697b0531ea6d67330daba8d9c1fa64b394fdb0
--- /dev/null
+++ b/ui/gfx/compositor/layer_animation_element.h
@@ -0,0 +1,97 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
+#define UI_GFX_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
+#pragma once
+
+#include <set>
+
+#include "base/time.h"
+#include "ui/gfx/compositor/compositor_export.h"
+
+namespace gfx {
+class Rect;
+} // gfx
+
+namespace ui {
+
+class LayerAnimationDelegate;
+class Transform;
+
+// LayerAnimationElements represent one segment of an animation between two
+// keyframes. They know how to update a LayerAnimationDelegate given a value
+// between 0 and 1 (0 for initial, and 1 for final).
+class COMPOSITOR_EXPORT LayerAnimationElement {
+ public:
+ enum AnimatableProperty {
+ TRANSFORM = 0,
+ BOUNDS,
+ OPACITY
+ };
+
+ typedef std::set<AnimatableProperty> AnimatableProperties;
+
+ LayerAnimationElement(const AnimatableProperties& properties,
+ base::TimeDelta duration);
+ virtual ~LayerAnimationElement();
+
+ // Creates an element that transitions to the given transform. The caller owns
+ // the return value.
+ static LayerAnimationElement* CreateTransformElement(
+ const Transform& transform,
+ base::TimeDelta duration);
+
+ // Creates an element that transitions to the given bounds. The caller owns
+ // the return value.
+ static LayerAnimationElement* CreateBoundsElement(
+ const gfx::Rect& bounds,
+ base::TimeDelta duration);
+
+ // Creates an element that transitions to the given opacity. The caller owns
+ // the return value.
+ static LayerAnimationElement* CreateOpacityElement(
+ float opacity,
+ base::TimeDelta duration);
+
+ // Creates an element that pauses the given properties. The caller owns the
+ // return value.
+ static LayerAnimationElement* CreatePauseElement(
+ const AnimatableProperties& properties,
+ base::TimeDelta duration);
+
+ // Updates the delegate to the appropriate value for |t|, which is in the
+ // range [0, 1] (0 for initial, and 1 for final). If the animation is not
+ // aborted, it is guaranteed that Progress will eventually be called with
+ // t = 1.0.
+ void Progress(double t, LayerAnimationDelegate* delegate);
+
+ // Called if the animation is not allowed to complete. This may be called
+ // before OnStarted or Progress.
+ void Abort();
+
+ // The properties that the element modifies.
+ const AnimatableProperties& properties() const { return properties_; }
+
+ // The duration of the animation
+ base::TimeDelta duration() const { return duration_; }
+
+ protected:
+ // Called once each time the animation element is run before any call to
+ // OnProgress.
+ virtual void OnStart(LayerAnimationDelegate* delegate) = 0;
+ virtual void OnProgress(double t, LayerAnimationDelegate* delegate) = 0;
+ virtual void OnAbort() = 0;
+
+ private:
+ bool first_frame_;
+ const AnimatableProperties properties_;
+ const base::TimeDelta duration_;
+
+ DISALLOW_COPY_AND_ASSIGN(LayerAnimationElement);
+};
+
+} // namespace ui
+
+#endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
« no previous file with comments | « ui/gfx/compositor/layer_animation_delegate.h ('k') | ui/gfx/compositor/layer_animation_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698