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 "SkAnimTimer.h" | 9 #include "SkAnimTimer.h" |
10 #include "SkView.h" | 10 #include "SkView.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 fRec[i].advance(fBounds); | 179 fRec[i].advance(fBounds); |
180 xform[i] = fRec[i].asRSXform(); | 180 xform[i] = fRec[i].asRSXform(); |
181 if (fUseColors) { | 181 if (fUseColors) { |
182 colors[i] = SkColorSetARGB((int)(fRec[i].fAlpha * 0xFF), 0xFF, 0
xFF, 0xFF); | 182 colors[i] = SkColorSetARGB((int)(fRec[i].fAlpha * 0xFF), 0xFF, 0
xFF, 0xFF); |
183 } | 183 } |
184 } | 184 } |
185 SkPaint paint; | 185 SkPaint paint; |
186 paint.setFilterQuality(kLow_SkFilterQuality); | 186 paint.setFilterQuality(kLow_SkFilterQuality); |
187 | 187 |
188 const SkRect cull = this->getBounds(); | 188 const SkRect cull = this->getBounds(); |
189 const SkColor* colorsPtr = fUseColors ? colors : NULL; | 189 const SkColor* colorsPtr = fUseColors ? colors : nullptr; |
190 fProc(canvas, fAtlas, xform, fTex, colorsPtr, N, &cull, &paint); | 190 fProc(canvas, fAtlas, xform, fTex, colorsPtr, N, &cull, &paint); |
191 } | 191 } |
192 | 192 |
193 SkRect onGetBounds() override { | 193 SkRect onGetBounds() override { |
194 const SkScalar border = kMaxScale * kCellSize; | 194 const SkScalar border = kMaxScale * kCellSize; |
195 SkRect r = fBounds; | 195 SkRect r = fBounds; |
196 r.outset(border, border); | 196 r.outset(border, border); |
197 return r; | 197 return r; |
198 } | 198 } |
199 | 199 |
(...skipping 16 matching lines...) Expand all Loading... |
216 | 216 |
217 protected: | 217 protected: |
218 bool onQuery(SkEvent* evt) override { | 218 bool onQuery(SkEvent* evt) override { |
219 if (SampleCode::TitleQ(*evt)) { | 219 if (SampleCode::TitleQ(*evt)) { |
220 SampleCode::TitleR(evt, fName); | 220 SampleCode::TitleR(evt, fName); |
221 return true; | 221 return true; |
222 } | 222 } |
223 SkUnichar uni; | 223 SkUnichar uni; |
224 if (SampleCode::CharQ(*evt, &uni)) { | 224 if (SampleCode::CharQ(*evt, &uni)) { |
225 switch (uni) { | 225 switch (uni) { |
226 case 'C': fDrawable->toggleUseColors(); this->inval(NULL); retur
n true; | 226 case 'C': fDrawable->toggleUseColors(); this->inval(nullptr); re
turn true; |
227 default: break; | 227 default: break; |
228 } | 228 } |
229 } | 229 } |
230 return this->INHERITED::onQuery(evt); | 230 return this->INHERITED::onQuery(evt); |
231 } | 231 } |
232 | 232 |
233 void onDrawContent(SkCanvas* canvas) override { | 233 void onDrawContent(SkCanvas* canvas) override { |
234 canvas->drawDrawable(fDrawable); | 234 canvas->drawDrawable(fDrawable); |
235 this->inval(NULL); | 235 this->inval(nullptr); |
236 } | 236 } |
237 | 237 |
238 #if 0 | 238 #if 0 |
239 // TODO: switch over to use this for our animation | 239 // TODO: switch over to use this for our animation |
240 bool onAnimate(const SkAnimTimer& timer) override { | 240 bool onAnimate(const SkAnimTimer& timer) override { |
241 SkScalar angle = SkDoubleToScalar(fmod(timer.secs() * 360 / 24, 360)); | 241 SkScalar angle = SkDoubleToScalar(fmod(timer.secs() * 360 / 24, 360)); |
242 fAnimatingDrawable->setSweep(angle); | 242 fAnimatingDrawable->setSweep(angle); |
243 return true; | 243 return true; |
244 } | 244 } |
245 #endif | 245 #endif |
246 | 246 |
247 private: | 247 private: |
248 typedef SampleView INHERITED; | 248 typedef SampleView INHERITED; |
249 }; | 249 }; |
250 | 250 |
251 ////////////////////////////////////////////////////////////////////////////// | 251 ////////////////////////////////////////////////////////////////////////////// |
252 | 252 |
253 DEF_SAMPLE( return new DrawAtlasView("DrawAtlas", draw_atlas); ) | 253 DEF_SAMPLE( return new DrawAtlasView("DrawAtlas", draw_atlas); ) |
254 DEF_SAMPLE( return new DrawAtlasView("DrawAtlasSim", draw_atlas_sim); ) | 254 DEF_SAMPLE( return new DrawAtlasView("DrawAtlasSim", draw_atlas_sim); ) |
OLD | NEW |