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