| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 SkString str; | 190 SkString str; |
| 191 str.printf("Hair-%s", gProcs[fProcIndex].fName); | 191 str.printf("Hair-%s", gProcs[fProcIndex].fName); |
| 192 SampleCode::TitleR(evt, str.c_str()); | 192 SampleCode::TitleR(evt, str.c_str()); |
| 193 return true; | 193 return true; |
| 194 } | 194 } |
| 195 return this->INHERITED::onQuery(evt); | 195 return this->INHERITED::onQuery(evt); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void show_bitmaps(SkCanvas* canvas, const SkBitmap& b0, const SkBitmap& b1, | 198 void show_bitmaps(SkCanvas* canvas, const SkBitmap& b0, const SkBitmap& b1, |
| 199 const SkIRect& inset) { | 199 const SkIRect& inset) { |
| 200 canvas->drawBitmap(b0, 0, 0, NULL); | 200 canvas->drawBitmap(b0, 0, 0, nullptr); |
| 201 canvas->drawBitmap(b1, SkIntToScalar(b0.width()), 0, NULL); | 201 canvas->drawBitmap(b1, SkIntToScalar(b0.width()), 0, nullptr); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void onDrawContent(SkCanvas* canvas) override { | 204 void onDrawContent(SkCanvas* canvas) override { |
| 205 gRand.setSeed(fNow); | 205 gRand.setSeed(fNow); |
| 206 | 206 |
| 207 SkBitmap bm, bm2; | 207 SkBitmap bm, bm2; |
| 208 bm.allocN32Pixels(WIDTH + MARGIN*2, HEIGHT + MARGIN*2); | 208 bm.allocN32Pixels(WIDTH + MARGIN*2, HEIGHT + MARGIN*2); |
| 209 // this will erase our margin, which we want to always stay 0 | 209 // this will erase our margin, which we want to always stay 0 |
| 210 bm.eraseColor(SK_ColorTRANSPARENT); | 210 bm.eraseColor(SK_ColorTRANSPARENT); |
| 211 | 211 |
| 212 bm2.installPixels(SkImageInfo::MakeN32Premul(WIDTH, HEIGHT), | 212 bm2.installPixels(SkImageInfo::MakeN32Premul(WIDTH, HEIGHT), |
| 213 bm.getAddr32(MARGIN, MARGIN), bm.rowBytes()); | 213 bm.getAddr32(MARGIN, MARGIN), bm.rowBytes()); |
| 214 | 214 |
| 215 SkCanvas c2(bm2); | 215 SkCanvas c2(bm2); |
| 216 SkPaint paint; | 216 SkPaint paint; |
| 217 paint.setAntiAlias(fDoAA); | 217 paint.setAntiAlias(fDoAA); |
| 218 paint.setStyle(SkPaint::kStroke_Style); | 218 paint.setStyle(SkPaint::kStroke_Style); |
| 219 | 219 |
| 220 bm2.eraseColor(SK_ColorTRANSPARENT); | 220 bm2.eraseColor(SK_ColorTRANSPARENT); |
| 221 gProcs[fProcIndex].fProc(&c2, paint, bm); | 221 gProcs[fProcIndex].fProc(&c2, paint, bm); |
| 222 canvas->drawBitmap(bm2, SkIntToScalar(10), SkIntToScalar(10), NULL); | 222 canvas->drawBitmap(bm2, SkIntToScalar(10), SkIntToScalar(10), nullptr); |
| 223 } | 223 } |
| 224 | 224 |
| 225 bool onAnimate(const SkAnimTimer&) override { | 225 bool onAnimate(const SkAnimTimer&) override { |
| 226 if (fDoAA) { | 226 if (fDoAA) { |
| 227 fProcIndex = cycle_hairproc_index(fProcIndex); | 227 fProcIndex = cycle_hairproc_index(fProcIndex); |
| 228 // todo: signal that we want to rebuild our TITLE | 228 // todo: signal that we want to rebuild our TITLE |
| 229 } | 229 } |
| 230 fDoAA = !fDoAA; | 230 fDoAA = !fDoAA; |
| 231 return true; | 231 return true; |
| 232 } | 232 } |
| 233 | 233 |
| 234 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { | 234 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { |
| 235 fDoAA = !fDoAA; | 235 fDoAA = !fDoAA; |
| 236 this->inval(NULL); | 236 this->inval(nullptr); |
| 237 return this->INHERITED::onFindClickHandler(x, y, modi); | 237 return this->INHERITED::onFindClickHandler(x, y, modi); |
| 238 } | 238 } |
| 239 | 239 |
| 240 | 240 |
| 241 private: | 241 private: |
| 242 typedef SampleView INHERITED; | 242 typedef SampleView INHERITED; |
| 243 }; | 243 }; |
| 244 | 244 |
| 245 ////////////////////////////////////////////////////////////////////////////// | 245 ////////////////////////////////////////////////////////////////////////////// |
| 246 | 246 |
| 247 static SkView* MyFactory() { return new HairlineView; } | 247 static SkView* MyFactory() { return new HairlineView; } |
| 248 static SkViewRegister reg(MyFactory); | 248 static SkViewRegister reg(MyFactory); |
| OLD | NEW |