blob: f83e5f77927061288529705c5b0dc64a23634626 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=e47b911f94fc629f756a829e523a2a89
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(ImageInfo_shiftPerPixel, 256, 256, true, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006const char* color_type(SkColorType ct) {
7 switch (ct) {
8 case kUnknown_SkColorType: return "Unknown";
9 case kAlpha_8_SkColorType: return "Alpha_8";
10 case kRGB_565_SkColorType: return "RGB_565";
11 case kARGB_4444_SkColorType: return "ARGB_4444";
12 case kRGBA_8888_SkColorType: return "RGBA_8888";
13 case kRGB_888x_SkColorType: return "RGB_888x";
14 case kBGRA_8888_SkColorType: return "BGRA_8888";
15 case kRGBA_1010102_SkColorType: return "RGBA_1010102";
16 case kRGB_101010x_SkColorType: return "RGB_101010x";
17 case kGray_8_SkColorType: return "Gray_8";
18 case kRGBA_F16Norm_SkColorType: return "RGBA_F16Norm";
19 case kRGBA_F16_SkColorType: return "RGBA_F16";
20 case kRGBA_F32_SkColorType: return "RGBA_F32";
21 default: SkASSERT(false); return nullptr;
22 }
23}
24void draw(SkCanvas* canvas) {
25 for (SkColorType colorType : {
26 kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
27 kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
28 kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
29 kGray_8_SkColorType, kRGBA_F16_SkColorType
30 } ) {
31 SkImageInfo info = SkImageInfo::Make(1, 1, colorType, kOpaque_SkAlphaType);
32 SkDebugf("color: k" "%s" "_SkColorType" "%*s" "shiftPerPixel: %d\n",
33 color_type(colorType), 14 - strlen(color_type(colorType)), " ",
34 info.shiftPerPixel());
35 }
36}
37} // END FIDDLE