Flutter Engine
The Flutter Engine
Classes | Enumerations | Functions
SkImageInfo.h File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkColorType.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSize.h"
#include "include/private/base/SkAPI.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkMath.h"
#include "include/private/base/SkTFitsIn.h"
#include <cstddef>
#include <cstdint>
#include <utility>

Go to the source code of this file.

Classes

struct  SkColorInfo
 
struct  SkImageInfo
 

Enumerations

enum  SkYUVColorSpace : int {
  kJPEG_Full_SkYUVColorSpace , kRec601_Limited_SkYUVColorSpace , kRec709_Full_SkYUVColorSpace , kRec709_Limited_SkYUVColorSpace ,
  kBT2020_8bit_Full_SkYUVColorSpace , kBT2020_8bit_Limited_SkYUVColorSpace , kBT2020_10bit_Full_SkYUVColorSpace , kBT2020_10bit_Limited_SkYUVColorSpace ,
  kBT2020_12bit_Full_SkYUVColorSpace , kBT2020_12bit_Limited_SkYUVColorSpace , kFCC_Full_SkYUVColorSpace , kFCC_Limited_SkYUVColorSpace ,
  kSMPTE240_Full_SkYUVColorSpace , kSMPTE240_Limited_SkYUVColorSpace , kYDZDX_Full_SkYUVColorSpace , kYDZDX_Limited_SkYUVColorSpace ,
  kGBR_Full_SkYUVColorSpace , kGBR_Limited_SkYUVColorSpace , kYCgCo_8bit_Full_SkYUVColorSpace , kYCgCo_8bit_Limited_SkYUVColorSpace ,
  kYCgCo_10bit_Full_SkYUVColorSpace , kYCgCo_10bit_Limited_SkYUVColorSpace , kYCgCo_12bit_Full_SkYUVColorSpace , kYCgCo_12bit_Limited_SkYUVColorSpace ,
  kIdentity_SkYUVColorSpace , kLastEnum_SkYUVColorSpace = kIdentity_SkYUVColorSpace , kJPEG_SkYUVColorSpace = kJPEG_Full_SkYUVColorSpace , kRec601_SkYUVColorSpace = kRec601_Limited_SkYUVColorSpace ,
  kRec709_SkYUVColorSpace = kRec709_Limited_SkYUVColorSpace , kBT2020_SkYUVColorSpace = kBT2020_8bit_Limited_SkYUVColorSpace
}
 

Functions

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

Enumeration Type Documentation

◆ SkYUVColorSpace

Enumerator
kJPEG_Full_SkYUVColorSpace 

describes full range

kRec601_Limited_SkYUVColorSpace 

describes SDTV range

kRec709_Full_SkYUVColorSpace 

describes HDTV range

kRec709_Limited_SkYUVColorSpace 
kBT2020_8bit_Full_SkYUVColorSpace 

describes UHDTV range, non-constant-luminance

kBT2020_8bit_Limited_SkYUVColorSpace 
kBT2020_10bit_Full_SkYUVColorSpace 
kBT2020_10bit_Limited_SkYUVColorSpace 
kBT2020_12bit_Full_SkYUVColorSpace 
kBT2020_12bit_Limited_SkYUVColorSpace 
kFCC_Full_SkYUVColorSpace 

describes FCC range

kFCC_Limited_SkYUVColorSpace 
kSMPTE240_Full_SkYUVColorSpace 

describes SMPTE240M range

kSMPTE240_Limited_SkYUVColorSpace 
kYDZDX_Full_SkYUVColorSpace 

describes YDZDX range

kYDZDX_Limited_SkYUVColorSpace 
kGBR_Full_SkYUVColorSpace 

describes GBR range

kGBR_Limited_SkYUVColorSpace 
kYCgCo_8bit_Full_SkYUVColorSpace 

describes YCgCo matrix

kYCgCo_8bit_Limited_SkYUVColorSpace 
kYCgCo_10bit_Full_SkYUVColorSpace 
kYCgCo_10bit_Limited_SkYUVColorSpace 
kYCgCo_12bit_Full_SkYUVColorSpace 
kYCgCo_12bit_Limited_SkYUVColorSpace 
kIdentity_SkYUVColorSpace 

maps Y->R, U->G, V->B

kLastEnum_SkYUVColorSpace 

last valid value

kJPEG_SkYUVColorSpace 
kRec601_SkYUVColorSpace 
kRec709_SkYUVColorSpace 
kBT2020_SkYUVColorSpace 

Definition at line 68 of file SkImageInfo.h.

68 : int {
69 kJPEG_Full_SkYUVColorSpace, //!< describes full range
70 kRec601_Limited_SkYUVColorSpace, //!< describes SDTV range
71 kRec709_Full_SkYUVColorSpace, //!< describes HDTV range
73 kBT2020_8bit_Full_SkYUVColorSpace, //!< describes UHDTV range, non-constant-luminance
79 kFCC_Full_SkYUVColorSpace, //!< describes FCC range
81 kSMPTE240_Full_SkYUVColorSpace, //!< describes SMPTE240M range
83 kYDZDX_Full_SkYUVColorSpace, //!< describes YDZDX range
85 kGBR_Full_SkYUVColorSpace, //!< describes GBR range
87 kYCgCo_8bit_Full_SkYUVColorSpace, //!< describes YCgCo matrix
93 kIdentity_SkYUVColorSpace, //!< maps Y->R, U->G, V->B
94
96
97 // Legacy (deprecated) names:
102};
@ kRec709_Full_SkYUVColorSpace
describes HDTV range
Definition: SkImageInfo.h:71
@ kYCgCo_10bit_Full_SkYUVColorSpace
Definition: SkImageInfo.h:89
@ kYCgCo_12bit_Full_SkYUVColorSpace
Definition: SkImageInfo.h:91
@ kYCgCo_12bit_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:92
@ kYCgCo_10bit_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:90
@ kGBR_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:86
@ kBT2020_8bit_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:74
@ kBT2020_SkYUVColorSpace
Definition: SkImageInfo.h:101
@ kFCC_Full_SkYUVColorSpace
describes FCC range
Definition: SkImageInfo.h:79
@ kJPEG_SkYUVColorSpace
Definition: SkImageInfo.h:98
@ kLastEnum_SkYUVColorSpace
last valid value
Definition: SkImageInfo.h:95
@ kYCgCo_8bit_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:88
@ kYDZDX_Full_SkYUVColorSpace
describes YDZDX range
Definition: SkImageInfo.h:83
@ kRec601_SkYUVColorSpace
Definition: SkImageInfo.h:99
@ kFCC_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:80
@ kBT2020_12bit_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:78
@ kYCgCo_8bit_Full_SkYUVColorSpace
describes YCgCo matrix
Definition: SkImageInfo.h:87
@ kBT2020_8bit_Full_SkYUVColorSpace
describes UHDTV range, non-constant-luminance
Definition: SkImageInfo.h:73
@ kRec601_Limited_SkYUVColorSpace
describes SDTV range
Definition: SkImageInfo.h:70
@ kRec709_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:72
@ kSMPTE240_Full_SkYUVColorSpace
describes SMPTE240M range
Definition: SkImageInfo.h:81
@ kGBR_Full_SkYUVColorSpace
describes GBR range
Definition: SkImageInfo.h:85
@ kSMPTE240_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:82
@ kBT2020_12bit_Full_SkYUVColorSpace
Definition: SkImageInfo.h:77
@ kBT2020_10bit_Full_SkYUVColorSpace
Definition: SkImageInfo.h:75
@ kRec709_SkYUVColorSpace
Definition: SkImageInfo.h:100
@ kIdentity_SkYUVColorSpace
maps Y->R, U->G, V->B
Definition: SkImageInfo.h:93
@ kBT2020_10bit_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:76
@ kYDZDX_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:84
@ kJPEG_Full_SkYUVColorSpace
describes full range
Definition: SkImageInfo.h:69

Function Documentation

◆ SkColorTypeBytesPerPixel()

SK_API 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()

SK_API 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()

SK_API 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)