| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 SkBitmap bitmap; | 124 SkBitmap bitmap; |
| 125 make_bitmap(&bitmap); | 125 make_bitmap(&bitmap); |
| 126 | 126 |
| 127 canvas->translate(20, 20); | 127 canvas->translate(20, 20); |
| 128 | 128 |
| 129 canvas->drawBitmap(bitmap, 0, 0, &paint); | 129 canvas->drawBitmap(bitmap, 0, 0, &paint); |
| 130 canvas->drawRect(srcR, paint); | 130 canvas->drawRect(srcR, paint); |
| 131 | 131 |
| 132 for (int i = 0; i < 2; ++i) { | 132 for (int i = 0; i < 2; ++i) { |
| 133 paint.setFilterQuality(1 == i ? kLow_SkFilterQuality : kNone_SkFilte
rQuality); | 133 paint.setFilterQuality(1 == i ? kLow_SkFilterQuality : kNone_SkFilte
rQuality); |
| 134 canvas->drawBitmapRectToRect(bitmap, &srcR, fDstR[i], &paint); | 134 canvas->drawBitmapRect(bitmap, &srcR, fDstR[i], &paint); |
| 135 canvas->drawRect(fDstR[i], paint); | 135 canvas->drawRect(fDstR[i], paint); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool onAnimate(const SkAnimTimer& timer) override { | 139 bool onAnimate(const SkAnimTimer& timer) override { |
| 140 if (timer.isStopped()) { | 140 if (timer.isStopped()) { |
| 141 this->resetBounce(); | 141 this->resetBounce(); |
| 142 } else if (timer.isRunning()) { | 142 } else if (timer.isRunning()) { |
| 143 this->bounce(); | 143 this->bounce(); |
| 144 } | 144 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return this->INHERITED::onQuery(evt); | 218 return this->INHERITED::onQuery(evt); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void onDrawContent(SkCanvas* canvas) override { | 221 void onDrawContent(SkCanvas* canvas) override { |
| 222 SkPaint paint; | 222 SkPaint paint; |
| 223 paint.setStyle(SkPaint::kStroke_Style); | 223 paint.setStyle(SkPaint::kStroke_Style); |
| 224 paint.setColor(SK_ColorYELLOW); | 224 paint.setColor(SK_ColorYELLOW); |
| 225 | 225 |
| 226 for (int i = 0; i < 2; ++i) { | 226 for (int i = 0; i < 2; ++i) { |
| 227 paint.setFilterQuality(1 == i ? kLow_SkFilterQuality : kNone_SkFilte
rQuality); | 227 paint.setFilterQuality(1 == i ? kLow_SkFilterQuality : kNone_SkFilte
rQuality); |
| 228 canvas->drawBitmapRectToRect(fBitmap, &fSrcR, fDstR[i], &paint); | 228 canvas->drawBitmapRect(fBitmap, &fSrcR, fDstR[i], &paint); |
| 229 canvas->drawRect(fDstR[i], paint); | 229 canvas->drawRect(fDstR[i], paint); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 bool onAnimate(const SkAnimTimer& timer) override { | 233 bool onAnimate(const SkAnimTimer& timer) override { |
| 234 if (timer.isStopped()) { | 234 if (timer.isStopped()) { |
| 235 this->resetBounce(); | 235 this->resetBounce(); |
| 236 } else if (timer.isRunning()) { | 236 } else if (timer.isRunning()) { |
| 237 this->bounceMe(); | 237 this->bounceMe(); |
| 238 } | 238 } |
| 239 return true; | 239 return true; |
| 240 } | 240 } |
| 241 | 241 |
| 242 private: | 242 private: |
| 243 typedef SampleView INHERITED; | 243 typedef SampleView INHERITED; |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 ////////////////////////////////////////////////////////////////////////////// | 246 ////////////////////////////////////////////////////////////////////////////// |
| 247 | 247 |
| 248 static SkView* F0() { return new BitmapRectView; } | 248 static SkView* F0() { return new BitmapRectView; } |
| 249 static SkView* F1() { return new BitmapRectView2; } | 249 static SkView* F1() { return new BitmapRectView2; } |
| 250 static SkViewRegister gR0(F0); | 250 static SkViewRegister gR0(F0); |
| 251 static SkViewRegister gR1(F1); | 251 static SkViewRegister gR1(F1); |
| OLD | NEW |