OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_INPUT_PAGE_SCALE_ANIMATION_H_ | 5 #ifndef CC_INPUT_PAGE_SCALE_ANIMATION_H_ |
6 #define CC_INPUT_PAGE_SCALE_ANIMATION_H_ | 6 #define CC_INPUT_PAGE_SCALE_ANIMATION_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
11 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
12 #include "ui/gfx/geometry/size_f.h" | 13 #include "ui/gfx/geometry/size_f.h" |
13 #include "ui/gfx/geometry/vector2d.h" | 14 #include "ui/gfx/geometry/vector2d.h" |
14 #include "ui/gfx/geometry/vector2d_f.h" | 15 #include "ui/gfx/geometry/vector2d_f.h" |
15 | 16 |
16 namespace cc { | 17 namespace cc { |
17 | 18 |
18 class TimingFunction; | 19 class TimingFunction; |
19 | 20 |
(...skipping 19 matching lines...) Expand all Loading... |
39 // double-tap zoom. Initialize it with starting and ending scroll/page scale | 40 // double-tap zoom. Initialize it with starting and ending scroll/page scale |
40 // positions and an animation length time, then call ...AtTime() at every frame | 41 // positions and an animation length time, then call ...AtTime() at every frame |
41 // to obtain the current interpolated position. The supplied timing function | 42 // to obtain the current interpolated position. The supplied timing function |
42 // is used to ease the animation. | 43 // is used to ease the animation. |
43 // | 44 // |
44 // All sizes and vectors in this class's public methods are in the root scroll | 45 // All sizes and vectors in this class's public methods are in the root scroll |
45 // layer's coordinate space. | 46 // layer's coordinate space. |
46 class CC_EXPORT PageScaleAnimation { | 47 class CC_EXPORT PageScaleAnimation { |
47 public: | 48 public: |
48 // Construct with the state at the beginning of the animation. | 49 // Construct with the state at the beginning of the animation. |
49 static scoped_ptr<PageScaleAnimation> Create( | 50 static std::unique_ptr<PageScaleAnimation> Create( |
50 const gfx::Vector2dF& start_scroll_offset, | 51 const gfx::Vector2dF& start_scroll_offset, |
51 float start_page_scale_factor, | 52 float start_page_scale_factor, |
52 const gfx::SizeF& viewport_size, | 53 const gfx::SizeF& viewport_size, |
53 const gfx::SizeF& root_layer_size, | 54 const gfx::SizeF& root_layer_size, |
54 scoped_ptr<TimingFunction> timing_function); | 55 std::unique_ptr<TimingFunction> timing_function); |
55 | 56 |
56 ~PageScaleAnimation(); | 57 ~PageScaleAnimation(); |
57 | 58 |
58 // The following methods initialize the animation. Call one of them | 59 // The following methods initialize the animation. Call one of them |
59 // immediately after construction to set the final scroll and page scale. | 60 // immediately after construction to set the final scroll and page scale. |
60 | 61 |
61 // Zoom while explicitly specifying the top-left scroll position. | 62 // Zoom while explicitly specifying the top-left scroll position. |
62 void ZoomTo(const gfx::Vector2dF& target_scroll_offset, | 63 void ZoomTo(const gfx::Vector2dF& target_scroll_offset, |
63 float target_page_scale_factor, | 64 float target_page_scale_factor, |
64 double duration); | 65 double duration); |
(...skipping 23 matching lines...) Expand all Loading... |
88 base::TimeDelta duration() const { return duration_; } | 89 base::TimeDelta duration() const { return duration_; } |
89 base::TimeTicks end_time() const { return start_time_ + duration_; } | 90 base::TimeTicks end_time() const { return start_time_ + duration_; } |
90 gfx::Vector2dF target_scroll_offset() const { return target_scroll_offset_; } | 91 gfx::Vector2dF target_scroll_offset() const { return target_scroll_offset_; } |
91 float target_page_scale_factor() const { return target_page_scale_factor_; } | 92 float target_page_scale_factor() const { return target_page_scale_factor_; } |
92 | 93 |
93 protected: | 94 protected: |
94 PageScaleAnimation(const gfx::Vector2dF& start_scroll_offset, | 95 PageScaleAnimation(const gfx::Vector2dF& start_scroll_offset, |
95 float start_page_scale_factor, | 96 float start_page_scale_factor, |
96 const gfx::SizeF& viewport_size, | 97 const gfx::SizeF& viewport_size, |
97 const gfx::SizeF& root_layer_size, | 98 const gfx::SizeF& root_layer_size, |
98 scoped_ptr<TimingFunction> timing_function); | 99 std::unique_ptr<TimingFunction> timing_function); |
99 | 100 |
100 private: | 101 private: |
101 void ClampTargetScrollOffset(); | 102 void ClampTargetScrollOffset(); |
102 void InferTargetScrollOffsetFromStartAnchor(); | 103 void InferTargetScrollOffsetFromStartAnchor(); |
103 void InferTargetAnchorFromScrollOffsets(); | 104 void InferTargetAnchorFromScrollOffsets(); |
104 | 105 |
105 gfx::SizeF StartViewportSize() const; | 106 gfx::SizeF StartViewportSize() const; |
106 gfx::SizeF TargetViewportSize() const; | 107 gfx::SizeF TargetViewportSize() const; |
107 float InterpAtTime(base::TimeTicks time) const; | 108 float InterpAtTime(base::TimeTicks time) const; |
108 gfx::SizeF ViewportSizeAt(float interp) const; | 109 gfx::SizeF ViewportSizeAt(float interp) const; |
109 gfx::Vector2dF ScrollOffsetAt(float interp) const; | 110 gfx::Vector2dF ScrollOffsetAt(float interp) const; |
110 gfx::Vector2dF AnchorAt(float interp) const; | 111 gfx::Vector2dF AnchorAt(float interp) const; |
111 gfx::Vector2dF ViewportRelativeAnchorAt(float interp) const; | 112 gfx::Vector2dF ViewportRelativeAnchorAt(float interp) const; |
112 float PageScaleFactorAt(float interp) const; | 113 float PageScaleFactorAt(float interp) const; |
113 | 114 |
114 float start_page_scale_factor_; | 115 float start_page_scale_factor_; |
115 float target_page_scale_factor_; | 116 float target_page_scale_factor_; |
116 gfx::Vector2dF start_scroll_offset_; | 117 gfx::Vector2dF start_scroll_offset_; |
117 gfx::Vector2dF target_scroll_offset_; | 118 gfx::Vector2dF target_scroll_offset_; |
118 | 119 |
119 gfx::Vector2dF start_anchor_; | 120 gfx::Vector2dF start_anchor_; |
120 gfx::Vector2dF target_anchor_; | 121 gfx::Vector2dF target_anchor_; |
121 | 122 |
122 gfx::SizeF viewport_size_; | 123 gfx::SizeF viewport_size_; |
123 gfx::SizeF root_layer_size_; | 124 gfx::SizeF root_layer_size_; |
124 | 125 |
125 base::TimeTicks start_time_; | 126 base::TimeTicks start_time_; |
126 base::TimeDelta duration_; | 127 base::TimeDelta duration_; |
127 | 128 |
128 scoped_ptr<TimingFunction> timing_function_; | 129 std::unique_ptr<TimingFunction> timing_function_; |
129 | 130 |
130 DISALLOW_COPY_AND_ASSIGN(PageScaleAnimation); | 131 DISALLOW_COPY_AND_ASSIGN(PageScaleAnimation); |
131 }; | 132 }; |
132 | 133 |
133 } // namespace cc | 134 } // namespace cc |
134 | 135 |
135 #endif // CC_INPUT_PAGE_SCALE_ANIMATION_H_ | 136 #endif // CC_INPUT_PAGE_SCALE_ANIMATION_H_ |
OLD | NEW |