blob: cd48ad9929f4fc219439d87b5c59db36026142ac [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=bf31ee140e2c163c3957276e6d4c4f0c
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Pixmap_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 SkImageInfo info = SkImageInfo::MakeA8(1, 1);
26 for (SkColorType colorType : { kUnknown_SkColorType, kAlpha_8_SkColorType,
27 kRGB_565_SkColorType, kARGB_4444_SkColorType,
28 kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
29 kGray_8_SkColorType, kRGBA_F16_SkColorType } ) {
30 SkPixmap pixmap(info.makeColorType(colorType), nullptr, 4);
31 SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d shiftPerPixel: %d\n",
32 color_type(colorType), 10 - strlen(color_type(colorType)), " ",
33 pixmap.info().bytesPerPixel(), pixmap.shiftPerPixel());
34 }
35}
36} // END FIDDLE