| 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 |
REG_FIDDLE(Pixmap_shiftPerPixel, 256, 256, true, 0) { |
| 5 |
const char* color_type(SkColorType ct) { |
| 6 |
switch (ct) { |
| 7 |
case kUnknown_SkColorType: return "Unknown"; |
| 8 |
case kAlpha_8_SkColorType: return "Alpha_8"; |
| 9 |
case kRGB_565_SkColorType: return "RGB_565"; |
| 10 |
case kARGB_4444_SkColorType: return "ARGB_4444"; |
| 11 |
case kRGBA_8888_SkColorType: return "RGBA_8888"; |
| 12 |
case kRGB_888x_SkColorType: return "RGB_888x"; |
| 13 |
case kBGRA_8888_SkColorType: return "BGRA_8888"; |
| 14 |
case kRGBA_1010102_SkColorType: return "RGBA_1010102"; |
| 15 |
case kRGB_101010x_SkColorType: return "RGB_101010x"; |
| 16 |
case kGray_8_SkColorType: return "Gray_8"; |
| 17 |
case kRGBA_F16Norm_SkColorType: return "RGBA_F16Norm"; |
| 18 |
case kRGBA_F16_SkColorType: return "RGBA_F16"; |
| 19 |
case kRGBA_F32_SkColorType: return "RGBA_F32"; |
| 20 |
default: SkASSERT(false); return nullptr; |
| 21 |
} |
| 22 |
} |
| 23 |
void draw(SkCanvas* canvas) { |
| 24 |
SkImageInfo info = SkImageInfo::MakeA8(1, 1); |
| 25 |
for (SkColorType colorType : { kUnknown_SkColorType, kAlpha_8_SkColorType, |
| 26 |
kRGB_565_SkColorType, kARGB_4444_SkColorType, |
| 27 |
kRGBA_8888_SkColorType, kBGRA_8888_SkColorType, |
| 28 |
kGray_8_SkColorType, kRGBA_F16_SkColorType } ) { |
| 29 |
SkPixmap pixmap(info.makeColorType(colorType), nullptr, 4); |
| 30 |
SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d shiftPerPixel: %d\n", |
| 31 |
color_type(colorType), (int)(10 - strlen(color_type(colorType))), " ", |
| 32 |
pixmap.info().bytesPerPixel(), pixmap.shiftPerPixel()); |
| 33 |
} |
| 34 |
} |
| 35 |
} // END FIDDLE |