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 "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 SkString onShortName() override { | 30 SkString onShortName() override { |
31 return SkString("xfermodes3"); | 31 return SkString("xfermodes3"); |
32 } | 32 } |
33 | 33 |
34 SkISize onISize() override { | 34 SkISize onISize() override { |
35 return SkISize::Make(630, 1215); | 35 return SkISize::Make(630, 1215); |
36 } | 36 } |
37 | 37 |
38 void onDrawBackground(SkCanvas* canvas) override { | 38 void onDrawBackground(SkCanvas* canvas) override { |
39 SkPaint bgPaint; | 39 SkPaint bgPaint; |
40 bgPaint.setColor(0xFF70D0E0); | 40 bgPaint.setColor(sk_tool_utils::color_to_565(0xFF70D0E0)); |
41 canvas->drawPaint(bgPaint); | 41 canvas->drawPaint(bgPaint); |
42 } | 42 } |
43 | 43 |
44 void onDraw(SkCanvas* canvas) override { | 44 void onDraw(SkCanvas* canvas) override { |
45 canvas->translate(SkIntToScalar(10), SkIntToScalar(20)); | 45 canvas->translate(SkIntToScalar(10), SkIntToScalar(20)); |
46 | 46 |
47 SkPaint labelP; | 47 SkPaint labelP; |
48 labelP.setAntiAlias(true); | 48 labelP.setAntiAlias(true); |
49 sk_tool_utils::set_portable_typeface(&labelP); | 49 sk_tool_utils::set_portable_typeface_always(&labelP); |
50 | 50 |
51 static const SkColor kSolidColors[] = { | 51 static const SkColor kSolidColors[] = { |
52 SK_ColorTRANSPARENT, | 52 SK_ColorTRANSPARENT, |
53 SK_ColorBLUE, | 53 SK_ColorBLUE, |
54 0x80808000 | 54 0x80808000 |
55 }; | 55 }; |
56 | 56 |
57 static const SkColor kBmpAlphas[] = { | 57 static const SkColor kBmpAlphas[] = { |
58 0xff, | 58 0xff, |
59 0x80, | 59 0x80, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); | 174 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); |
175 SkPaint borderPaint; | 175 SkPaint borderPaint; |
176 borderPaint.setStyle(SkPaint::kStroke_Style); | 176 borderPaint.setStyle(SkPaint::kStroke_Style); |
177 canvas->drawRect(r, borderPaint); | 177 canvas->drawRect(r, borderPaint); |
178 | 178 |
179 canvas->restore(); | 179 canvas->restore(); |
180 } | 180 } |
181 | 181 |
182 void onOnceBeforeDraw() override { | 182 void onOnceBeforeDraw() override { |
183 static const uint32_t kCheckData[] = { | 183 static const uint32_t kCheckData[] = { |
184 SkPackARGB32(0xFF, 0x40, 0x40, 0x40), | 184 SkPackARGB32(0xFF, 0x42, 0x41, 0x42), |
185 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), | 185 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), |
186 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), | 186 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), |
187 SkPackARGB32(0xFF, 0x40, 0x40, 0x40) | 187 SkPackARGB32(0xFF, 0x42, 0x41, 0x42) |
188 }; | 188 }; |
189 SkBitmap bg; | 189 SkBitmap bg; |
190 bg.allocN32Pixels(2, 2, true); | 190 bg.allocN32Pixels(2, 2, true); |
191 SkAutoLockPixels bgAlp(bg); | 191 SkAutoLockPixels bgAlp(bg); |
192 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); | 192 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); |
193 | 193 |
194 SkMatrix lm; | 194 SkMatrix lm; |
195 lm.setScale(SkIntToScalar(kCheckSize), SkIntToScalar(kCheckSize)); | 195 lm.setScale(SkIntToScalar(kCheckSize), SkIntToScalar(kCheckSize)); |
196 fBGShader.reset(SkShader::CreateBitmapShader(bg, | 196 fBGShader.reset(SkShader::CreateBitmapShader(bg, |
197 SkShader::kRepeat_TileMode, | 197 SkShader::kRepeat_TileMode, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 SkAutoTUnref<SkShader> fBmpShader; | 233 SkAutoTUnref<SkShader> fBmpShader; |
234 | 234 |
235 typedef GM INHERITED; | 235 typedef GM INHERITED; |
236 }; | 236 }; |
237 | 237 |
238 ////////////////////////////////////////////////////////////////////////////// | 238 ////////////////////////////////////////////////////////////////////////////// |
239 | 239 |
240 DEF_GM(return new Xfermodes3GM;) | 240 DEF_GM(return new Xfermodes3GM;) |
241 | 241 |
242 } | 242 } |
OLD | NEW |