1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ci// HASH=bf31ee140e2c163c3957276e6d4c4f0c
5cb93a386Sopenharmony_ciREG_FIDDLE(Pixmap_shiftPerPixel, 256, 256, true, 0) {
6cb93a386Sopenharmony_ciconst char* color_type(SkColorType ct) {
7cb93a386Sopenharmony_ci    switch (ct) {
8cb93a386Sopenharmony_ci        case kUnknown_SkColorType:      return "Unknown";
9cb93a386Sopenharmony_ci        case kAlpha_8_SkColorType:      return "Alpha_8";
10cb93a386Sopenharmony_ci        case kRGB_565_SkColorType:      return "RGB_565";
11cb93a386Sopenharmony_ci        case kARGB_4444_SkColorType:    return "ARGB_4444";
12cb93a386Sopenharmony_ci        case kRGBA_8888_SkColorType:    return "RGBA_8888";
13cb93a386Sopenharmony_ci        case kRGB_888x_SkColorType:     return "RGB_888x";
14cb93a386Sopenharmony_ci        case kBGRA_8888_SkColorType:    return "BGRA_8888";
15cb93a386Sopenharmony_ci        case kRGBA_1010102_SkColorType: return "RGBA_1010102";
16cb93a386Sopenharmony_ci        case kRGB_101010x_SkColorType:  return "RGB_101010x";
17cb93a386Sopenharmony_ci        case kGray_8_SkColorType:       return "Gray_8";
18cb93a386Sopenharmony_ci        case kRGBA_F16Norm_SkColorType: return "RGBA_F16Norm";
19cb93a386Sopenharmony_ci        case kRGBA_F16_SkColorType:     return "RGBA_F16";
20cb93a386Sopenharmony_ci        case kRGBA_F32_SkColorType:     return "RGBA_F32";
21cb93a386Sopenharmony_ci        default: SkASSERT(false); return nullptr;
22cb93a386Sopenharmony_ci    }
23cb93a386Sopenharmony_ci}
24cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
25cb93a386Sopenharmony_ci    SkImageInfo info = SkImageInfo::MakeA8(1, 1);
26cb93a386Sopenharmony_ci    for (SkColorType colorType : { kUnknown_SkColorType,   kAlpha_8_SkColorType,
27cb93a386Sopenharmony_ci                                   kRGB_565_SkColorType,   kARGB_4444_SkColorType,
28cb93a386Sopenharmony_ci                                   kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
29cb93a386Sopenharmony_ci                                   kGray_8_SkColorType,    kRGBA_F16_SkColorType } ) {
30cb93a386Sopenharmony_ci        SkPixmap pixmap(info.makeColorType(colorType), nullptr, 4);
31cb93a386Sopenharmony_ci        SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d shiftPerPixel: %d\n",
32cb93a386Sopenharmony_ci                color_type(colorType), (int)(10 - strlen(color_type(colorType))), " ",
33cb93a386Sopenharmony_ci                pixmap.info().bytesPerPixel(), pixmap.shiftPerPixel());
34cb93a386Sopenharmony_ci    }
35cb93a386Sopenharmony_ci}
36cb93a386Sopenharmony_ci}  // END FIDDLE
37