OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 212 } |
213 | 213 |
214 void build_rgn(SkRegion* rgn, SkRegion::Op op) { | 214 void build_rgn(SkRegion* rgn, SkRegion::Op op) { |
215 build_base_rgn(rgn); | 215 build_base_rgn(rgn); |
216 rgn->op(fRect, op); | 216 rgn->op(fRect, op); |
217 } | 217 } |
218 | 218 |
219 | 219 |
220 protected: | 220 protected: |
221 // overrides from SkEventSink | 221 // overrides from SkEventSink |
222 virtual bool onQuery(SkEvent* evt) SK_OVERRIDE { | 222 bool onQuery(SkEvent* evt) SK_OVERRIDE { |
223 if (SampleCode::TitleQ(*evt)) { | 223 if (SampleCode::TitleQ(*evt)) { |
224 SampleCode::TitleR(evt, "Regions"); | 224 SampleCode::TitleR(evt, "Regions"); |
225 return true; | 225 return true; |
226 } | 226 } |
227 return this->INHERITED::onQuery(evt); | 227 return this->INHERITED::onQuery(evt); |
228 } | 228 } |
229 | 229 |
230 static void drawstr(SkCanvas* canvas, const char text[], const SkPoint& loc, | 230 static void drawstr(SkCanvas* canvas, const char text[], const SkPoint& loc, |
231 bool hilite) { | 231 bool hilite) { |
232 SkPaint paint; | 232 SkPaint paint; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 SkPaint paint; | 314 SkPaint paint; |
315 | 315 |
316 paint.setStyle(SkPaint::kFill_Style); | 316 paint.setStyle(SkPaint::kFill_Style); |
317 paint.setColor((color & ~(0xFF << 24)) | (0x44 << 24)); | 317 paint.setColor((color & ~(0xFF << 24)) | (0x44 << 24)); |
318 canvas->drawPath(path, paint); | 318 canvas->drawPath(path, paint); |
319 paint.setColor(color); | 319 paint.setColor(color); |
320 paint.setStyle(SkPaint::kStroke_Style); | 320 paint.setStyle(SkPaint::kStroke_Style); |
321 canvas->drawPath(path, paint); | 321 canvas->drawPath(path, paint); |
322 } | 322 } |
323 | 323 |
324 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 324 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { |
325 if (false) { // avoid bit rot, suppress warning | 325 if (false) { // avoid bit rot, suppress warning |
326 test_strokerect(canvas); | 326 test_strokerect(canvas); |
327 return; | 327 return; |
328 } | 328 } |
329 if (false) { // avoid bit rot, suppress warning | 329 if (false) { // avoid bit rot, suppress warning |
330 test_text(canvas); | 330 test_text(canvas); |
331 return; | 331 return; |
332 } | 332 } |
333 #ifdef SK_DEBUG | 333 #ifdef SK_DEBUG |
334 if (true) { | 334 if (true) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 canvas->translate(SkIntToScalar(200), 0); | 392 canvas->translate(SkIntToScalar(200), 0); |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, | 396 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, |
397 unsigned modi) SK_OVERRIDE { | 397 unsigned modi) SK_OVERRIDE { |
398 return fRect.contains(SkScalarRoundToInt(x), | 398 return fRect.contains(SkScalarRoundToInt(x), |
399 SkScalarRoundToInt(y)) ? new Click(this) : NULL; | 399 SkScalarRoundToInt(y)) ? new Click(this) : NULL; |
400 } | 400 } |
401 | 401 |
402 virtual bool onClick(Click* click) SK_OVERRIDE { | 402 bool onClick(Click* click) SK_OVERRIDE { |
403 fRect.offset(click->fICurr.fX - click->fIPrev.fX, | 403 fRect.offset(click->fICurr.fX - click->fIPrev.fX, |
404 click->fICurr.fY - click->fIPrev.fY); | 404 click->fICurr.fY - click->fIPrev.fY); |
405 this->inval(NULL); | 405 this->inval(NULL); |
406 return true; | 406 return true; |
407 } | 407 } |
408 | 408 |
409 private: | 409 private: |
410 SkIRect fBase, fRect; | 410 SkIRect fBase, fRect; |
411 | 411 |
412 typedef SampleView INHERITED; | 412 typedef SampleView INHERITED; |
413 }; | 413 }; |
414 | 414 |
415 ////////////////////////////////////////////////////////////////////////////// | 415 ////////////////////////////////////////////////////////////////////////////// |
416 | 416 |
417 static SkView* MyFactory() { return new RegionView; } | 417 static SkView* MyFactory() { return new RegionView; } |
418 static SkViewRegister reg(MyFactory); | 418 static SkViewRegister reg(MyFactory); |
OLD | NEW |