Chromium Code Reviews| 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..fd27c5ffc1db09e9cad6e857c86ef13778da590e |
| --- /dev/null |
| +++ b/ui/gfx/compositor/layer_animation_element.h |
| @@ -0,0 +1,67 @@ |
| +// 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/memory/ref_counted.h" |
| +#include "base/time.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 the last keyframe, and one for the next). |
| +class LayerAnimationElement : public base::RefCounted<LayerAnimationElement> { |
|
sky
2011/10/14 16:39:52
Can we make the ownership model trivial and have t
|
| + public: |
| + enum AnimatableProperty { |
| + TRANSFORM = 0, |
| + BOUNDS, |
| + OPACITY |
| + }; |
| + |
| + typedef std::set<AnimatableProperty> AnimatableProperties; |
| + |
| + static LayerAnimationElement* CreateTransformElement( |
| + const Transform& transform, base::TimeDelta duration); |
|
sky
2011/10/14 16:39:52
wrap each param.
|
| + static LayerAnimationElement* CreateBoundsElement( |
| + const gfx::Rect& bounds, base::TimeDelta duration); |
| + static LayerAnimationElement* CreateOpacityElement( |
| + float opacity, base::TimeDelta duration); |
| + static LayerAnimationElement* CreatePauseElement( |
| + AnimatableProperty property, base::TimeDelta duration); |
| + |
| + // Updates the delegate to the appropriate value for |t|, which is in the |
| + // range [0, 1] where 0 represents the last keyframe and 1 represents the |
| + // next. If the animation is not aborted, it is guaranteed that animate will |
|
sky
2011/10/14 16:39:52
animate -> progress
|
| + // eventually be called with t = 1.0. |
| + virtual void Progress(double t, LayerAnimationDelegate* delegate) = 0; |
|
sky
2011/10/14 16:39:52
I think this should be time based, otherwise we co
|
| + |
| + // Called if the animation is not allowed to complete. |
| + virtual void Abort() = 0; |
| + |
| + // The properties that the element modifies. |
| + virtual const AnimatableProperties& Properties() const = 0; |
|
sky
2011/10/14 16:39:52
Can you think of a case where the properties or du
|
| + |
| + // The duration of the animation |
| + virtual base::TimeDelta Duration() const = 0; |
| + |
| + protected: |
| + friend class base::RefCounted<LayerAnimationElement>; |
| + virtual ~LayerAnimationElement() {} |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ |