OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 public: | 42 public: |
43 ComposeShaderGM() { | 43 ComposeShaderGM() { |
44 fShader = make_shader(SkXfermode::kDstIn_Mode); | 44 fShader = make_shader(SkXfermode::kDstIn_Mode); |
45 } | 45 } |
46 | 46 |
47 virtual ~ComposeShaderGM() { | 47 virtual ~ComposeShaderGM() { |
48 SkSafeUnref(fShader); | 48 SkSafeUnref(fShader); |
49 } | 49 } |
50 | 50 |
51 protected: | 51 protected: |
52 SkString onShortName() SK_OVERRIDE { | 52 SkString onShortName() override { |
53 return SkString("composeshader"); | 53 return SkString("composeshader"); |
54 } | 54 } |
55 | 55 |
56 SkISize onISize() SK_OVERRIDE { | 56 SkISize onISize() override { |
57 return SkISize::Make(120, 120); | 57 return SkISize::Make(120, 120); |
58 } | 58 } |
59 | 59 |
60 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 60 void onDraw(SkCanvas* canvas) override { |
61 | 61 |
62 SkPaint paint; | 62 SkPaint paint; |
63 | 63 |
64 paint.setColor(SK_ColorGREEN); | 64 paint.setColor(SK_ColorGREEN); |
65 canvas->drawRectCoords(0, 0, SkIntToScalar(100), SkIntToScalar(100), pai
nt); | 65 canvas->drawRectCoords(0, 0, SkIntToScalar(100), SkIntToScalar(100), pai
nt); |
66 paint.setShader(fShader); | 66 paint.setShader(fShader); |
67 canvas->drawRectCoords(0, 0, SkIntToScalar(100), SkIntToScalar(100), pai
nt); | 67 canvas->drawRectCoords(0, 0, SkIntToScalar(100), SkIntToScalar(100), pai
nt); |
68 } | 68 } |
69 | 69 |
70 protected: | 70 protected: |
71 SkShader* fShader; | 71 SkShader* fShader; |
72 | 72 |
73 private: | 73 private: |
74 typedef GM INHERITED ; | 74 typedef GM INHERITED ; |
75 }; | 75 }; |
76 | 76 |
77 class ComposeShaderAlphaGM : public skiagm::GM { | 77 class ComposeShaderAlphaGM : public skiagm::GM { |
78 public: | 78 public: |
79 ComposeShaderAlphaGM() {} | 79 ComposeShaderAlphaGM() {} |
80 | 80 |
81 protected: | 81 protected: |
82 SkString onShortName() SK_OVERRIDE { | 82 SkString onShortName() override { |
83 return SkString("composeshader_alpha"); | 83 return SkString("composeshader_alpha"); |
84 } | 84 } |
85 | 85 |
86 SkISize onISize() SK_OVERRIDE { | 86 SkISize onISize() override { |
87 return SkISize::Make(220, 750); | 87 return SkISize::Make(220, 750); |
88 } | 88 } |
89 | 89 |
90 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 90 void onDraw(SkCanvas* canvas) override { |
91 SkAutoTUnref<SkShader> shader0(make_shader(SkXfermode::kDstIn_Mode)); | 91 SkAutoTUnref<SkShader> shader0(make_shader(SkXfermode::kDstIn_Mode)); |
92 SkAutoTUnref<SkShader> shader1(make_shader(SkXfermode::kSrcOver_Mode)); | 92 SkAutoTUnref<SkShader> shader1(make_shader(SkXfermode::kSrcOver_Mode)); |
93 SkShader* shaders[] = { shader0.get(), shader1.get() }; | 93 SkShader* shaders[] = { shader0.get(), shader1.get() }; |
94 | 94 |
95 SkPaint paint; | 95 SkPaint paint; |
96 paint.setColor(SK_ColorGREEN); | 96 paint.setColor(SK_ColorGREEN); |
97 | 97 |
98 const SkRect r = SkRect::MakeXYWH(5, 5, 100, 100); | 98 const SkRect r = SkRect::MakeXYWH(5, 5, 100, 100); |
99 | 99 |
100 for (size_t y = 0; y < SK_ARRAY_COUNT(shaders); ++y) { | 100 for (size_t y = 0; y < SK_ARRAY_COUNT(shaders); ++y) { |
(...skipping 13 matching lines...) Expand all Loading... |
114 canvas->restore(); | 114 canvas->restore(); |
115 canvas->translate(0, r.height() + 5); | 115 canvas->translate(0, r.height() + 5); |
116 } | 116 } |
117 } | 117 } |
118 }; | 118 }; |
119 | 119 |
120 ////////////////////////////////////////////////////////////////////////////// | 120 ////////////////////////////////////////////////////////////////////////////// |
121 | 121 |
122 DEF_GM( return new ComposeShaderGM; ) | 122 DEF_GM( return new ComposeShaderGM; ) |
123 DEF_GM( return new ComposeShaderAlphaGM; ) | 123 DEF_GM( return new ComposeShaderAlphaGM; ) |
OLD | NEW |