Flutter Engine
The Flutter Engine
Functions
SkImageInfo.cpp File Reference
#include "include/core/SkImageInfo.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorSpace.h"
#include "include/private/base/SkAssert.h"
#include "src/base/SkSafeMath.h"
#include "src/core/SkImageInfoPriv.h"

Go to the source code of this file.

Functions

int SkColorTypeBytesPerPixel (SkColorType ct)
 
bool SkColorTypeIsAlwaysOpaque (SkColorType ct)
 
bool SkColorTypeValidateAlphaType (SkColorType colorType, SkAlphaType alphaType, SkAlphaType *canonical)
 

Function Documentation

◆ SkColorTypeBytesPerPixel()

int SkColorTypeBytesPerPixel ( SkColorType  ct)

Returns the number of bytes required to store a pixel, including unused padding. Returns zero if ct is kUnknown_SkColorType or invalid.

Returns
bytes per pixel

Definition at line 16 of file SkImageInfo.cpp.

16 {
17 switch (ct) {
18 case kUnknown_SkColorType: return 0;
19 case kAlpha_8_SkColorType: return 1;
20 case kRGB_565_SkColorType: return 2;
21 case kARGB_4444_SkColorType: return 2;
22 case kRGBA_8888_SkColorType: return 4;
23 case kBGRA_8888_SkColorType: return 4;
24 case kRGB_888x_SkColorType: return 4;
25 case kRGBA_1010102_SkColorType: return 4;
26 case kRGB_101010x_SkColorType: return 4;
27 case kBGRA_1010102_SkColorType: return 4;
28 case kBGR_101010x_SkColorType: return 4;
29 case kBGR_101010x_XR_SkColorType: return 4;
30 case kBGRA_10101010_XR_SkColorType: return 8;
31 case kRGBA_10x6_SkColorType: return 8;
32 case kGray_8_SkColorType: return 1;
33 case kRGBA_F16Norm_SkColorType: return 8;
34 case kRGBA_F16_SkColorType: return 8;
35 case kRGBA_F32_SkColorType: return 16;
36 case kR8G8_unorm_SkColorType: return 2;
37 case kA16_unorm_SkColorType: return 2;
38 case kR16G16_unorm_SkColorType: return 4;
39 case kA16_float_SkColorType: return 2;
40 case kR16G16_float_SkColorType: return 4;
42 case kSRGBA_8888_SkColorType: return 4;
43 case kR8_unorm_SkColorType: return 1;
44 }
46}
#define SkUNREACHABLE
Definition: SkAssert.h:135
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
Definition: SkColorType.h:50
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
Definition: SkColorType.h:33
@ kR8_unorm_SkColorType
Definition: SkColorType.h:54
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
Definition: SkColorType.h:30
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition: SkColorType.h:23
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
Definition: SkColorType.h:43
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
Definition: SkColorType.h:48
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition: SkColorType.h:21
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
Definition: SkColorType.h:29
@ kSRGBA_8888_SkColorType
Definition: SkColorType.h:53
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
Definition: SkColorType.h:32
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
Definition: SkColorType.h:25
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
Definition: SkColorType.h:28
@ kA16_float_SkColorType
pixel with a half float for alpha
Definition: SkColorType.h:45
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
Definition: SkColorType.h:40
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition: SkColorType.h:27
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Definition: SkColorType.h:31
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
Definition: SkColorType.h:49
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
Definition: SkColorType.h:36
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20
@ kR16G16_float_SkColorType
pixel with a half float for red and green
Definition: SkColorType.h:46

◆ SkColorTypeIsAlwaysOpaque()

bool SkColorTypeIsAlwaysOpaque ( SkColorType  ct)

Returns true if SkColorType always decodes alpha to 1.0, making the pixel fully opaque. If true, SkColorType does not reserve bits to encode alpha.

Returns
true if alpha is always set to 1.0

Definition at line 48 of file SkImageInfo.cpp.

48 {
50}
@ kAlpha_SkColorChannelFlag
Definition: SkColor.h:242
static uint32_t SkColorTypeChannelFlags(SkColorType ct)

◆ SkColorTypeValidateAlphaType()

bool SkColorTypeValidateAlphaType ( SkColorType  colorType,
SkAlphaType  alphaType,
SkAlphaType canonical = nullptr 
)

Returns true if canonical can be set to a valid SkAlphaType for colorType. If there is more than one valid canonical SkAlphaType, set to alphaType, if valid. If true is returned and canonical is not nullptr, store valid SkAlphaType.

Returns false only if alphaType is kUnknown_SkAlphaType, color type is not kUnknown_SkColorType, and SkColorType is not always opaque. If false is returned, canonical is ignored.

Parameters
canonicalstorage for SkAlphaType
Returns
true if valid SkAlphaType can be associated with colorType

Definition at line 194 of file SkImageInfo.cpp.

195 {
196 switch (colorType) {
198 alphaType = kUnknown_SkAlphaType;
199 break;
200 case kAlpha_8_SkColorType: // fall-through
201 case kA16_unorm_SkColorType: // fall-through
203 if (kUnpremul_SkAlphaType == alphaType) {
204 alphaType = kPremul_SkAlphaType;
205 }
206 [[fallthrough]];
219 if (kUnknown_SkAlphaType == alphaType) {
220 return false;
221 }
222 break;
233 alphaType = kOpaque_SkAlphaType;
234 break;
235 }
236 if (canonical) {
237 *canonical = alphaType;
238 }
239 return true;
240}
kUnpremul_SkAlphaType
@ kUnknown_SkAlphaType
uninitialized
Definition: SkAlphaType.h:27
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)