OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2014 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #include "gm.h" | |
9 #include "SkPaint.h" | |
10 #include "SkPictureRecorder.h" | |
11 | |
12 static SkPicture* make_picture() { | |
13 SkPictureRecorder rec; | |
14 SkCanvas* canvas = rec.beginRecording(100, 100); | |
15 | |
16 SkPaint paint; | |
17 paint.setAntiAlias(true); | |
18 SkPath path; | |
19 | |
20 paint.setColor(0x800000FF); | |
21 canvas->drawRect(SkRect::MakeWH(100, 100), paint); | |
22 | |
23 paint.setColor(0x80FF0000); | |
24 path.moveTo(0, 0); path.lineTo(100, 0); path.lineTo(100, 100); | |
25 canvas->drawPath(path, paint); | |
26 | |
27 paint.setColor(0x8000FF00); | |
28 path.reset(); path.moveTo(0, 0); path.lineTo(100, 0); path.lineTo(0, 100); | |
29 canvas->drawPath(path, paint); | |
30 | |
31 paint.setColor(0x80FFFFFF); | |
32 paint.setXfermodeMode(SkXfermode::kPlus_Mode); | |
33 canvas->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), paint); | |
34 | |
35 return rec.endRecording(); | |
36 } | |
37 | |
robertphillips
2014/08/08 18:37:37
// Exercise the SkCanvas::drawPicture interface wi
reed1
2014/08/09 17:42:31
Done.
| |
38 class PictureGM : public skiagm::GM { | |
39 SkAutoTUnref<SkPicture> fPicture; | |
40 public: | |
41 PictureGM() : fPicture(make_picture()) {} | |
42 | |
43 protected: | |
44 virtual SkString onShortName() SK_OVERRIDE { | |
45 return SkString("pictures"); | |
46 } | |
47 | |
48 virtual SkISize onISize() SK_OVERRIDE { | |
robertphillips
2014/08/08 18:37:37
Does this need to be this large?
reed1
2014/08/09 17:42:31
Done.
| |
49 return SkISize::Make(1024, 768); | |
50 } | |
51 | |
52 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | |
53 canvas->translate(10, 10); | |
54 | |
55 SkMatrix matrix; | |
56 SkPaint paint; | |
57 | |
58 canvas->drawPicture(fPicture); | |
59 | |
60 matrix.setTranslate(110, 0); | |
61 canvas->drawPicture(fPicture, &matrix, NULL); | |
62 | |
63 matrix.postTranslate(110, 0); | |
64 canvas->drawPicture(fPicture, &matrix, &paint); | |
65 | |
66 paint.setAlpha(0x80); | |
67 matrix.postTranslate(110, 0); | |
68 canvas->drawPicture(fPicture, &matrix, &paint); | |
69 } | |
robertphillips
2014/08/08 18:37:37
private:
typedef skiagm::GM INHERITED;
?
reed1
2014/08/09 17:42:31
Done.
| |
70 }; | |
71 | |
72 DEF_GM( return SkNEW(PictureGM); ) | |
OLD | NEW |