Update V8 to version 4.7.45.
[chromium-blink-merge.git] / ui / compositor / scoped_layer_animation_settings.h
blobd4de1402d25e73098729005955df0c887458d90b
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_
6 #define UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_
8 #include <set>
10 #include "base/time/time.h"
12 #include "ui/compositor/compositor_export.h"
13 #include "ui/compositor/layer_animator.h"
14 #include "ui/gfx/animation/tween.h"
16 namespace ui {
18 class ImplicitAnimationObserver;
19 class LayerAnimationObserver;
20 class InvertingObserver;
22 // Scoped settings allow you to temporarily change the animator's settings and
23 // these changes are reverted when the object is destroyed. NOTE: when the
24 // settings object is created, it applies the default transition duration
25 // (200ms).
26 class COMPOSITOR_EXPORT ScopedLayerAnimationSettings {
27 public:
28 explicit ScopedLayerAnimationSettings(scoped_refptr<LayerAnimator> animator);
29 virtual ~ScopedLayerAnimationSettings();
31 void AddObserver(ImplicitAnimationObserver* observer);
33 void SetTransitionDuration(base::TimeDelta duration);
34 base::TimeDelta GetTransitionDuration() const;
36 // Locks transition duration in |animator_|. When transition duration
37 // is locked any subsequent changes to it are ignored until the
38 // ScopedLayerAnimationSettings object that has locked the duration goes out
39 // of scope.
40 void LockTransitionDuration();
42 void SetTweenType(gfx::Tween::Type tween_type);
43 gfx::Tween::Type GetTweenType() const;
45 void SetPreemptionStrategy(LayerAnimator::PreemptionStrategy strategy);
46 LayerAnimator::PreemptionStrategy GetPreemptionStrategy() const;
48 // Sets the base layer whose animation will be countered.
49 void SetInverselyAnimatedBaseLayer(Layer* base);
51 // Adds the layer to be counter-animated when a transform animation is
52 // scheduled on the animator_. Must call SetInverselyAnimatedBaseLayer with
53 // the layer associated with animator_ before animating.
54 void AddInverselyAnimatedLayer(Layer* inverse_layer);
56 private:
57 scoped_refptr<LayerAnimator> animator_;
58 bool old_is_transition_duration_locked_;
59 base::TimeDelta old_transition_duration_;
60 gfx::Tween::Type old_tween_type_;
61 LayerAnimator::PreemptionStrategy old_preemption_strategy_;
62 std::set<ImplicitAnimationObserver*> observers_;
63 scoped_ptr<InvertingObserver> inverse_observer_;
65 DISALLOW_COPY_AND_ASSIGN(ScopedLayerAnimationSettings);
68 } // namespace ui
70 #endif // UI_COMPOSITOR_SCOPED_LAYER_ANIMATION_SETTINGS_H_