OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 for (int i = 0; i < kNumPictures; ++i) { | 479 for (int i = 0; i < kNumPictures; ++i) { |
480 SkSafeUnref(fPictures[i]); | 480 SkSafeUnref(fPictures[i]); |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
484 protected: | 484 protected: |
485 Content fContent; | 485 Content fContent; |
486 Layout fLayout; | 486 Layout fLayout; |
487 const SkPicture* fPictures[kNumPictures]; | 487 const SkPicture* fPictures[kNumPictures]; |
488 | 488 |
489 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 489 void onOnceBeforeDraw() SK_OVERRIDE { |
490 fPictures[0] = make_hex_plane_picture(SK_ColorWHITE); | 490 fPictures[0] = make_hex_plane_picture(SK_ColorWHITE); |
491 fPictures[1] = make_hex_plane_picture(SK_ColorGRAY); | 491 fPictures[1] = make_hex_plane_picture(SK_ColorGRAY); |
492 fPictures[2] = make_sierpinski_picture(); | 492 fPictures[2] = make_sierpinski_picture(); |
493 fPictures[3] = make_single_layer_hex_plane_picture(); | 493 fPictures[3] = make_single_layer_hex_plane_picture(); |
494 } | 494 } |
495 | 495 |
496 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 496 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
497 SkMultiPictureDraw mpd; | 497 SkMultiPictureDraw mpd; |
498 SkTArray<ComposeStep> composeSteps; | 498 SkTArray<ComposeStep> composeSteps; |
499 | 499 |
500 // Fill up the MultiPictureDraw | 500 // Fill up the MultiPictureDraw |
501 (*gLayoutMthds[fLayout])(canvas, &mpd, | 501 (*gLayoutMthds[fLayout])(canvas, &mpd, |
502 gContentMthds[fContent], | 502 gContentMthds[fContent], |
503 fPictures, &composeSteps); | 503 fPictures, &composeSteps); |
504 | 504 |
505 mpd.draw(); | 505 mpd.draw(); |
506 | 506 |
507 // Compose all the drawn canvases into the final canvas | 507 // Compose all the drawn canvases into the final canvas |
508 for (int i = 0; i < composeSteps.count(); ++i) { | 508 for (int i = 0; i < composeSteps.count(); ++i) { |
509 const ComposeStep& step = composeSteps[i]; | 509 const ComposeStep& step = composeSteps[i]; |
510 | 510 |
511 SkAutoTUnref<SkImage> image(step.fSurf->newImageSnapshot()); | 511 SkAutoTUnref<SkImage> image(step.fSurf->newImageSnapshot()); |
512 | 512 |
513 canvas->drawImage(image, step.fX, step.fY, step.fPaint); | 513 canvas->drawImage(image, step.fX, step.fY, step.fPaint); |
514 } | 514 } |
515 } | 515 } |
516 | 516 |
517 virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(kPicWidth,
kPicHeight); } | 517 SkISize onISize() SK_OVERRIDE { return SkISize::Make(kPicWidth, kPicHeig
ht); } |
518 | 518 |
519 virtual SkString onShortName() SK_OVERRIDE { | 519 SkString onShortName() SK_OVERRIDE { |
520 static const char* gContentNames[] = { | 520 static const char* gContentNames[] = { |
521 "noclip", "rectclip", "rrectclip", "pathclip", | 521 "noclip", "rectclip", "rrectclip", "pathclip", |
522 "invpathclip", "sierpinski", "biglayer" | 522 "invpathclip", "sierpinski", "biglayer" |
523 }; | 523 }; |
524 static const char* gLayoutNames[] = { "simple", "tiled" }; | 524 static const char* gLayoutNames[] = { "simple", "tiled" }; |
525 | 525 |
526 SkASSERT(SK_ARRAY_COUNT(gLayoutNames) == kLayoutCnt); | 526 SkASSERT(SK_ARRAY_COUNT(gLayoutNames) == kLayoutCnt); |
527 SkASSERT(SK_ARRAY_COUNT(gContentNames) == kContentCnt); | 527 SkASSERT(SK_ARRAY_COUNT(gContentNames) == kContentCnt); |
528 | 528 |
529 SkString name("multipicturedraw_"); | 529 SkString name("multipicturedraw_"); |
530 | 530 |
531 name.append(gContentNames[fContent]); | 531 name.append(gContentNames[fContent]); |
532 name.append("_"); | 532 name.append("_"); |
533 name.append(gLayoutNames[fLayout]); | 533 name.append(gLayoutNames[fLayout]); |
534 return name; | 534 return name; |
535 } | 535 } |
536 | 536 |
537 virtual uint32_t onGetFlags() const SK_OVERRIDE { return kAsBench_Flag |
kSkipTiled_Flag; } | 537 uint32_t onGetFlags() const SK_OVERRIDE { return kAsBench_Flag | kSkipTi
led_Flag; } |
538 | 538 |
539 private: | 539 private: |
540 typedef GM INHERITED; | 540 typedef GM INHERITED; |
541 }; | 541 }; |
542 | 542 |
543 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kNoClipSingle_
Content, | 543 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kNoClipSingle_
Content, |
544 MultiPictureDraw::kSimple_Layout
));) | 544 MultiPictureDraw::kSimple_Layout
));) |
545 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kRectClipMulti
_Content, | 545 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kRectClipMulti
_Content, |
546 MultiPictureDraw::kSimple_Layout
));) | 546 MultiPictureDraw::kSimple_Layout
));) |
547 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kRRectClipMult
i_Content, | 547 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kRRectClipMult
i_Content, |
(...skipping 15 matching lines...) Expand all Loading... |
563 MultiPictureDraw::kTiled_Layout)
);) | 563 MultiPictureDraw::kTiled_Layout)
);) |
564 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kPathClipMulti
_Content, | 564 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kPathClipMulti
_Content, |
565 MultiPictureDraw::kTiled_Layout)
);) | 565 MultiPictureDraw::kTiled_Layout)
);) |
566 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kInvPathClipMu
lti_Content, | 566 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kInvPathClipMu
lti_Content, |
567 MultiPictureDraw::kTiled_Layout)
);) | 567 MultiPictureDraw::kTiled_Layout)
);) |
568 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kSierpinski_Co
ntent, | 568 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kSierpinski_Co
ntent, |
569 MultiPictureDraw::kTiled_Layout)
);) | 569 MultiPictureDraw::kTiled_Layout)
);) |
570 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kBigLayer_Cont
ent, | 570 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kBigLayer_Cont
ent, |
571 MultiPictureDraw::kTiled_Layout)
);) | 571 MultiPictureDraw::kTiled_Layout)
);) |
572 } | 572 } |
OLD | NEW |