OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 /** | 8 /** |
9 * Pathologically simple drawing tests, designed to generate consistent | 9 * Pathologically simple drawing tests, designed to generate consistent |
10 * output images across platforms for gm/tests/run.sh | 10 * output images across platforms for gm/tests/run.sh |
11 */ | 11 */ |
12 | 12 |
13 #include "gm.h" | 13 #include "gm.h" |
14 #include "SkCanvas.h" | 14 #include "SkCanvas.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 | 16 |
17 class SelfTestGM : public skiagm::GM { | 17 class SelfTestGM : public skiagm::GM { |
18 public: | 18 public: |
19 SelfTestGM(const char name[], SkColor color) : fName(name), fColor(color) {} | 19 SelfTestGM(const char name[], SkColor color, uint32_t flags) : |
| 20 fName(name), fColor(color), fFlags(flags) {} |
20 const static int kWidth = 300; | 21 const static int kWidth = 300; |
21 const static int kHeight = 200; | 22 const static int kHeight = 200; |
22 | 23 |
23 protected: | 24 protected: |
24 SkString onShortName() { | 25 SkString onShortName() { |
25 return fName; | 26 return fName; |
26 } | 27 } |
27 | 28 |
28 SkISize onISize() { return skiagm::make_isize(kWidth, kHeight); } | 29 SkISize onISize() { return skiagm::make_isize(kWidth, kHeight); } |
29 | 30 |
30 virtual void onDraw(SkCanvas* canvas) { | 31 virtual void onDraw(SkCanvas* canvas) { |
31 SkPaint paint; | 32 SkPaint paint; |
32 paint.setStyle(SkPaint::kFill_Style); | 33 paint.setStyle(SkPaint::kFill_Style); |
33 paint.setColor(fColor); | 34 paint.setColor(fColor); |
34 canvas->drawRectCoords(0, 0, SkIntToScalar(kWidth), SkIntToScalar(kHeigh
t), paint); | 35 canvas->drawRectCoords(0, 0, SkIntToScalar(kWidth), SkIntToScalar(kHeigh
t), paint); |
35 } | 36 } |
36 | 37 |
| 38 virtual uint32_t onGetFlags() const { return fFlags; } |
| 39 |
37 private: | 40 private: |
38 const SkString fName; | 41 const SkString fName; |
39 const SkColor fColor; | 42 const SkColor fColor; |
| 43 const uint32_t fFlags; |
40 }; | 44 }; |
41 | 45 |
42 ////////////////////////////////////////////////////////////////////////////// | 46 ////////////////////////////////////////////////////////////////////////////// |
43 | 47 |
44 // We use translucent colors to make sure we are properly handling cases like | 48 // We use translucent colors to make sure we are properly handling cases like |
45 // those which caused https://code.google.com/p/skia/issues/detail?id=1079 | 49 // those which caused https://code.google.com/p/skia/issues/detail?id=1079 |
46 // ('gm generating spurious pixel_error messages as of r7258') | 50 // ('gm generating spurious pixel_error messages as of r7258') |
47 static SkColor kTranslucentGreen = 0x7700EE00; | 51 static SkColor kTranslucentGreen = 0x7700EE00; |
48 static SkColor kTranslucentBlue = 0x770000DD; | 52 static SkColor kTranslucentBlue = 0x770000DD; |
49 | 53 |
50 static skiagm::GM* F1(void*) { return new SelfTestGM("selftest1", kTranslucentGr
een); } | 54 static skiagm::GM* F1(void*) { |
51 static skiagm::GM* F2(void*) { return new SelfTestGM("selftest2", kTranslucentBl
ue); } | 55 return new SelfTestGM("selftest1", kTranslucentGreen, 0); |
| 56 } |
| 57 static skiagm::GM* F2(void*) { |
| 58 return new SelfTestGM("selftest2", kTranslucentBlue, skiagm::GM::kSkipPipe_
Flag); |
| 59 } |
52 | 60 |
53 static skiagm::GMRegistry gR1(F1); | 61 static skiagm::GMRegistry gR1(F1); |
54 static skiagm::GMRegistry gR2(F2); | 62 static skiagm::GMRegistry gR2(F2); |
OLD | NEW |