commit-bot@chromium.org | c61c3c3 | 2013-03-01 15:32:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Pathologically simple drawing tests, designed to generate consistent |
| 10 | * output images across platforms for gm/tests/run.sh |
| 11 | */ |
| 12 | |
| 13 | #include "gm.h" |
| 14 | #include "SkCanvas.h" |
| 15 | #include "SkPaint.h" |
| 16 | |
| 17 | class SelfTestGM : public skiagm::GM { |
| 18 | public: |
epoger@google.com | c8263e7 | 2013-04-10 12:17:34 +0000 | [diff] [blame] | 19 | SelfTestGM(const char name[], SkColor color, uint32_t flags) : |
| 20 | fName(name), fColor(color), fFlags(flags) {} |
commit-bot@chromium.org | c61c3c3 | 2013-03-01 15:32:34 +0000 | [diff] [blame] | 21 | const static int kWidth = 300; |
| 22 | const static int kHeight = 200; |
| 23 | |
| 24 | protected: |
| 25 | SkString onShortName() { |
| 26 | return fName; |
| 27 | } |
| 28 | |
| 29 | SkISize onISize() { return skiagm::make_isize(kWidth, kHeight); } |
| 30 | |
| 31 | virtual void onDraw(SkCanvas* canvas) { |
| 32 | SkPaint paint; |
| 33 | paint.setStyle(SkPaint::kFill_Style); |
| 34 | paint.setColor(fColor); |
| 35 | canvas->drawRectCoords(0, 0, SkIntToScalar(kWidth), SkIntToScalar(kHeight), paint); |
| 36 | } |
| 37 | |
epoger@google.com | c8263e7 | 2013-04-10 12:17:34 +0000 | [diff] [blame] | 38 | virtual uint32_t onGetFlags() const { return fFlags; } |
| 39 | |
commit-bot@chromium.org | c61c3c3 | 2013-03-01 15:32:34 +0000 | [diff] [blame] | 40 | private: |
| 41 | const SkString fName; |
| 42 | const SkColor fColor; |
epoger@google.com | c8263e7 | 2013-04-10 12:17:34 +0000 | [diff] [blame] | 43 | const uint32_t fFlags; |
commit-bot@chromium.org | c61c3c3 | 2013-03-01 15:32:34 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | ////////////////////////////////////////////////////////////////////////////// |
| 47 | |
epoger@google.com | b9ba1ea | 2013-03-02 19:56:18 +0000 | [diff] [blame] | 48 | // We use translucent colors to make sure we are properly handling cases like |
| 49 | // those which caused https://code.google.com/p/skia/issues/detail?id=1079 |
| 50 | // ('gm generating spurious pixel_error messages as of r7258') |
| 51 | static SkColor kTranslucentGreen = 0x7700EE00; |
| 52 | static SkColor kTranslucentBlue = 0x770000DD; |
| 53 | |
epoger@google.com | c8263e7 | 2013-04-10 12:17:34 +0000 | [diff] [blame] | 54 | static skiagm::GM* F1(void*) { |
| 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 | } |
commit-bot@chromium.org | c61c3c3 | 2013-03-01 15:32:34 +0000 | [diff] [blame] | 60 | |
| 61 | static skiagm::GMRegistry gR1(F1); |
| 62 | static skiagm::GMRegistry gR2(F2); |