1 | /* |
2 | * Copyright 2022 Google LLC |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #ifndef SkColorType_DEFINED |
9 | #define SkColorType_DEFINED |
10 | |
11 | #include "include/core/SkTypes.h" |
12 | |
13 | /** \enum SkColorType |
14 | Describes how pixel bits encode color. A pixel may be an alpha mask, a grayscale, RGB, or ARGB. |
15 | |
16 | kN32_SkColorType selects the native 32-bit ARGB format for the current configuration. This can |
17 | lead to inconsistent results across platforms, so use with caution. |
18 | */ |
19 | enum SkColorType : int { |
20 | kUnknown_SkColorType, //!< uninitialized |
21 | kAlpha_8_SkColorType, //!< pixel with alpha in 8-bit byte |
22 | kRGB_565_SkColorType, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word |
23 | kARGB_4444_SkColorType, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word |
24 | kRGBA_8888_SkColorType, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word |
25 | kRGB_888x_SkColorType, //!< pixel with 8 bits each for red, green, blue; in 32-bit word |
26 | kBGRA_8888_SkColorType, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word |
27 | kRGBA_1010102_SkColorType, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word |
28 | kBGRA_1010102_SkColorType, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word |
29 | kRGB_101010x_SkColorType, //!< pixel with 10 bits each for red, green, blue; in 32-bit word |
30 | kBGR_101010x_SkColorType, //!< pixel with 10 bits each for blue, green, red; in 32-bit word |
31 | kBGR_101010x_XR_SkColorType, //!< pixel with 10 bits each for blue, green, red; in 32-bit word, extended range |
32 | kGray_8_SkColorType, //!< pixel with grayscale level in 8-bit byte |
33 | kRGBA_F16Norm_SkColorType, //!< pixel with half floats in [0,1] for red, green, blue, alpha; |
34 | // in 64-bit word |
35 | kRGBA_F16_SkColorType, //!< pixel with half floats for red, green, blue, alpha; |
36 | // in 64-bit word |
37 | kRGBA_F32_SkColorType, //!< pixel using C float for red, green, blue, alpha; in 128-bit word |
38 | |
39 | // The following 6 colortypes are just for reading from - not for rendering to |
40 | kR8G8_unorm_SkColorType, //!< pixel with a uint8_t for red and green |
41 | |
42 | kA16_float_SkColorType, //!< pixel with a half float for alpha |
43 | kR16G16_float_SkColorType, //!< pixel with a half float for red and green |
44 | |
45 | kA16_unorm_SkColorType, //!< pixel with a little endian uint16_t for alpha |
46 | kR16G16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red and green |
47 | kR16G16B16A16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red, green, blue |
48 | // and alpha |
49 | |
50 | kSRGBA_8888_SkColorType, |
51 | kR8_unorm_SkColorType, |
52 | |
53 | kLastEnum_SkColorType = kR8_unorm_SkColorType, //!< last valid value |
54 | |
55 | #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) |
56 | kN32_SkColorType = kBGRA_8888_SkColorType,//!< native 32-bit BGRA encoding |
57 | |
58 | #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
59 | kN32_SkColorType = kRGBA_8888_SkColorType,//!< native 32-bit RGBA encoding |
60 | |
61 | #else |
62 | #error "SK_*32_SHIFT values must correspond to BGRA or RGBA byte order" |
63 | #endif |
64 | }; |
65 | static constexpr int kSkColorTypeCnt = static_cast<int>(kLastEnum_SkColorType) + 1; |
66 | |
67 | #endif |
68 | |