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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 protected: | 135 protected: |
136 bool onQuery(SkEvent* evt) override { | 136 bool onQuery(SkEvent* evt) override { |
137 if (SampleCode::TitleQ(*evt)) { | 137 if (SampleCode::TitleQ(*evt)) { |
138 SampleCode::TitleR(evt, "ClipDrawMatch"); | 138 SampleCode::TitleR(evt, "ClipDrawMatch"); |
139 return true; | 139 return true; |
140 } | 140 } |
141 SkUnichar uni; | 141 SkUnichar uni; |
142 if (SampleCode::CharQ(*evt, &uni)) { | 142 if (SampleCode::CharQ(*evt, &uni)) { |
143 switch (uni) { | 143 switch (uni) { |
144 case '1': fGeom = kRect_Geometry; this->inval(NULL); return true
; | 144 case '1': fGeom = kRect_Geometry; this->inval(nullptr); return t
rue; |
145 case '2': fGeom = kRRect_Geometry; this->inval(NULL); return tru
e; | 145 case '2': fGeom = kRRect_Geometry; this->inval(nullptr); return
true; |
146 case '3': fGeom = kCircle_Geometry; this->inval(NULL); return tr
ue; | 146 case '3': fGeom = kCircle_Geometry; this->inval(nullptr); return
true; |
147 case '4': fGeom = kConvexPath_Geometry; this->inval(NULL); retur
n true; | 147 case '4': fGeom = kConvexPath_Geometry; this->inval(nullptr); re
turn true; |
148 case '5': fGeom = kConcavePath_Geometry; this->inval(NULL); retu
rn true; | 148 case '5': fGeom = kConcavePath_Geometry; this->inval(nullptr); r
eturn true; |
149 case '6': fGeom = kRectAndRect_Geometry; this->inval(NULL); retu
rn true; | 149 case '6': fGeom = kRectAndRect_Geometry; this->inval(nullptr); r
eturn true; |
150 case '7': fGeom = kRectAndRRect_Geometry; this->inval(NULL); ret
urn true; | 150 case '7': fGeom = kRectAndRRect_Geometry; this->inval(nullptr);
return true; |
151 case '8': fGeom = kRectAndConvex_Geometry; this->inval(NULL); re
turn true; | 151 case '8': fGeom = kRectAndConvex_Geometry; this->inval(nullptr);
return true; |
152 case '9': fGeom = kRectAndConcave_Geometry; this->inval(NULL); r
eturn true; | 152 case '9': fGeom = kRectAndConcave_Geometry; this->inval(nullptr)
; return true; |
153 case 'f': fSign = -fSign; this->inval(NULL); return true; | 153 case 'f': fSign = -fSign; this->inval(nullptr); return true; |
154 case 't': fClipFirst = !fClipFirst; this->inval(NULL); return tr
ue; | 154 case 't': fClipFirst = !fClipFirst; this->inval(nullptr); return
true; |
155 default: break; | 155 default: break; |
156 } | 156 } |
157 } | 157 } |
158 return this->INHERITED::onQuery(evt); | 158 return this->INHERITED::onQuery(evt); |
159 } | 159 } |
160 | 160 |
161 void drawClippedGeom(SkCanvas* canvas, const SkPoint& offset, bool useAA) { | 161 void drawClippedGeom(SkCanvas* canvas, const SkPoint& offset, bool useAA) { |
162 | 162 |
163 int count = canvas->save(); | 163 int count = canvas->save(); |
164 | 164 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 SkScalar trans[2]; | 233 SkScalar trans[2]; |
234 fTrans.timeToValues(SkTime::GetMSecs(), trans); | 234 fTrans.timeToValues(SkTime::GetMSecs(), trans); |
235 | 235 |
236 SkPoint offset; | 236 SkPoint offset; |
237 offset.set(trans[0], trans[1]); | 237 offset.set(trans[0], trans[1]); |
238 | 238 |
239 int saveCount = canvas->save(); | 239 int saveCount = canvas->save(); |
240 this->drawGeometry(canvas, offset, false); | 240 this->drawGeometry(canvas, offset, false); |
241 canvas->restoreToCount(saveCount); | 241 canvas->restoreToCount(saveCount); |
242 | 242 |
243 this->inval(NULL); | 243 this->inval(nullptr); |
244 } | 244 } |
245 | 245 |
246 private: | 246 private: |
247 SkInterpolator fTrans; | 247 SkInterpolator fTrans; |
248 Geometry fGeom; | 248 Geometry fGeom; |
249 bool fClipFirst; | 249 bool fClipFirst; |
250 int fSign; | 250 int fSign; |
251 | 251 |
252 typedef SampleView INHERITED; | 252 typedef SampleView INHERITED; |
253 }; | 253 }; |
254 | 254 |
255 ////////////////////////////////////////////////////////////////////////////// | 255 ////////////////////////////////////////////////////////////////////////////// |
256 | 256 |
257 static SkView* MyFactory() { return new ClipDrawMatchView; } | 257 static SkView* MyFactory() { return new ClipDrawMatchView; } |
258 static SkViewRegister reg(MyFactory); | 258 static SkViewRegister reg(MyFactory); |
OLD | NEW |