OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 void onDraw(SkCanvas* canvas) override { | 29 void onDraw(SkCanvas* canvas) override { |
30 canvas->translate(SkIntToScalar(10), SkIntToScalar(20)); | 30 canvas->translate(SkIntToScalar(10), SkIntToScalar(20)); |
31 | 31 |
32 const SkScalar w = SkIntToScalar(kSize); | 32 const SkScalar w = SkIntToScalar(kSize); |
33 const SkScalar h = SkIntToScalar(kSize); | 33 const SkScalar h = SkIntToScalar(kSize); |
34 | 34 |
35 SkPaint labelP; | 35 SkPaint labelP; |
36 labelP.setAntiAlias(true); | 36 labelP.setAntiAlias(true); |
37 sk_tool_utils::set_portable_typeface(&labelP); | 37 sk_tool_utils::set_portable_typeface_always(&labelP); |
38 labelP.setTextAlign(SkPaint::kCenter_Align); | 38 labelP.setTextAlign(SkPaint::kCenter_Align); |
39 | 39 |
40 const int W = 6; | 40 const int W = 6; |
41 | 41 |
42 SkScalar x = 0, y = 0; | 42 SkScalar x = 0, y = 0; |
43 for (size_t m = 0; m <= SkXfermode::kLastMode; m++) { | 43 for (size_t m = 0; m <= SkXfermode::kLastMode; m++) { |
44 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m); | 44 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m); |
45 SkXfermode* xm = SkXfermode::Create(mode); | 45 SkXfermode* xm = SkXfermode::Create(mode); |
46 SkAutoUnref aur(xm); | 46 SkAutoUnref aur(xm); |
47 | 47 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if ((m % W) == W - 1) { | 81 if ((m % W) == W - 1) { |
82 x = 0; | 82 x = 0; |
83 y += h + SkIntToScalar(30); | 83 y += h + SkIntToScalar(30); |
84 } | 84 } |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 private: | 88 private: |
89 void onOnceBeforeDraw() override { | 89 void onOnceBeforeDraw() override { |
90 static const uint32_t kCheckData[] = { | 90 static const uint32_t kCheckData[] = { |
91 SkPackARGB32(0xFF, 0x40, 0x40, 0x40), | 91 SkPackARGB32(0xFF, 0x42, 0x41, 0x42), |
92 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), | 92 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), |
93 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), | 93 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), |
94 SkPackARGB32(0xFF, 0x40, 0x40, 0x40) | 94 SkPackARGB32(0xFF, 0x42, 0x41, 0x42) |
95 }; | 95 }; |
96 SkBitmap bg; | 96 SkBitmap bg; |
97 bg.allocN32Pixels(2, 2, true); | 97 bg.allocN32Pixels(2, 2, true); |
98 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); | 98 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); |
99 | 99 |
100 SkMatrix lm; | 100 SkMatrix lm; |
101 lm.setScale(SkIntToScalar(16), SkIntToScalar(16)); | 101 lm.setScale(SkIntToScalar(16), SkIntToScalar(16)); |
102 fBG.reset(SkShader::CreateBitmapShader(bg, | 102 fBG.reset(SkShader::CreateBitmapShader(bg, |
103 SkShader::kRepeat_TileMode, | 103 SkShader::kRepeat_TileMode, |
104 SkShader::kRepeat_TileMode, | 104 SkShader::kRepeat_TileMode, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 typedef GM INHERITED; | 146 typedef GM INHERITED; |
147 }; | 147 }; |
148 | 148 |
149 ////////////////////////////////////////////////////////////////////////////// | 149 ////////////////////////////////////////////////////////////////////////////// |
150 | 150 |
151 static GM* MyFactory(void*) { return new Xfermodes2GM; } | 151 static GM* MyFactory(void*) { return new Xfermodes2GM; } |
152 static GMRegistry reg(MyFactory); | 152 static GMRegistry reg(MyFactory); |
153 | 153 |
154 } | 154 } |
OLD | NEW |