OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkInterpolator.h" | 10 #include "SkInterpolator.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 fTrans.setKeyFrame(1, SkTime::GetMSecs() + 2000, values); | 124 fTrans.setKeyFrame(1, SkTime::GetMSecs() + 2000, values); |
125 values[0] = values[1] = 1; | 125 values[0] = values[1] = 1; |
126 fTrans.setKeyFrame(2, SkTime::GetMSecs() + 3000, values); | 126 fTrans.setKeyFrame(2, SkTime::GetMSecs() + 3000, values); |
127 values[1] = 0; | 127 values[1] = 0; |
128 fTrans.setKeyFrame(3, SkTime::GetMSecs() + 4000, values); | 128 fTrans.setKeyFrame(3, SkTime::GetMSecs() + 4000, values); |
129 values[0] = 0; | 129 values[0] = 0; |
130 fTrans.setKeyFrame(4, SkTime::GetMSecs() + 5000, values); | 130 fTrans.setKeyFrame(4, SkTime::GetMSecs() + 5000, values); |
131 } | 131 } |
132 | 132 |
133 protected: | 133 protected: |
134 bool onQuery(SkEvent* evt) SK_OVERRIDE { | 134 bool onQuery(SkEvent* evt) override { |
135 if (SampleCode::TitleQ(*evt)) { | 135 if (SampleCode::TitleQ(*evt)) { |
136 SampleCode::TitleR(evt, "ClipDrawMatch"); | 136 SampleCode::TitleR(evt, "ClipDrawMatch"); |
137 return true; | 137 return true; |
138 } | 138 } |
139 SkUnichar uni; | 139 SkUnichar uni; |
140 if (SampleCode::CharQ(*evt, &uni)) { | 140 if (SampleCode::CharQ(*evt, &uni)) { |
141 switch (uni) { | 141 switch (uni) { |
142 case '1': fGeom = kRect_Geometry; this->inval(NULL); return true
; | 142 case '1': fGeom = kRect_Geometry; this->inval(NULL); return true
; |
143 case '2': fGeom = kRRect_Geometry; this->inval(NULL); return tru
e; | 143 case '2': fGeom = kRRect_Geometry; this->inval(NULL); return tru
e; |
144 case '3': fGeom = kCircle_Geometry; this->inval(NULL); return tr
ue; | 144 case '3': fGeom = kCircle_Geometry; this->inval(NULL); return tr
ue; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 this->drawClippedGeom(canvas, offset, useAA); | 220 this->drawClippedGeom(canvas, offset, useAA); |
221 } | 221 } |
222 | 222 |
223 draw_normal_geom(canvas, offset, fGeom, useAA); | 223 draw_normal_geom(canvas, offset, fGeom, useAA); |
224 | 224 |
225 if (!fClipFirst) { | 225 if (!fClipFirst) { |
226 this->drawClippedGeom(canvas, offset, useAA); | 226 this->drawClippedGeom(canvas, offset, useAA); |
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 230 void onDrawContent(SkCanvas* canvas) override { |
231 SkScalar trans[2]; | 231 SkScalar trans[2]; |
232 fTrans.timeToValues(SkTime::GetMSecs(), trans); | 232 fTrans.timeToValues(SkTime::GetMSecs(), trans); |
233 | 233 |
234 SkPoint offset; | 234 SkPoint offset; |
235 offset.set(trans[0], trans[1]); | 235 offset.set(trans[0], trans[1]); |
236 | 236 |
237 int saveCount = canvas->save(); | 237 int saveCount = canvas->save(); |
238 this->drawGeometry(canvas, offset, false); | 238 this->drawGeometry(canvas, offset, false); |
239 canvas->restoreToCount(saveCount); | 239 canvas->restoreToCount(saveCount); |
240 | 240 |
241 this->inval(NULL); | 241 this->inval(NULL); |
242 } | 242 } |
243 | 243 |
244 private: | 244 private: |
245 SkInterpolator fTrans; | 245 SkInterpolator fTrans; |
246 Geometry fGeom; | 246 Geometry fGeom; |
247 bool fClipFirst; | 247 bool fClipFirst; |
248 int fSign; | 248 int fSign; |
249 | 249 |
250 typedef SampleView INHERITED; | 250 typedef SampleView INHERITED; |
251 }; | 251 }; |
252 | 252 |
253 ////////////////////////////////////////////////////////////////////////////// | 253 ////////////////////////////////////////////////////////////////////////////// |
254 | 254 |
255 static SkView* MyFactory() { return new ClipDrawMatchView; } | 255 static SkView* MyFactory() { return new ClipDrawMatchView; } |
256 static SkViewRegister reg(MyFactory); | 256 static SkViewRegister reg(MyFactory); |
OLD | NEW |