Flutter Engine
The Flutter Engine
SkImageInfoPriv.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
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 SkImageInfoPriv_DEFINED
9#define SkImageInfoPriv_DEFINED
10
14
15static inline uint32_t SkColorTypeChannelFlags(SkColorType ct) {
16 switch (ct) {
17 case kUnknown_SkColorType: return 0;
43 }
45}
46
47static inline bool SkColorTypeIsAlphaOnly(SkColorType ct) {
49}
50
51static inline bool SkAlphaTypeIsValid(unsigned value) {
53}
54
56 switch (ct) {
57 case kUnknown_SkColorType: return 0;
58 case kAlpha_8_SkColorType: return 0;
59 case kRGB_565_SkColorType: return 1;
60 case kARGB_4444_SkColorType: return 1;
61 case kRGBA_8888_SkColorType: return 2;
62 case kRGB_888x_SkColorType: return 2;
63 case kBGRA_8888_SkColorType: return 2;
64 case kRGBA_1010102_SkColorType: return 2;
65 case kRGB_101010x_SkColorType: return 2;
66 case kBGRA_1010102_SkColorType: return 2;
67 case kBGR_101010x_SkColorType: return 2;
68 case kBGR_101010x_XR_SkColorType: return 2;
69 case kBGRA_10101010_XR_SkColorType: return 3;
70 case kRGBA_10x6_SkColorType: return 3;
71 case kGray_8_SkColorType: return 0;
72 case kRGBA_F16Norm_SkColorType: return 3;
73 case kRGBA_F16_SkColorType: return 3;
74 case kRGBA_F32_SkColorType: return 4;
75 case kR8G8_unorm_SkColorType: return 1;
76 case kA16_unorm_SkColorType: return 1;
77 case kR16G16_unorm_SkColorType: return 2;
78 case kA16_float_SkColorType: return 1;
79 case kR16G16_float_SkColorType: return 2;
81 case kSRGBA_8888_SkColorType: return 2;
82 case kR8_unorm_SkColorType: return 0;
83 }
85}
86
87static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) {
88 return (size_t)(width * SkColorTypeBytesPerPixel(ct));
89}
90
91static inline bool SkColorTypeIsValid(unsigned value) {
93}
94
95static inline size_t SkColorTypeComputeOffset(SkColorType ct, int x, int y, size_t rowBytes) {
96 if (kUnknown_SkColorType == ct) {
97 return 0;
98 }
99 return (size_t)y * rowBytes + ((size_t)x << SkColorTypeShiftPerPixel(ct));
100}
101
102static inline bool SkColorTypeIsNormalized(SkColorType ct) {
103 switch (ct) {
120 case kA16_float_SkColorType: /*subtle... alpha is always [0,1]*/
125 return true;
126
132 return false;
133 }
135}
136
138 switch (ct) {
140 return 0;
141
143 return 4;
144
146 return 6;
147
156 return 8;
157
165 return 10;
166
174 return 16;
175
177 return 32;
178 }
180}
181
182/**
183 * Returns true if |info| contains a valid colorType and alphaType.
184 */
185static inline bool SkColorInfoIsValid(const SkColorInfo& info) {
186 return info.colorType() != kUnknown_SkColorType && info.alphaType() != kUnknown_SkAlphaType;
187}
188
189/**
190 * Returns true if |info| contains a valid combination of width, height and colorInfo.
191 */
192static inline bool SkImageInfoIsValid(const SkImageInfo& info) {
193 if (info.width() <= 0 || info.height() <= 0) {
194 return false;
195 }
196
197 const int kMaxDimension = SK_MaxS32 >> 2;
198 if (info.width() > kMaxDimension || info.height() > kMaxDimension) {
199 return false;
200 }
201
202 return SkColorInfoIsValid(info.colorInfo());
203}
204
205/**
206 * Returns true if Skia has defined a pixel conversion from the |src| to the |dst|.
207 * Returns false otherwise.
208 */
209static inline bool SkImageInfoValidConversion(const SkImageInfo& dst, const SkImageInfo& src) {
211}
212#endif // SkImageInfoPriv_DEFINED
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kUnknown_SkAlphaType
uninitialized
Definition: SkAlphaType.h:27
@ kLastEnum_SkAlphaType
last valid value
Definition: SkAlphaType.h:31
#define SkUNREACHABLE
Definition: SkAssert.h:135
SkColorType
Definition: SkColorType.h:19
@ 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
@ kLastEnum_SkColorType
last valid value
Definition: SkColorType.h:56
@ 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
@ kRGB_SkColorChannelFlags
Definition: SkColor.h:247
@ kRGBA_SkColorChannelFlags
Definition: SkColor.h:248
@ kRed_SkColorChannelFlag
Definition: SkColor.h:239
@ kRG_SkColorChannelFlags
Definition: SkColor.h:246
@ kAlpha_SkColorChannelFlag
Definition: SkColor.h:242
@ kGray_SkColorChannelFlag
Definition: SkColor.h:243
static uint32_t SkColorTypeChannelFlags(SkColorType ct)
static size_t SkColorTypeMinRowBytes(SkColorType ct, int width)
static bool SkColorTypeIsAlphaOnly(SkColorType ct)
static bool SkColorTypeIsValid(unsigned value)
static bool SkColorInfoIsValid(const SkColorInfo &info)
static int SkColorTypeMaxBitsPerChannel(SkColorType ct)
static size_t SkColorTypeComputeOffset(SkColorType ct, int x, int y, size_t rowBytes)
static bool SkImageInfoIsValid(const SkImageInfo &info)
static bool SkColorTypeIsNormalized(SkColorType ct)
static int SkColorTypeShiftPerPixel(SkColorType ct)
static bool SkImageInfoValidConversion(const SkImageInfo &dst, const SkImageInfo &src)
static bool SkAlphaTypeIsValid(unsigned value)
SK_API int SkColorTypeBytesPerPixel(SkColorType ct)
Definition: SkImageInfo.cpp:16
static constexpr int32_t SK_MaxS32
Definition: SkMath.h:21
uint8_t value
double y
double x
dst
Definition: cp.py:12
int32_t width