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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "SkSurface.h" | 9 #include "SkSurface.h" |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 default: | 239 default: |
240 SkFAIL("Should not get here - invalid alpha type"); | 240 SkFAIL("Should not get here - invalid alpha type"); |
241 return 0xFF000000; | 241 return 0xFF000000; |
242 } | 242 } |
243 return alpha << 24 | component; | 243 return alpha << 24 | component; |
244 } | 244 } |
245 | 245 |
246 static void make_color_test_bitmap_variant( | 246 static void make_color_test_bitmap_variant( |
247 SkColorType colorType, | 247 SkColorType colorType, |
248 SkAlphaType alphaType, | 248 SkAlphaType alphaType, |
249 sk_sp<SkColorSpace> colorSpace, | 249 SkColorProfileType profile, |
250 SkBitmap* bm) | 250 SkBitmap* bm) |
251 { | 251 { |
252 SkASSERT(colorType == kRGBA_8888_SkColorType || colorType == kBGRA_8888_SkCo
lorType); | 252 SkASSERT(colorType == kRGBA_8888_SkColorType || colorType == kBGRA_8888_SkCo
lorType); |
253 SkASSERT(alphaType == kPremul_SkAlphaType || alphaType == kUnpremul_SkAlphaT
ype); | 253 SkASSERT(alphaType == kPremul_SkAlphaType || alphaType == kUnpremul_SkAlphaT
ype); |
254 bm->allocPixels( | 254 bm->allocPixels( |
255 SkImageInfo::Make(SCALE, SCALE, colorType, alphaType, colorSpace)); | 255 SkImageInfo::Make(SCALE, SCALE, colorType, alphaType, profile)); |
256 SkPixmap pm; | 256 SkPixmap pm; |
257 bm->peekPixels(&pm); | 257 bm->peekPixels(&pm); |
258 for (int y = 0; y < bm->height(); y++) { | 258 for (int y = 0; y < bm->height(); y++) { |
259 for (int x = 0; x < bm->width(); x++) { | 259 for (int x = 0; x < bm->width(); x++) { |
260 *pm.writable_addr32(x, y) = make_pixel(x, y, alphaType); | 260 *pm.writable_addr32(x, y) = make_pixel(x, y, alphaType); |
261 } | 261 } |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 DEF_SIMPLE_GM(all_variants_8888, canvas, 4 * SCALE + 30, 2 * SCALE + 10) { | 265 DEF_SIMPLE_GM(all_variants_8888, canvas, 4 * SCALE + 30, 2 * SCALE + 10) { |
266 sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8); | 266 sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8); |
267 | 267 |
268 sk_sp<SkColorSpace> colorSpaces[] { | 268 for (auto profile : {kSRGB_SkColorProfileType, kLinear_SkColorProfileType})
{ |
269 nullptr, | |
270 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) | |
271 }; | |
272 for (auto colorSpace : colorSpaces) { | |
273 canvas->save(); | 269 canvas->save(); |
274 for (auto alphaType : {kPremul_SkAlphaType, kUnpremul_SkAlphaType}) { | 270 for (auto alphaType : {kPremul_SkAlphaType, kUnpremul_SkAlphaType}) { |
275 canvas->save(); | 271 canvas->save(); |
276 for (auto colorType : {kRGBA_8888_SkColorType, kBGRA_8888_SkColorTyp
e}) { | 272 for (auto colorType : {kRGBA_8888_SkColorType, kBGRA_8888_SkColorTyp
e}) { |
277 SkBitmap bm; | 273 SkBitmap bm; |
278 make_color_test_bitmap_variant(colorType, alphaType, colorSpace,
&bm); | 274 make_color_test_bitmap_variant(colorType, alphaType, profile, &b
m); |
279 canvas->drawBitmap(bm, 0.0f, 0.0f); | 275 canvas->drawBitmap(bm, 0.0f, 0.0f); |
280 canvas->translate(SCALE + 10, 0.0f); | 276 canvas->translate(SCALE + 10, 0.0f); |
281 } | 277 } |
282 canvas->restore(); | 278 canvas->restore(); |
283 canvas->translate(0.0f, SCALE + 10); | 279 canvas->translate(0.0f, SCALE + 10); |
284 } | 280 } |
285 canvas->restore(); | 281 canvas->restore(); |
286 canvas->translate(2 * (SCALE + 10), 0.0f); | 282 canvas->translate(2 * (SCALE + 10), 0.0f); |
287 } | 283 } |
288 } | 284 } |
OLD | NEW |