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 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), | 178 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), |
179 SkPackARGB32(0xFF, 0x42, 0x41, 0x42) | 179 SkPackARGB32(0xFF, 0x42, 0x41, 0x42) |
180 }; | 180 }; |
181 SkBitmap bg; | 181 SkBitmap bg; |
182 bg.allocN32Pixels(2, 2, true); | 182 bg.allocN32Pixels(2, 2, true); |
183 SkAutoLockPixels bgAlp(bg); | 183 SkAutoLockPixels bgAlp(bg); |
184 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); | 184 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); |
185 | 185 |
186 SkMatrix lm; | 186 SkMatrix lm; |
187 lm.setScale(SkIntToScalar(kCheckSize), SkIntToScalar(kCheckSize)); | 187 lm.setScale(SkIntToScalar(kCheckSize), SkIntToScalar(kCheckSize)); |
188 fBGShader = SkShader::MakeBitmapShader(bg, SkShader::kRepeat_TileMode, | 188 fBGShader.reset(SkShader::CreateBitmapShader(bg, |
189 SkShader::kRepeat_TileMode, &lm); | 189 SkShader::kRepeat_TileMode, |
| 190 SkShader::kRepeat_TileMode, |
| 191 &lm)); |
190 | 192 |
191 SkPaint bmpPaint; | 193 SkPaint bmpPaint; |
192 const SkPoint kCenter = { SkIntToScalar(kSize) / 2, SkIntToScalar(kSize)
/ 2 }; | 194 static const SkPoint kCenter = { SkIntToScalar(kSize) / 2, SkIntToScalar
(kSize) / 2 }; |
193 const SkColor kColors[] = { | 195 static const SkColor kColors[] = { SK_ColorTRANSPARENT, 0x80800000, |
194 SK_ColorTRANSPARENT, 0x80800000, 0xF020F060, SK_ColorWHITE | 196 0xF020F060, SK_ColorWHITE }; |
195 }; | 197 bmpPaint.setShader(SkGradientShader::CreateRadial(kCenter, |
196 bmpPaint.setShader(SkGradientShader::MakeRadial(kCenter, 3 * SkIntToScal
ar(kSize) / 4, | 198 3 * SkIntToScalar(kSiz
e) / 4, |
197 kColors, nullptr, SK_ARR
AY_COUNT(kColors), | 199 kColors, |
198 SkShader::kRepeat_TileMo
de)); | 200 nullptr, |
| 201 SK_ARRAY_COUNT(kColors
), |
| 202 SkShader::kRepeat_Tile
Mode))->unref(); |
199 | 203 |
200 SkBitmap bmp; | 204 SkBitmap bmp; |
201 bmp.allocN32Pixels(kSize, kSize); | 205 bmp.allocN32Pixels(kSize, kSize); |
202 SkCanvas bmpCanvas(bmp); | 206 SkCanvas bmpCanvas(bmp); |
203 | 207 |
204 bmpCanvas.clear(SK_ColorTRANSPARENT); | 208 bmpCanvas.clear(SK_ColorTRANSPARENT); |
205 SkRect rect = { SkIntToScalar(kSize) / 8, SkIntToScalar(kSize) / 8, | 209 SkRect rect = { SkIntToScalar(kSize) / 8, SkIntToScalar(kSize) / 8, |
206 7 * SkIntToScalar(kSize) / 8, 7 * SkIntToScalar(kSize) /
8}; | 210 7 * SkIntToScalar(kSize) / 8, 7 * SkIntToScalar(kSize) /
8}; |
207 bmpCanvas.drawRect(rect, bmpPaint); | 211 bmpCanvas.drawRect(rect, bmpPaint); |
208 | 212 |
209 fBmpShader = SkShader::MakeBitmapShader(bmp, SkShader::kClamp_TileMode, | 213 fBmpShader.reset(SkShader::CreateBitmapShader(bmp, |
210 SkShader::kClamp_TileMode); | 214 SkShader::kClamp_TileMode, |
| 215 SkShader::kClamp_TileMode)
); |
211 } | 216 } |
212 | 217 |
213 enum { | 218 enum { |
214 kCheckSize = 8, | 219 kCheckSize = 8, |
215 kSize = 30, | 220 kSize = 30, |
216 kTestsPerRow = 15, | 221 kTestsPerRow = 15, |
217 }; | 222 }; |
218 | 223 |
219 sk_sp<SkShader> fBGShader; | 224 SkAutoTUnref<SkShader> fBGShader; |
220 sk_sp<SkShader> fBmpShader; | 225 SkAutoTUnref<SkShader> fBmpShader; |
221 | 226 |
222 typedef GM INHERITED; | 227 typedef GM INHERITED; |
223 }; | 228 }; |
224 | 229 |
225 ////////////////////////////////////////////////////////////////////////////// | 230 ////////////////////////////////////////////////////////////////////////////// |
226 | 231 |
227 DEF_GM(return new Xfermodes3GM;) | 232 DEF_GM(return new Xfermodes3GM;) |
228 | 233 |
229 } | 234 } |
OLD | NEW |