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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 SkPaint paint; | 30 SkPaint paint; |
31 | 31 |
32 drawline(canvas, 1, 1, paint, SkIntToScalar(20 * 1000)); | 32 drawline(canvas, 1, 1, paint, SkIntToScalar(20 * 1000)); |
33 } | 33 } |
34 | 34 |
35 class DashingGM : public skiagm::GM { | 35 class DashingGM : public skiagm::GM { |
36 public: | 36 public: |
37 DashingGM() {} | 37 DashingGM() {} |
38 | 38 |
39 protected: | 39 protected: |
| 40 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
| 41 return kSkipTiled_Flag; |
| 42 } |
| 43 |
40 SkString onShortName() { | 44 SkString onShortName() { |
41 return SkString("dashing"); | 45 return SkString("dashing"); |
42 } | 46 } |
43 | 47 |
44 SkISize onISize() { return skiagm::make_isize(640, 300); } | 48 SkISize onISize() { return skiagm::make_isize(640, 300); } |
45 | 49 |
46 virtual void onDraw(SkCanvas* canvas) { | 50 virtual void onDraw(SkCanvas* canvas) { |
47 static const struct { | 51 static const struct { |
48 int fOnInterval; | 52 int fOnInterval; |
49 int fOffInterval; | 53 int fOffInterval; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 SkMatrix matrix; | 116 SkMatrix matrix; |
113 matrix.setRectToRect(path->getBounds(), bounds, SkMatrix::kCenter_ScaleToFit
); | 117 matrix.setRectToRect(path->getBounds(), bounds, SkMatrix::kCenter_ScaleToFit
); |
114 path->transform(matrix); | 118 path->transform(matrix); |
115 } | 119 } |
116 | 120 |
117 class Dashing2GM : public skiagm::GM { | 121 class Dashing2GM : public skiagm::GM { |
118 public: | 122 public: |
119 Dashing2GM() {} | 123 Dashing2GM() {} |
120 | 124 |
121 protected: | 125 protected: |
| 126 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
| 127 return kSkipTiled_Flag; |
| 128 } |
| 129 |
122 SkString onShortName() { | 130 SkString onShortName() { |
123 return SkString("dashing2"); | 131 return SkString("dashing2"); |
124 } | 132 } |
125 | 133 |
126 SkISize onISize() { return skiagm::make_isize(640, 480); } | 134 SkISize onISize() { return skiagm::make_isize(640, 480); } |
127 | 135 |
128 virtual void onDraw(SkCanvas* canvas) { | 136 virtual void onDraw(SkCanvas* canvas) { |
129 static const int gIntervals[] = { | 137 static const int gIntervals[] = { |
130 3, // 3 dashes: each count [0] followed by intervals [1..count] | 138 3, // 3 dashes: each count [0] followed by intervals [1..count] |
131 2, 10, 10, | 139 2, 10, 10, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 }; | 178 }; |
171 | 179 |
172 ////////////////////////////////////////////////////////////////////////////// | 180 ////////////////////////////////////////////////////////////////////////////// |
173 | 181 |
174 // Test out the on/off line dashing Chrome if fond of | 182 // Test out the on/off line dashing Chrome if fond of |
175 class Dashing3GM : public skiagm::GM { | 183 class Dashing3GM : public skiagm::GM { |
176 public: | 184 public: |
177 Dashing3GM() {} | 185 Dashing3GM() {} |
178 | 186 |
179 protected: | 187 protected: |
| 188 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
| 189 return kSkipTiled_Flag; |
| 190 } |
| 191 |
180 SkString onShortName() { | 192 SkString onShortName() { |
181 return SkString("dashing3"); | 193 return SkString("dashing3"); |
182 } | 194 } |
183 | 195 |
184 SkISize onISize() { return skiagm::make_isize(640, 480); } | 196 SkISize onISize() { return skiagm::make_isize(640, 480); } |
185 | 197 |
186 // Draw a 100x100 block of dashed lines. The horizontal ones are BW | 198 // Draw a 100x100 block of dashed lines. The horizontal ones are BW |
187 // while the vertical ones are AA. | 199 // while the vertical ones are AA. |
188 void drawDashedLines(SkCanvas* canvas, | 200 void drawDashedLines(SkCanvas* canvas, |
189 SkScalar lineLength, | 201 SkScalar lineLength, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 313 |
302 ////////////////////////////////////////////////////////////////////////////// | 314 ////////////////////////////////////////////////////////////////////////////// |
303 | 315 |
304 static skiagm::GM* F0(void*) { return new DashingGM; } | 316 static skiagm::GM* F0(void*) { return new DashingGM; } |
305 static skiagm::GM* F1(void*) { return new Dashing2GM; } | 317 static skiagm::GM* F1(void*) { return new Dashing2GM; } |
306 static skiagm::GM* F2(void*) { return new Dashing3GM; } | 318 static skiagm::GM* F2(void*) { return new Dashing3GM; } |
307 | 319 |
308 static skiagm::GMRegistry gR0(F0); | 320 static skiagm::GMRegistry gR0(F0); |
309 static skiagm::GMRegistry gR1(F1); | 321 static skiagm::GMRegistry gR1(F1); |
310 static skiagm::GMRegistry gR2(F2); | 322 static skiagm::GMRegistry gR2(F2); |
OLD | NEW |