OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkShader.h" | 10 #include "SkShader.h" |
11 | 11 |
12 // Inspired by svg/as-border-image/svg-as-border-image.html. Draws a four-color
checker board bitmap | 12 // Inspired by svg/as-border-image/svg-as-border-image.html. Draws a four-color
checker board bitmap |
13 // such that it is stretched and repeat tiled with different filter qualities. I
t is testing whether | 13 // such that it is stretched and repeat tiled with different filter qualities. I
t is testing whether |
14 // the bmp filter respects the repeat mode at the tile seams. | 14 // the bmp filter respects the repeat mode at the tile seams. |
15 class BmpFilterQualityRepeat : public skiagm::GM { | 15 class BmpFilterQualityRepeat : public skiagm::GM { |
16 public: | 16 public: |
17 BmpFilterQualityRepeat() { this->setBGColor(sk_tool_utils::color_to_565(0xFF
CCBBAA)); } | 17 BmpFilterQualityRepeat() { this->setBGColor(sk_tool_utils::color_to_565(0xFF
CCBBAA)); } |
18 | 18 |
19 protected: | 19 protected: |
20 | 20 |
21 void onOnceBeforeDraw() override { | 21 void onOnceBeforeDraw() override { |
22 fBmp.allocN32Pixels(40, 40, true); | 22 fBmp.allocN32Pixels(40, 40, true); |
23 SkCanvas canvas(fBmp); | 23 SkCanvas canvas(fBmp); |
24 SkBitmap colorBmp; | 24 SkBitmap colorBmp; |
25 colorBmp.allocN32Pixels(20, 20, true); | 25 colorBmp.allocN32Pixels(20, 20, true); |
26 colorBmp.eraseColor(0xFFFF0000); | 26 colorBmp.eraseColor(0xFFFF0000); |
27 canvas.drawBitmap(colorBmp, 0, 0); | 27 canvas.drawBitmap(colorBmp, 0, 0); |
28 colorBmp.eraseColor(0xFF008200); | 28 colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF008200)); |
29 canvas.drawBitmap(colorBmp, 20, 0); | 29 canvas.drawBitmap(colorBmp, 20, 0); |
30 colorBmp.eraseColor(0xFFFF9000); | 30 colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFFFF9000)); |
31 canvas.drawBitmap(colorBmp, 0, 20); | 31 canvas.drawBitmap(colorBmp, 0, 20); |
32 colorBmp.eraseColor(0xFF2000FF); | 32 colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF2000FF)); |
33 canvas.drawBitmap(colorBmp, 20, 20); | 33 canvas.drawBitmap(colorBmp, 20, 20); |
34 } | 34 } |
35 | 35 |
36 SkString onShortName() override { return SkString("bmp_filter_quality_repeat
"); } | 36 SkString onShortName() override { return SkString("bmp_filter_quality_repeat
"); } |
37 | 37 |
38 SkISize onISize() override { return SkISize::Make(1000, 235); } | 38 SkISize onISize() override { return SkISize::Make(1000, 235); } |
39 | 39 |
40 void onDraw(SkCanvas* canvas) override { | 40 void onDraw(SkCanvas* canvas) override { |
41 | 41 |
42 static const struct { | 42 static const struct { |
(...skipping 28 matching lines...) Expand all Loading... |
71 | 71 |
72 private: | 72 private: |
73 SkBitmap fBmp; | 73 SkBitmap fBmp; |
74 | 74 |
75 typedef skiagm::GM INHERITED; | 75 typedef skiagm::GM INHERITED; |
76 }; | 76 }; |
77 | 77 |
78 ////////////////////////////////////////////////////////////////////////////// | 78 ////////////////////////////////////////////////////////////////////////////// |
79 | 79 |
80 DEF_GM( return SkNEW(BmpFilterQualityRepeat); ) | 80 DEF_GM( return SkNEW(BmpFilterQualityRepeat); ) |
OLD | NEW |