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