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 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 return rec.endRecording(); | 35 return rec.endRecording(); |
36 } | 36 } |
37 | 37 |
38 // Exercise the optional arguments to drawPicture | 38 // Exercise the optional arguments to drawPicture |
39 // | 39 // |
40 class PictureGM : public skiagm::GM { | 40 class PictureGM : public skiagm::GM { |
41 public: | 41 public: |
42 PictureGM() : fPicture(make_picture()) {} | 42 PictureGM() : fPicture(make_picture()) {} |
43 | 43 |
44 protected: | 44 protected: |
45 virtual SkString onShortName() SK_OVERRIDE { | 45 SkString onShortName() SK_OVERRIDE { |
46 return SkString("pictures"); | 46 return SkString("pictures"); |
47 } | 47 } |
48 | 48 |
49 virtual SkISize onISize() SK_OVERRIDE { | 49 SkISize onISize() SK_OVERRIDE { |
50 return SkISize::Make(450, 120); | 50 return SkISize::Make(450, 120); |
51 } | 51 } |
52 | 52 |
53 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 53 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
54 canvas->translate(10, 10); | 54 canvas->translate(10, 10); |
55 | 55 |
56 SkMatrix matrix; | 56 SkMatrix matrix; |
57 SkPaint paint; | 57 SkPaint paint; |
58 | 58 |
59 canvas->drawPicture(fPicture); | 59 canvas->drawPicture(fPicture); |
60 | 60 |
61 matrix.setTranslate(110, 0); | 61 matrix.setTranslate(110, 0); |
62 canvas->drawPicture(fPicture, &matrix, NULL); | 62 canvas->drawPicture(fPicture, &matrix, NULL); |
63 | 63 |
64 matrix.postTranslate(110, 0); | 64 matrix.postTranslate(110, 0); |
65 canvas->drawPicture(fPicture, &matrix, &paint); | 65 canvas->drawPicture(fPicture, &matrix, &paint); |
66 | 66 |
67 paint.setAlpha(0x80); | 67 paint.setAlpha(0x80); |
68 matrix.postTranslate(110, 0); | 68 matrix.postTranslate(110, 0); |
69 canvas->drawPicture(fPicture, &matrix, &paint); | 69 canvas->drawPicture(fPicture, &matrix, &paint); |
70 } | 70 } |
71 | 71 |
72 private: | 72 private: |
73 SkAutoTUnref<SkPicture> fPicture; | 73 SkAutoTUnref<SkPicture> fPicture; |
74 | 74 |
75 typedef skiagm::GM INHERITED; | 75 typedef skiagm::GM INHERITED; |
76 }; | 76 }; |
77 | 77 |
78 DEF_GM( return SkNEW(PictureGM); ) | 78 DEF_GM( return SkNEW(PictureGM); ) |
OLD | NEW |