Flutter Engine
The Flutter Engine
Namespaces | Macros | Typedefs | Functions
SkCodecPriv.h File Reference
#include "include/codec/SkEncodedOrigin.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkTypes.h"
#include "include/private/SkColorData.h"
#include "include/private/SkEncodedInfo.h"
#include "src/codec/SkColorPalette.h"
#include <string_view>

Go to the source code of this file.

Namespaces

namespace  SkCodecs
 

Macros

#define SkCodecPrintf(...)
 

Typedefs

typedef uint32_t(* PackColorProc) (U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 

Functions

bool sk_select_xform_format (SkColorType colorType, bool forColorTable, skcms_PixelFormat *outFormat)
 
static float get_scale_from_sample_size (int sampleSize)
 
static bool is_valid_subset (const SkIRect &subset, const SkISize &imageDims)
 
static int get_scaled_dimension (int srcDimension, int sampleSize)
 
static int get_start_coord (int sampleFactor)
 
static int get_dst_coord (int srcCoord, int sampleFactor)
 
static bool is_coord_necessary (int srcCoord, int sampleFactor, int scaledDim)
 
static bool valid_alpha (SkAlphaType dstAlpha, bool srcIsOpaque)
 
static const SkPMColorget_color_ptr (SkColorPalette *colorTable)
 
static size_t compute_row_bytes_ppb (int width, uint32_t pixelsPerByte)
 
static size_t compute_row_bytes_bpp (int width, uint32_t bytesPerPixel)
 
static size_t compute_row_bytes (int width, uint32_t bitsPerPixel)
 
static uint8_t get_byte (const uint8_t *buffer, uint32_t i)
 
static uint16_t get_short (const uint8_t *buffer, uint32_t i)
 
static uint32_t get_int (const uint8_t *buffer, uint32_t i)
 
static bool is_valid_endian_marker (const uint8_t *data, bool *isLittleEndian)
 
static uint16_t get_endian_short (const uint8_t *data, bool littleEndian)
 
static uint32_t get_endian_int (const uint8_t *data, bool littleEndian)
 
static SkPMColor premultiply_argb_as_rgba (U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 
static SkPMColor premultiply_argb_as_bgra (U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 
static bool is_rgba (SkColorType colorType)
 
static PackColorProc choose_pack_color_proc (bool isPremul, SkColorType colorType)
 
bool SkCodecs::HasDecoder (std::string_view id)
 

Macro Definition Documentation

◆ SkCodecPrintf

#define SkCodecPrintf (   ...)

Definition at line 23 of file SkCodecPriv.h.

Typedef Documentation

◆ PackColorProc

typedef uint32_t(* PackColorProc) (U8CPU a, U8CPU r, U8CPU g, U8CPU b)

Definition at line 239 of file SkCodecPriv.h.

Function Documentation

◆ choose_pack_color_proc()

static PackColorProc choose_pack_color_proc ( bool  isPremul,
SkColorType  colorType 
)
inlinestatic

Definition at line 241 of file SkCodecPriv.h.

241 {
242 bool isRGBA = is_rgba(colorType);
243 if (isPremul) {
244 if (isRGBA) {
246 } else {
248 }
249 } else {
250 if (isRGBA) {
251 return &SkPackARGB_as_RGBA;
252 } else {
253 return &SkPackARGB_as_BGRA;
254 }
255 }
256}
static SkPMColor premultiply_argb_as_rgba(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkCodecPriv.h:210
static SkPMColor premultiply_argb_as_bgra(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkCodecPriv.h:220
static bool is_rgba(SkColorType colorType)
Definition: SkCodecPriv.h:230
static uint32_t SkPackARGB_as_RGBA(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColorData.h:65
static uint32_t SkPackARGB_as_BGRA(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColorData.h:74
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)

◆ compute_row_bytes()

static size_t compute_row_bytes ( int  width,
uint32_t  bitsPerPixel 
)
inlinestatic

Definition at line 130 of file SkCodecPriv.h.

130 {
131 if (bitsPerPixel < 16) {
132 SkASSERT(0 == 8 % bitsPerPixel);
133 const uint32_t pixelsPerByte = 8 / bitsPerPixel;
134 return compute_row_bytes_ppb(width, pixelsPerByte);
135 } else {
136 SkASSERT(0 == bitsPerPixel % 8);
137 const uint32_t bytesPerPixel = bitsPerPixel / 8;
138 return compute_row_bytes_bpp(width, bytesPerPixel);
139 }
140}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static size_t compute_row_bytes_bpp(int width, uint32_t bytesPerPixel)
Definition: SkCodecPriv.h:123
static size_t compute_row_bytes_ppb(int width, uint32_t pixelsPerByte)
Definition: SkCodecPriv.h:116
int32_t width

◆ compute_row_bytes_bpp()

static size_t compute_row_bytes_bpp ( int  width,
uint32_t  bytesPerPixel 
)
inlinestatic

Definition at line 123 of file SkCodecPriv.h.

123 {
124 return width * bytesPerPixel;
125}

◆ compute_row_bytes_ppb()

static size_t compute_row_bytes_ppb ( int  width,
uint32_t  pixelsPerByte 
)
inlinestatic

Definition at line 116 of file SkCodecPriv.h.

116 {
117 return (width + pixelsPerByte - 1) / pixelsPerByte;
118}

◆ get_byte()

static uint8_t get_byte ( const uint8_t *  buffer,
uint32_t  i 
)
inlinestatic

Definition at line 146 of file SkCodecPriv.h.

146 {
147 return buffer[i];
148}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ get_color_ptr()

static const SkPMColor * get_color_ptr ( SkColorPalette colorTable)
inlinestatic

Definition at line 109 of file SkCodecPriv.h.

109 {
110 return nullptr != colorTable ? colorTable->readColors() : nullptr;
111}
const SkPMColor * readColors() const

◆ get_dst_coord()

static int get_dst_coord ( int  srcCoord,
int  sampleFactor 
)
inlinestatic

Definition at line 67 of file SkCodecPriv.h.

67{ return srcCoord / sampleFactor; }

◆ get_endian_int()

static uint32_t get_endian_int ( const uint8_t *  data,
bool  littleEndian 
)
inlinestatic

Definition at line 202 of file SkCodecPriv.h.

202 {
203 if (littleEndian) {
204 return (data[3] << 24) | (data[2] << 16) | (data[1] << 8) | (data[0]);
205 }
206
207 return (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | (data[3]);
208}
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ get_endian_short()

static uint16_t get_endian_short ( const uint8_t *  data,
bool  littleEndian 
)
inlinestatic

Definition at line 194 of file SkCodecPriv.h.

194 {
195 if (littleEndian) {
196 return (data[1] << 8) | (data[0]);
197 }
198
199 return (data[0] << 8) | (data[1]);
200}

◆ get_int()

static uint32_t get_int ( const uint8_t *  buffer,
uint32_t  i 
)
inlinestatic

Definition at line 168 of file SkCodecPriv.h.

168 {
169 uint32_t result;
170 memcpy(&result, &(buffer[i]), 4);
171#ifdef SK_CPU_BENDIAN
172 return SkEndianSwap32(result);
173#else
174 return result;
175#endif
176}
static constexpr uint32_t SkEndianSwap32(uint32_t value)
Definition: SkEndian.h:56
GAsyncResult * result

◆ get_scale_from_sample_size()

static float get_scale_from_sample_size ( int  sampleSize)
inlinestatic

Definition at line 31 of file SkCodecPriv.h.

31 {
32 return 1.0f / ((float) sampleSize);
33}

◆ get_scaled_dimension()

static int get_scaled_dimension ( int  srcDimension,
int  sampleSize 
)
inlinestatic

Definition at line 44 of file SkCodecPriv.h.

44 {
45 if (sampleSize > srcDimension) {
46 return 1;
47 }
48 return srcDimension / sampleSize;
49}

◆ get_short()

static uint16_t get_short ( const uint8_t *  buffer,
uint32_t  i 
)
inlinestatic

Definition at line 154 of file SkCodecPriv.h.

154 {
155 uint16_t result;
156 memcpy(&result, &(buffer[i]), 2);
157#ifdef SK_CPU_BENDIAN
158 return SkEndianSwap16(result);
159#else
160 return result;
161#endif
162}
static uint16_t SkEndianSwap16(uint16_t value)
Definition: SkEndian.h:33

◆ get_start_coord()

static int get_start_coord ( int  sampleFactor)
inlinestatic

Definition at line 57 of file SkCodecPriv.h.

57{ return sampleFactor / 2; }

◆ is_coord_necessary()

static bool is_coord_necessary ( int  srcCoord,
int  sampleFactor,
int  scaledDim 
)
inlinestatic

Definition at line 77 of file SkCodecPriv.h.

77 {
78 // Get the first coordinate that we want to keep
79 int startCoord = get_start_coord(sampleFactor);
80
81 // Return false on edge cases
82 if (srcCoord < startCoord || get_dst_coord(srcCoord, sampleFactor) >= scaledDim) {
83 return false;
84 }
85
86 // Every sampleFactor rows are necessary
87 return ((srcCoord - startCoord) % sampleFactor) == 0;
88}
static int get_dst_coord(int srcCoord, int sampleFactor)
Definition: SkCodecPriv.h:67
static int get_start_coord(int sampleFactor)
Definition: SkCodecPriv.h:57

◆ is_rgba()

static bool is_rgba ( SkColorType  colorType)
inlinestatic

Definition at line 230 of file SkCodecPriv.h.

230 {
231#ifdef SK_PMCOLOR_IS_RGBA
233#else
235#endif
236}
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24

◆ is_valid_endian_marker()

static bool is_valid_endian_marker ( const uint8_t *  data,
bool *  isLittleEndian 
)
inlinestatic

Definition at line 184 of file SkCodecPriv.h.

184 {
185 // II indicates Intel (little endian) and MM indicates motorola (big endian).
186 if (('I' != data[0] || 'I' != data[1]) && ('M' != data[0] || 'M' != data[1])) {
187 return false;
188 }
189
190 *isLittleEndian = ('I' == data[0]);
191 return true;
192}

◆ is_valid_subset()

static bool is_valid_subset ( const SkIRect subset,
const SkISize imageDims 
)
inlinestatic

Definition at line 35 of file SkCodecPriv.h.

35 {
36 return SkIRect::MakeSize(imageDims).contains(subset);
37}
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463

◆ premultiply_argb_as_bgra()

static SkPMColor premultiply_argb_as_bgra ( U8CPU  a,
U8CPU  r,
U8CPU  g,
U8CPU  b 
)
inlinestatic

Definition at line 220 of file SkCodecPriv.h.

220 {
221 if (a != 255) {
222 r = SkMulDiv255Round(r, a);
223 g = SkMulDiv255Round(g, a);
224 b = SkMulDiv255Round(b, a);
225 }
226
227 return SkPackARGB_as_BGRA(a, r, g, b);
228}
static U8CPU SkMulDiv255Round(U16CPU a, U16CPU b)
Definition: SkMath.h:73
static bool b
struct MyStruct a[10]

◆ premultiply_argb_as_rgba()

static SkPMColor premultiply_argb_as_rgba ( U8CPU  a,
U8CPU  r,
U8CPU  g,
U8CPU  b 
)
inlinestatic

Definition at line 210 of file SkCodecPriv.h.

210 {
211 if (a != 255) {
212 r = SkMulDiv255Round(r, a);
213 g = SkMulDiv255Round(g, a);
214 b = SkMulDiv255Round(b, a);
215 }
216
217 return SkPackARGB_as_RGBA(a, r, g, b);
218}

◆ sk_select_xform_format()

bool sk_select_xform_format ( SkColorType  colorType,
bool  forColorTable,
skcms_PixelFormat outFormat 
)

Definition at line 767 of file SkCodec.cpp.

768 {
769 SkASSERT(outFormat);
770
771 switch (colorType) {
773 *outFormat = skcms_PixelFormat_RGBA_8888;
774 break;
776 *outFormat = skcms_PixelFormat_BGRA_8888;
777 break;
779 if (forColorTable) {
780#if defined(SK_PMCOLOR_IS_RGBA)
781 *outFormat = skcms_PixelFormat_RGBA_8888;
782#else
783 *outFormat = skcms_PixelFormat_BGRA_8888;
784#endif
785 break;
786 }
787 *outFormat = skcms_PixelFormat_BGR_565;
788 break;
790 *outFormat = skcms_PixelFormat_RGBA_hhhh;
791 break;
794 break;
796 *outFormat = skcms_PixelFormat_G_8;
797 break;
798 default:
799 return false;
800 }
801 return true;
802}
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ 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
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Definition: SkColorType.h:31
@ skcms_PixelFormat_BGR_101010x_XR
Definition: skcms_public.h:321
@ skcms_PixelFormat_BGRA_8888
Definition: skcms_public.h:288
@ skcms_PixelFormat_RGBA_hhhh
Definition: skcms_public.h:312
@ skcms_PixelFormat_RGBA_8888
Definition: skcms_public.h:287
@ skcms_PixelFormat_G_8
Definition: skcms_public.h:276
@ skcms_PixelFormat_BGR_565
Definition: skcms_public.h:280

◆ valid_alpha()

static bool valid_alpha ( SkAlphaType  dstAlpha,
bool  srcIsOpaque 
)
inlinestatic

Definition at line 90 of file SkCodecPriv.h.

90 {
91 if (kUnknown_SkAlphaType == dstAlpha) {
92 return false;
93 }
94
95 if (srcIsOpaque) {
96 if (kOpaque_SkAlphaType != dstAlpha) {
97 SkCodecPrintf("Warning: an opaque image should be decoded as opaque "
98 "- it is being decoded as non-opaque, which will draw slower\n");
99 }
100 return true;
101 }
102
103 return dstAlpha != kOpaque_SkAlphaType;
104}
@ kUnknown_SkAlphaType
uninitialized
Definition: SkAlphaType.h:27
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
#define SkCodecPrintf(...)
Definition: SkCodecPriv.h:23