OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 Test a set of clipping problems discovered while writing blitAntiRect, | 32 Test a set of clipping problems discovered while writing blitAntiRect, |
33 and test all the code paths through the clipping blitters. | 33 and test all the code paths through the clipping blitters. |
34 Each region should show as a blue center surrounded by a 2px green | 34 Each region should show as a blue center surrounded by a 2px green |
35 border, with no red. | 35 border, with no red. |
36 */ | 36 */ |
37 | 37 |
38 #define HEIGHT 480 | 38 #define HEIGHT 480 |
39 | 39 |
40 class GammaTextGM : public skiagm::GM { | 40 class GammaTextGM : public skiagm::GM { |
41 protected: | 41 protected: |
42 SkString onShortName() SK_OVERRIDE { | 42 SkString onShortName() override { |
43 return SkString("gammatext"); | 43 return SkString("gammatext"); |
44 } | 44 } |
45 | 45 |
46 SkISize onISize() SK_OVERRIDE { | 46 SkISize onISize() override { |
47 return SkISize::Make(1024, HEIGHT); | 47 return SkISize::Make(1024, HEIGHT); |
48 } | 48 } |
49 | 49 |
50 static void drawGrad(SkCanvas* canvas) { | 50 static void drawGrad(SkCanvas* canvas) { |
51 SkPoint pts[] = { { 0, 0 }, { 0, SkIntToScalar(HEIGHT) } }; | 51 SkPoint pts[] = { { 0, 0 }, { 0, SkIntToScalar(HEIGHT) } }; |
52 SkShader* s = make_heatGradient(pts); | 52 SkShader* s = make_heatGradient(pts); |
53 | 53 |
54 canvas->clear(SK_ColorRED); | 54 canvas->clear(SK_ColorRED); |
55 SkPaint paint; | 55 SkPaint paint; |
56 paint.setShader(s)->unref(); | 56 paint.setShader(s)->unref(); |
57 SkRect r = { 0, 0, SkIntToScalar(1024), SkIntToScalar(HEIGHT) }; | 57 SkRect r = { 0, 0, SkIntToScalar(1024), SkIntToScalar(HEIGHT) }; |
58 canvas->drawRect(r, paint); | 58 canvas->drawRect(r, paint); |
59 } | 59 } |
60 | 60 |
61 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 61 void onDraw(SkCanvas* canvas) override { |
62 drawGrad(canvas); | 62 drawGrad(canvas); |
63 | 63 |
64 const SkColor fg[] = { | 64 const SkColor fg[] = { |
65 0xFFFFFFFF, | 65 0xFFFFFFFF, |
66 0xFFFFFF00, 0xFFFF00FF, 0xFF00FFFF, | 66 0xFFFFFF00, 0xFFFF00FF, 0xFF00FFFF, |
67 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, | 67 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, |
68 0xFF000000, | 68 0xFF000000, |
69 }; | 69 }; |
70 | 70 |
71 const char* text = "Hamburgefons"; | 71 const char* text = "Hamburgefons"; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 public: | 131 public: |
132 GammaShaderTextGM() { | 132 GammaShaderTextGM() { |
133 const SkColor colors[] = { SK_ColorBLACK, SK_ColorRED, SK_ColorBLUE }; | 133 const SkColor colors[] = { SK_ColorBLACK, SK_ColorRED, SK_ColorBLUE }; |
134 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { | 134 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { |
135 fShaders[i] = NULL; | 135 fShaders[i] = NULL; |
136 fColors[i] = colors[i]; | 136 fColors[i] = colors[i]; |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 ~GammaShaderTextGM() SK_OVERRIDE { | 140 ~GammaShaderTextGM() override { |
141 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { | 141 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { |
142 SkSafeUnref(fShaders[i]); | 142 SkSafeUnref(fShaders[i]); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 protected: | 146 protected: |
147 SkString onShortName() SK_OVERRIDE { | 147 SkString onShortName() override { |
148 return SkString("gammagradienttext"); | 148 return SkString("gammagradienttext"); |
149 } | 149 } |
150 | 150 |
151 SkISize onISize() SK_OVERRIDE { | 151 SkISize onISize() override { |
152 return SkISize::Make(300, 300); | 152 return SkISize::Make(300, 300); |
153 } | 153 } |
154 | 154 |
155 void onOnceBeforeDraw() SK_OVERRIDE { | 155 void onOnceBeforeDraw() override { |
156 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { | 156 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { |
157 fShaders[i] = make_gradient(fColors[i]); | 157 fShaders[i] = make_gradient(fColors[i]); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 161 void onDraw(SkCanvas* canvas) override { |
162 SkPaint paint; | 162 SkPaint paint; |
163 paint.setAntiAlias(true); | 163 paint.setAntiAlias(true); |
164 paint.setLCDRenderText(true); | 164 paint.setLCDRenderText(true); |
165 paint.setTextSize(18); | 165 paint.setTextSize(18); |
166 set_face(&paint); | 166 set_face(&paint); |
167 | 167 |
168 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { | 168 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { |
169 paint.setColor(fColors[i]); | 169 paint.setColor(fColors[i]); |
170 draw_pair(canvas, &paint, fShaders[i]); | 170 draw_pair(canvas, &paint, fShaders[i]); |
171 canvas->translate(0, 80); | 171 canvas->translate(0, 80); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 private: | 175 private: |
176 typedef skiagm::GM INHERITED; | 176 typedef skiagm::GM INHERITED; |
177 }; | 177 }; |
178 | 178 |
179 DEF_GM( return new GammaShaderTextGM; ) | 179 DEF_GM( return new GammaShaderTextGM; ) |
180 | 180 |
OLD | NEW |