• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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.
3 #include "tools/fiddle/examples.h"
4 // HASH=e47b911f94fc629f756a829e523a2a89
5 REG_FIDDLE(ImageInfo_shiftPerPixel, 256, 256, true, 0) {
color_type(SkColorType ct)6 const 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 }
draw(SkCanvas * canvas)24 void 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
38