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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 canvas->translate(0.0f, SkIntToScalar(SCALE)); | 184 canvas->translate(0.0f, SkIntToScalar(SCALE)); |
185 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType); | 185 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType); |
186 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8"); | 186 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8"); |
187 | 187 |
188 p.setColor(SK_ColorRED); | 188 p.setColor(SK_ColorRED); |
189 canvas->translate(0.0f, SkIntToScalar(SCALE)); | 189 canvas->translate(0.0f, SkIntToScalar(SCALE)); |
190 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType); | 190 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType); |
191 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8"); | 191 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8"); |
192 } | 192 } |
| 193 |
| 194 // Works on Ganesh, fails on Raster. |
| 195 SkImage* make_not_native32_color_wheel() { |
| 196 SkBitmap n32bitmap, notN32bitmap; |
| 197 n32bitmap.allocN32Pixels(SCALE, SCALE); |
| 198 n32bitmap.eraseColor(SK_ColorTRANSPARENT); |
| 199 SkCanvas n32canvas(n32bitmap); |
| 200 color_wheel_native(&n32canvas); |
| 201 n32canvas.flush(); |
| 202 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) |
| 203 const SkColorType ct = kRGBA_8888_SkColorType; |
| 204 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
| 205 const SkColorType ct = kBGRA_8888_SkColorType; |
| 206 #endif |
| 207 static_assert(ct != kN32_SkColorType, "BRGA!=RGBA"); |
| 208 SkAssertResult(n32bitmap.copyTo(¬N32bitmap, ct)); |
| 209 SkASSERT(notN32bitmap.colorType() == ct); |
| 210 return SkImage::NewFromBitmap(notN32bitmap); |
| 211 } |
| 212 |
| 213 DEF_SIMPLE_GM(not_native32_bitmap_config, canvas, SCALE, SCALE) { |
| 214 SkAutoTUnref<SkImage> notN32image(make_not_native32_color_wheel()); |
| 215 SkASSERT(notN32image); |
| 216 sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8); |
| 217 canvas->drawImage(notN32image, 0.0f, 0.0f); |
| 218 } |
OLD | NEW |