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

Side by Side Diff: samplecode/SampleCode.h

Issue 888283002: allow GMs to animate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: switch all existing animations to use animatePulse Created 5 years, 10 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
« no previous file with comments | « samplecode/SampleCamera.cpp ('k') | samplecode/SampleDegenerateTwoPtRadials.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SampleCode_DEFINED 10 #ifndef SampleCode_DEFINED
(...skipping 18 matching lines...) Expand all
29 29
30 static bool TitleQ(const SkEvent&); 30 static bool TitleQ(const SkEvent&);
31 static void TitleR(SkEvent*, const char title[]); 31 static void TitleR(SkEvent*, const char title[]);
32 static bool RequestTitle(SkView* view, SkString* title); 32 static bool RequestTitle(SkView* view, SkString* title);
33 33
34 static bool PrefSizeQ(const SkEvent&); 34 static bool PrefSizeQ(const SkEvent&);
35 static void PrefSizeR(SkEvent*, SkScalar width, SkScalar height); 35 static void PrefSizeR(SkEvent*, SkScalar width, SkScalar height);
36 36
37 static bool FastTextQ(const SkEvent&); 37 static bool FastTextQ(const SkEvent&);
38 38
39 private:
39 static SkMSec GetAnimTime(); 40 static SkMSec GetAnimTime();
40 static SkMSec GetAnimTimeDelta(); 41 static SkMSec GetAnimTimeDelta();
41 static SkScalar GetAnimSecondsDelta(); 42 static SkScalar GetAnimSecondsDelta();
42 static SkScalar GetAnimScalar(SkScalar speedPerSec, SkScalar period = 0); 43 static SkScalar GetAnimScalar(SkScalar speedPerSec, SkScalar period = 0);
43 // gives a sinusoidal value between 0 and amplitude 44 // gives a sinusoidal value between 0 and amplitude
44 static SkScalar GetAnimSinScalar(SkScalar amplitude, 45 static SkScalar GetAnimSinScalar(SkScalar amplitude,
45 SkScalar periodInSec, 46 SkScalar periodInSec,
46 SkScalar phaseInSec = 0); 47 SkScalar phaseInSec = 0);
48
49 friend class SampleWindow;
47 }; 50 };
48 51
49 ////////////////////////////////////////////////////////////////////////////// 52 //////////////////////////////////////////////////////////////////////////////
50 53
51 // interface that constructs SkViews 54 // interface that constructs SkViews
52 class SkViewFactory : public SkRefCnt { 55 class SkViewFactory : public SkRefCnt {
53 public: 56 public:
54 virtual SkView* operator() () const = 0; 57 virtual SkView* operator() () const = 0;
55 }; 58 };
56 59
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 113
111 class SampleView : public SkView { 114 class SampleView : public SkView {
112 public: 115 public:
113 SampleView() 116 SampleView()
114 : fPipeState(SkOSMenu::kOffState) 117 : fPipeState(SkOSMenu::kOffState)
115 , fBGColor(SK_ColorWHITE) 118 , fBGColor(SK_ColorWHITE)
116 , fRepeatCount(1) 119 , fRepeatCount(1)
117 {} 120 {}
118 121
119 void setBGColor(SkColor color) { fBGColor = color; } 122 void setBGColor(SkColor color) { fBGColor = color; }
123 bool animatePulse(SkMSec curr, SkMSec prev) { return this->onAnimatePulse(cu rr, prev); }
120 124
121 static bool IsSampleView(SkView*); 125 static bool IsSampleView(SkView*);
122 static bool SetRepeatDraw(SkView*, int count); 126 static bool SetRepeatDraw(SkView*, int count);
123 static bool SetUsePipe(SkView*, SkOSMenu::TriState); 127 static bool SetUsePipe(SkView*, SkOSMenu::TriState);
124 128
125 /** 129 /**
126 * Call this to request menu items from a SampleView. 130 * Call this to request menu items from a SampleView.
127 * Subclassing notes: A subclass of SampleView can overwrite this method 131 * Subclassing notes: A subclass of SampleView can overwrite this method
128 * to add new items of various types to the menu and change its title. 132 * to add new items of various types to the menu and change its title.
129 * The events attached to any new menu items must be handled in its onEvent 133 * The events attached to any new menu items must be handled in its onEvent
130 * method. See SkOSMenu.h for helper functions. 134 * method. See SkOSMenu.h for helper functions.
131 */ 135 */
132 virtual void requestMenu(SkOSMenu* menu) {} 136 virtual void requestMenu(SkOSMenu* menu) {}
133 137
134 virtual void onTileSizeChanged(const SkSize& tileSize) {} 138 virtual void onTileSizeChanged(const SkSize& tileSize) {}
135 139
136 protected: 140 protected:
137 virtual void onDrawBackground(SkCanvas*); 141 virtual void onDrawBackground(SkCanvas*);
138 virtual void onDrawContent(SkCanvas*) = 0; 142 virtual void onDrawContent(SkCanvas*) = 0;
143 virtual bool onAnimatePulse(SkMSec curr, SkMSec prev) { return false; }
139 144
140 // overrides 145 // overrides
141 virtual bool onEvent(const SkEvent& evt); 146 virtual bool onEvent(const SkEvent& evt);
142 virtual bool onQuery(SkEvent* evt); 147 virtual bool onQuery(SkEvent* evt);
143 virtual void draw(SkCanvas*); 148 virtual void draw(SkCanvas*);
144 virtual void onDraw(SkCanvas*); 149 virtual void onDraw(SkCanvas*);
145 150
146 SkOSMenu::TriState fPipeState; 151 SkOSMenu::TriState fPipeState;
147 SkColor fBGColor; 152 SkColor fBGColor;
148 153
149 private: 154 private:
150 int fRepeatCount; 155 int fRepeatCount;
151 156
152 typedef SkView INHERITED; 157 typedef SkView INHERITED;
153 }; 158 };
154 159
155 #endif 160 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleCamera.cpp ('k') | samplecode/SampleDegenerateTwoPtRadials.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698