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

Side by Side Diff: cc/page_scale_animation.h

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CCPageScaleAnimation_h 5 #ifndef CCPageScaleAnimation_h
6 #define CCPageScaleAnimation_h 6 #define CCPageScaleAnimation_h
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "IntSize.h" 9 #include "IntSize.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 // A small helper class that does the math for zoom animations, primarily for 13 // A small helper class that does the math for zoom animations, primarily for
14 // double-tap zoom. Initialize it with starting and ending scroll/page scale 14 // double-tap zoom. Initialize it with starting and ending scroll/page scale
15 // positions and an animation length time, then call ...AtTime() at every frame 15 // positions and an animation length time, then call ...AtTime() at every frame
16 // to obtain the current interpolated position. 16 // to obtain the current interpolated position.
17 class CCPageScaleAnimation { 17 class PageScaleAnimation {
18 public: 18 public:
19 // Construct with the starting page scale and scroll offset (which is in 19 // Construct with the starting page scale and scroll offset (which is in
20 // pageScaleStart space). The window size is the user-viewable area 20 // pageScaleStart space). The window size is the user-viewable area
21 // in pixels. 21 // in pixels.
22 static scoped_ptr<CCPageScaleAnimation> create(const IntSize& scrollStart, f loat pageScaleStart, const IntSize& windowSize, const IntSize& contentSize, doub le startTime); 22 static scoped_ptr<PageScaleAnimation> create(const IntSize& scrollStart, flo at pageScaleStart, const IntSize& windowSize, const IntSize& contentSize, double startTime);
23 23
24 // The following methods initialize the animation. Call one of them 24 // The following methods initialize the animation. Call one of them
25 // immediately after construction to set the final scroll and page scale. 25 // immediately after construction to set the final scroll and page scale.
26 26
27 // Zoom while explicitly specifying the top-left scroll position. The 27 // Zoom while explicitly specifying the top-left scroll position. The
28 // scroll offset is in finalPageScale coordinates. 28 // scroll offset is in finalPageScale coordinates.
29 void zoomTo(const IntSize& finalScroll, float finalPageScale, double duratio n); 29 void zoomTo(const IntSize& finalScroll, float finalPageScale, double duratio n);
30 30
31 // Zoom based on a specified onscreen anchor, which will remain at the same 31 // Zoom based on a specified onscreen anchor, which will remain at the same
32 // position on the screen throughout the animation. The anchor is in local 32 // position on the screen throughout the animation. The anchor is in local
33 // space relative to scrollStart. 33 // space relative to scrollStart.
34 void zoomWithAnchor(const IntSize& anchor, float finalPageScale, double dura tion); 34 void zoomWithAnchor(const IntSize& anchor, float finalPageScale, double dura tion);
35 35
36 // Call these functions while the animation is in progress to output the 36 // Call these functions while the animation is in progress to output the
37 // current state. 37 // current state.
38 IntSize scrollOffsetAtTime(double time) const; 38 IntSize scrollOffsetAtTime(double time) const;
39 float pageScaleAtTime(double time) const; 39 float pageScaleAtTime(double time) const;
40 bool isAnimationCompleteAtTime(double time) const; 40 bool isAnimationCompleteAtTime(double time) const;
41 41
42 // The following methods return state which is invariant throughout the 42 // The following methods return state which is invariant throughout the
43 // course of the animation. 43 // course of the animation.
44 double startTime() const { return m_startTime; } 44 double startTime() const { return m_startTime; }
45 double duration() const { return m_duration; } 45 double duration() const { return m_duration; }
46 double endTime() const { return m_startTime + m_duration; } 46 double endTime() const { return m_startTime + m_duration; }
47 const IntSize& finalScrollOffset() const { return m_scrollEnd; } 47 const IntSize& finalScrollOffset() const { return m_scrollEnd; }
48 float finalPageScale() const { return m_pageScaleEnd; } 48 float finalPageScale() const { return m_pageScaleEnd; }
49 49
50 protected: 50 protected:
51 CCPageScaleAnimation(const IntSize& scrollStart, float pageScaleStart, const IntSize& windowSize, const IntSize& contentSize, double startTime); 51 PageScaleAnimation(const IntSize& scrollStart, float pageScaleStart, const I ntSize& windowSize, const IntSize& contentSize, double startTime);
52 52
53 private: 53 private:
54 float progressRatioForTime(double time) const; 54 float progressRatioForTime(double time) const;
55 IntSize scrollOffsetAtRatio(float ratio) const; 55 IntSize scrollOffsetAtRatio(float ratio) const;
56 float pageScaleAtRatio(float ratio) const; 56 float pageScaleAtRatio(float ratio) const;
57 57
58 IntSize m_scrollStart; 58 IntSize m_scrollStart;
59 float m_pageScaleStart; 59 float m_pageScaleStart;
60 IntSize m_windowSize; 60 IntSize m_windowSize;
61 IntSize m_contentSize; 61 IntSize m_contentSize;
62 62
63 bool m_anchorMode; 63 bool m_anchorMode;
64 IntSize m_anchor; 64 IntSize m_anchor;
65 IntSize m_scrollEnd; 65 IntSize m_scrollEnd;
66 float m_pageScaleEnd; 66 float m_pageScaleEnd;
67 67
68 double m_startTime; 68 double m_startTime;
69 double m_duration; 69 double m_duration;
70 }; 70 };
71 71
72 } // namespace cc 72 } // namespace cc
73 73
74 #endif 74 #endif
OLDNEW
« cc/active_animation.h ('K') | « cc/overdraw_metrics.cc ('k') | cc/page_scale_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698