Flutter Engine
The Flutter Engine
Macros | Functions
SkSwizzler.cpp File Reference
#include "src/codec/SkSwizzler.h"
#include "include/core/SkAlphaType.h"
#include "include/core/SkColorPriv.h"
#include "include/core/SkColorType.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRect.h"
#include "include/private/SkColorData.h"
#include "include/private/SkEncodedInfo.h"
#include "include/private/base/SkAlign.h"
#include "include/private/base/SkCPUTypes.h"
#include "include/private/base/SkMath.h"
#include "include/private/base/SkTemplates.h"
#include "src/base/SkHalf.h"
#include "src/codec/SkCodecPriv.h"
#include "src/core/SkSwizzlePriv.h"
#include <cstring>

Go to the source code of this file.

Macros

#define GRAYSCALE_BLACK   0
 
#define GRAYSCALE_WHITE   0xFF
 
#define RGB565_BLACK   0
 
#define RGB565_WHITE   0xFFFF
 

Functions

static void copy (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void sample1 (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void sample2 (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void sample4 (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void sample6 (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void sample8 (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_bit_to_grayscale (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor *)
 
static void swizzle_bit_to_n32 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor *)
 
static void swizzle_bit_to_565 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor *)
 
static void swizzle_bit_to_f16 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor *)
 
static void swizzle_small_index_to_565 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_small_index_to_n32 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_index_to_n32 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_index_to_n32_skipZ (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_index_to_565 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bytesPerPixel, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_gray_to_n32 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_gray_to_n32 (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_gray_to_565 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bytesPerPixel, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_grayalpha_to_n32_unpremul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_grayalpha_to_n32_unpremul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_grayalpha_to_n32_premul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_grayalpha_to_n32_premul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_grayalpha_to_a8 (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor[])
 
static void swizzle_bgr_to_565 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgb_to_rgba (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgb_to_bgra (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_rgb_to_rgba (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_rgb_to_bgra (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgb_to_565 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bytesPerPixel, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgba_to_rgba_premul (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgba_to_bgra_premul (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_rgba_to_rgba_premul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_rgba_to_bgra_premul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgba_to_bgra_unpremul (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_rgba_to_bgra_unpremul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgb16_to_rgba (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgb16_to_bgra (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgb16_to_565 (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgba16_to_rgba_unpremul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgba16_to_rgba_premul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgba16_to_bgra_unpremul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_rgba16_to_bgra_premul (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_cmyk_to_rgba (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_cmyk_to_bgra (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_cmyk_to_rgba (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void fast_swizzle_cmyk_to_bgra (void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 
static void swizzle_cmyk_to_565 (void *SK_RESTRICT dstRow, const uint8_t *SK_RESTRICT src, int dstWidth, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
 

Macro Definition Documentation

◆ GRAYSCALE_BLACK

#define GRAYSCALE_BLACK   0

Definition at line 94 of file SkSwizzler.cpp.

◆ GRAYSCALE_WHITE

#define GRAYSCALE_WHITE   0xFF

Definition at line 95 of file SkSwizzler.cpp.

◆ RGB565_BLACK

#define RGB565_BLACK   0

Definition at line 144 of file SkSwizzler.cpp.

◆ RGB565_WHITE

#define RGB565_WHITE   0xFFFF

Definition at line 145 of file SkSwizzler.cpp.

Function Documentation

◆ copy()

static void copy ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 31 of file SkSwizzler.cpp.

32 {
33 // This function must not be called if we are sampling. If we are not
34 // sampling, deltaSrc should equal bpp.
35 SkASSERT(deltaSrc == bpp);
36
37 memcpy(dst, src + offset, width * bpp);
38}
#define SkASSERT(cond)
Definition: SkAssert.h:116
dst
Definition: cp.py:12
int32_t width
SeparatedVector2 offset

◆ fast_swizzle_cmyk_to_bgra()

static void fast_swizzle_cmyk_to_bgra ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 727 of file SkSwizzler.cpp.

729 {
730
731 // This function must not be called if we are sampling. If we are not
732 // sampling, deltaSrc should equal bpp.
733 SkASSERT(deltaSrc == bpp);
734
735 SkOpts::inverted_CMYK_to_BGR1((uint32_t*) dst, (const uint32_t*)(src + offset), width);
736}
Swizzle_8888_u32 inverted_CMYK_to_BGR1
Definition: SkSwizzlePriv.h:25

◆ fast_swizzle_cmyk_to_rgba()

static void fast_swizzle_cmyk_to_rgba ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 716 of file SkSwizzler.cpp.

718 {
719
720 // This function must not be called if we are sampling. If we are not
721 // sampling, deltaSrc should equal bpp.
722 SkASSERT(deltaSrc == bpp);
723
724 SkOpts::inverted_CMYK_to_RGB1((uint32_t*) dst, (const uint32_t*)(src + offset), width);
725}
Swizzle_8888_u32 inverted_CMYK_to_RGB1
Definition: SkSwizzlePriv.h:24

◆ fast_swizzle_gray_to_n32()

static void fast_swizzle_gray_to_n32 ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 298 of file SkSwizzler.cpp.

300 {
301
302 // This function must not be called if we are sampling. If we are not
303 // sampling, deltaSrc should equal bpp.
304 SkASSERT(deltaSrc == bpp);
305
306 // Note that there is no need to distinguish between RGB and BGR.
307 // Each color channel will get the same value.
308 SkOpts::gray_to_RGB1((uint32_t*) dst, src + offset, width);
309}
Swizzle_8888_u8 gray_to_RGB1
Definition: SkSwizzlePriv.h:30

◆ fast_swizzle_grayalpha_to_n32_premul()

static void fast_swizzle_grayalpha_to_n32_premul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 363 of file SkSwizzler.cpp.

365 {
366
367 // This function must not be called if we are sampling. If we are not
368 // sampling, deltaSrc should equal bpp.
369 SkASSERT(deltaSrc == bpp);
370
371 // Note that there is no need to distinguish between rgb and bgr.
372 // Each color channel will get the same value.
373 SkOpts::grayA_to_rgbA((uint32_t*) dst, src + offset, width);
374}
Swizzle_8888_u8 grayA_to_rgbA
Definition: SkSwizzlePriv.h:32

◆ fast_swizzle_grayalpha_to_n32_unpremul()

static void fast_swizzle_grayalpha_to_n32_unpremul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 337 of file SkSwizzler.cpp.

339 {
340
341 // This function must not be called if we are sampling. If we are not
342 // sampling, deltaSrc should equal bpp.
343 SkASSERT(deltaSrc == bpp);
344
345 // Note that there is no need to distinguish between RGB and BGR.
346 // Each color channel will get the same value.
347 SkOpts::grayA_to_RGBA((uint32_t*) dst, src + offset, width);
348}
Swizzle_8888_u8 grayA_to_RGBA
Definition: SkSwizzlePriv.h:31

◆ fast_swizzle_rgb_to_bgra()

static void fast_swizzle_rgb_to_bgra ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 437 of file SkSwizzler.cpp.

439 {
440
441 // This function must not be called if we are sampling. If we are not
442 // sampling, deltaSrc should equal bpp.
443 SkASSERT(deltaSrc == bpp);
444
445 SkOpts::RGB_to_BGR1((uint32_t*) dst, src + offset, width);
446}
Swizzle_8888_u8 RGB_to_BGR1
Definition: SkSwizzlePriv.h:29

◆ fast_swizzle_rgb_to_rgba()

static void fast_swizzle_rgb_to_rgba ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 426 of file SkSwizzler.cpp.

428 {
429
430 // This function must not be called if we are sampling. If we are not
431 // sampling, deltaSrc should equal bpp.
432 SkASSERT(deltaSrc == bpp);
433
434 SkOpts::RGB_to_RGB1((uint32_t*) dst, src + offset, width);
435}
Swizzle_8888_u8 RGB_to_RGB1

◆ fast_swizzle_rgba_to_bgra_premul()

static void fast_swizzle_rgba_to_bgra_premul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 497 of file SkSwizzler.cpp.

499 {
500
501 // This function must not be called if we are sampling. If we are not
502 // sampling, deltaSrc should equal bpp.
503 SkASSERT(deltaSrc == bpp);
504
505 SkOpts::RGBA_to_bgrA((uint32_t*) dst, (const uint32_t*)(src + offset), width);
506}
Swizzle_8888_u32 RGBA_to_bgrA
Definition: SkSwizzlePriv.h:21

◆ fast_swizzle_rgba_to_bgra_unpremul()

static void fast_swizzle_rgba_to_bgra_unpremul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 521 of file SkSwizzler.cpp.

523 {
524
525 // This function must not be called if we are sampling. If we are not
526 // sampling, deltaSrc should equal bpp.
527 SkASSERT(deltaSrc == bpp);
528
529 SkOpts::RGBA_to_BGRA((uint32_t*) dst, (const uint32_t*)(src + offset), width);
530}
Swizzle_8888_u32 RGBA_to_BGRA

◆ fast_swizzle_rgba_to_rgba_premul()

static void fast_swizzle_rgba_to_rgba_premul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 486 of file SkSwizzler.cpp.

488 {
489
490 // This function must not be called if we are sampling. If we are not
491 // sampling, deltaSrc should equal bpp.
492 SkASSERT(deltaSrc == bpp);
493
494 SkOpts::RGBA_to_rgbA((uint32_t*) dst, (const uint32_t*)(src + offset), width);
495}
Swizzle_8888_u32 RGBA_to_rgbA
Definition: SkSwizzlePriv.h:20

◆ sample1()

static void sample1 ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 40 of file SkSwizzler.cpp.

41 {
42 src += offset;
43 uint8_t* dst8 = (uint8_t*) dst;
44 for (int x = 0; x < width; x++) {
45 dst8[x] = *src;
46 src += deltaSrc;
47 }
48}
double x

◆ sample2()

static void sample2 ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 50 of file SkSwizzler.cpp.

51 {
52 src += offset;
53 uint16_t* dst16 = (uint16_t*) dst;
54 for (int x = 0; x < width; x++) {
55 dst16[x] = *((const uint16_t*) src);
56 src += deltaSrc;
57 }
58}

◆ sample4()

static void sample4 ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 60 of file SkSwizzler.cpp.

61 {
62 src += offset;
63 uint32_t* dst32 = (uint32_t*) dst;
64 for (int x = 0; x < width; x++) {
65 dst32[x] = *((const uint32_t*) src);
66 src += deltaSrc;
67 }
68}

◆ sample6()

static void sample6 ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 70 of file SkSwizzler.cpp.

71 {
72 src += offset;
73 uint8_t* dst8 = (uint8_t*) dst;
74 for (int x = 0; x < width; x++) {
75 memcpy(dst8, src, 6);
76 dst8 += 6;
77 src += deltaSrc;
78 }
79}

◆ sample8()

static void sample8 ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 81 of file SkSwizzler.cpp.

82 {
83 src += offset;
84 uint64_t* dst64 = (uint64_t*) dst;
85 for (int x = 0; x < width; x++) {
86 dst64[x] = *((const uint64_t*) src);
87 src += deltaSrc;
88 }
89}

◆ swizzle_bgr_to_565()

static void swizzle_bgr_to_565 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 388 of file SkSwizzler.cpp.

390 {
391
392 src += offset;
393 uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow;
394 for (int x = 0; x < dstWidth; x++) {
395 dst[x] = SkPack888ToRGB16(src[2], src[1], src[0]);
396 src += deltaSrc;
397 }
398}
static U16CPU SkPack888ToRGB16(U8CPU r, U8CPU g, U8CPU b)
Definition: SkColorData.h:324
#define SK_RESTRICT
Definition: SkFeatures.h:42

◆ swizzle_bit_to_565()

static void swizzle_bit_to_565 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  
)
static

Definition at line 147 of file SkSwizzler.cpp.

149 {
150 uint16_t* SK_RESTRICT dst = (uint16_t*) dstRow;
151
152 // increment src by byte offset and bitIndex by bit offset
153 src += offset / 8;
154 int bitIndex = offset % 8;
155 uint8_t currByte = *src;
156
157 dst[0] = ((currByte >> (7 - bitIndex)) & 1) ? RGB565_WHITE : RGB565_BLACK;
158
159 for (int x = 1; x < dstWidth; x++) {
160 int bitOffset = bitIndex + deltaSrc;
161 bitIndex = bitOffset % 8;
162 currByte = *(src += bitOffset / 8);
163 dst[x] = ((currByte >> (7 - bitIndex)) & 1) ? RGB565_WHITE : RGB565_BLACK;
164 }
165}
#define RGB565_BLACK
Definition: SkSwizzler.cpp:144
#define RGB565_WHITE
Definition: SkSwizzler.cpp:145

◆ swizzle_bit_to_f16()

static void swizzle_bit_to_f16 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  
)
static

Definition at line 170 of file SkSwizzler.cpp.

172 {
173 constexpr uint64_t kWhite = (((uint64_t) SK_Half1) << 0) |
174 (((uint64_t) SK_Half1) << 16) |
175 (((uint64_t) SK_Half1) << 32) |
176 (((uint64_t) SK_Half1) << 48);
177 constexpr uint64_t kBlack = (((uint64_t) 0) << 0) |
178 (((uint64_t) 0) << 16) |
179 (((uint64_t) 0) << 32) |
180 (((uint64_t) SK_Half1) << 48);
181
182 uint64_t* SK_RESTRICT dst = (uint64_t*) dstRow;
183
184 // increment src by byte offset and bitIndex by bit offset
185 src += offset / 8;
186 int bitIndex = offset % 8;
187 uint8_t currByte = *src;
188
189 dst[0] = ((currByte >> (7 - bitIndex)) & 1) ? kWhite : kBlack;
190
191 for (int x = 1; x < dstWidth; x++) {
192 int bitOffset = bitIndex + deltaSrc;
193 bitIndex = bitOffset % 8;
194 currByte = *(src += bitOffset / 8);
195 dst[x] = ((currByte >> (7 - bitIndex)) & 1) ? kWhite : kBlack;
196 }
197}
static constexpr uint16_t SK_Half1
Definition: SkHalf.h:23
constexpr SkColor4f kWhite
Definition: SkColor.h:439
constexpr SkColor4f kBlack
Definition: SkColor.h:435

◆ swizzle_bit_to_grayscale()

static void swizzle_bit_to_grayscale ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  
)
static

Definition at line 99 of file SkSwizzler.cpp.

101 {
102
103 uint8_t* SK_RESTRICT dst = (uint8_t*) dstRow;
104
105 // increment src by byte offset and bitIndex by bit offset
106 src += offset / 8;
107 int bitIndex = offset % 8;
108 uint8_t currByte = *src;
109
110 dst[0] = ((currByte >> (7-bitIndex)) & 1) ? GRAYSCALE_WHITE : GRAYSCALE_BLACK;
111
112 for (int x = 1; x < dstWidth; x++) {
113 int bitOffset = bitIndex + deltaSrc;
114 bitIndex = bitOffset % 8;
115 currByte = *(src += bitOffset / 8);
116 dst[x] = ((currByte >> (7-bitIndex)) & 1) ? GRAYSCALE_WHITE : GRAYSCALE_BLACK;
117 }
118}
#define GRAYSCALE_WHITE
Definition: SkSwizzler.cpp:95
#define GRAYSCALE_BLACK
Definition: SkSwizzler.cpp:94

◆ swizzle_bit_to_n32()

static void swizzle_bit_to_n32 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  
)
static

Definition at line 124 of file SkSwizzler.cpp.

126 {
127 SkPMColor* SK_RESTRICT dst = (SkPMColor*) dstRow;
128
129 // increment src by byte offset and bitIndex by bit offset
130 src += offset / 8;
131 int bitIndex = offset % 8;
132 uint8_t currByte = *src;
133
134 dst[0] = ((currByte >> (7 - bitIndex)) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
135
136 for (int x = 1; x < dstWidth; x++) {
137 int bitOffset = bitIndex + deltaSrc;
138 bitIndex = bitOffset % 8;
139 currByte = *(src += bitOffset / 8);
140 dst[x] = ((currByte >> (7 - bitIndex)) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
141 }
142}
uint32_t SkPMColor
Definition: SkColor.h:205
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122

◆ swizzle_cmyk_to_565()

static void swizzle_cmyk_to_565 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 738 of file SkSwizzler.cpp.

740 {
741
742 src += offset;
743 uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow;
744 for (int x = 0; x < dstWidth; x++) {
745 const uint8_t r = SkMulDiv255Round(src[0], src[3]);
746 const uint8_t g = SkMulDiv255Round(src[1], src[3]);
747 const uint8_t b = SkMulDiv255Round(src[2], src[3]);
748
749 dst[x] = SkPack888ToRGB16(r, g, b);
750 src += deltaSrc;
751 }
752}
static U8CPU SkMulDiv255Round(U16CPU a, U16CPU b)
Definition: SkMath.h:73
static bool b

◆ swizzle_cmyk_to_bgra()

static void swizzle_cmyk_to_bgra ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 700 of file SkSwizzler.cpp.

702 {
703
704 src += offset;
706 for (int x = 0; x < dstWidth; x++) {
707 const uint8_t r = SkMulDiv255Round(src[0], src[3]);
708 const uint8_t g = SkMulDiv255Round(src[1], src[3]);
709 const uint8_t b = SkMulDiv255Round(src[2], src[3]);
710
711 dst[x] = SkPackARGB_as_BGRA(0xFF, r, g, b);
712 src += deltaSrc;
713 }
714}
static uint32_t SkPackARGB_as_BGRA(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColorData.h:74

◆ swizzle_cmyk_to_rgba()

static void swizzle_cmyk_to_rgba ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 684 of file SkSwizzler.cpp.

686 {
687
688 src += offset;
690 for (int x = 0; x < dstWidth; x++) {
691 const uint8_t r = SkMulDiv255Round(src[0], src[3]);
692 const uint8_t g = SkMulDiv255Round(src[1], src[3]);
693 const uint8_t b = SkMulDiv255Round(src[2], src[3]);
694
695 dst[x] = SkPackARGB_as_RGBA(0xFF, r, g, b);
696 src += deltaSrc;
697 }
698}
static uint32_t SkPackARGB_as_RGBA(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColorData.h:65

◆ swizzle_gray_to_565()

static void swizzle_gray_to_565 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bytesPerPixel,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 311 of file SkSwizzler.cpp.

313 {
314
315 src += offset;
316 uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow;
317 for (int x = 0; x < dstWidth; x++) {
318 dst[x] = SkPack888ToRGB16(src[0], src[0], src[0]);
319 src += deltaSrc;
320 }
321}

◆ swizzle_gray_to_n32()

static void swizzle_gray_to_n32 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 286 of file SkSwizzler.cpp.

288 {
289
290 src += offset;
292 for (int x = 0; x < dstWidth; x++) {
293 dst[x] = SkPackARGB32NoCheck(0xFF, *src, *src, *src);
294 src += deltaSrc;
295 }
296}
static SkPMColor SkPackARGB32NoCheck(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColorPriv.h:120

◆ swizzle_grayalpha_to_a8()

static void swizzle_grayalpha_to_a8 ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const  SkPMColor[] 
)
static

Definition at line 376 of file SkSwizzler.cpp.

377 {
378 src += offset;
379 uint8_t* dst8 = (uint8_t*)dst;
380 for (int x = 0; x < width; ++x) {
381 dst8[x] = src[1]; // src[0] is gray, ignored
382 src += deltaSrc;
383 }
384}

◆ swizzle_grayalpha_to_n32_premul()

static void swizzle_grayalpha_to_n32_premul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 350 of file SkSwizzler.cpp.

352 {
353
354 src += offset;
355 SkPMColor* dst32 = (SkPMColor*) dst;
356 for (int x = 0; x < width; x++) {
357 uint8_t pmgray = SkMulDiv255Round(src[1], src[0]);
358 dst32[x] = SkPackARGB32NoCheck(src[1], pmgray, pmgray, pmgray);
359 src += deltaSrc;
360 }
361}

◆ swizzle_grayalpha_to_n32_unpremul()

static void swizzle_grayalpha_to_n32_unpremul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 325 of file SkSwizzler.cpp.

327 {
328
329 src += offset;
330 SkPMColor* dst32 = (SkPMColor*) dst;
331 for (int x = 0; x < width; x++) {
332 dst32[x] = SkPackARGB32NoCheck(src[1], src[0], src[0], src[0]);
333 src += deltaSrc;
334 }
335}

◆ swizzle_index_to_565()

static void swizzle_index_to_565 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bytesPerPixel,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 273 of file SkSwizzler.cpp.

275 {
276 src += offset;
277 uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow;
278 for (int x = 0; x < dstWidth; x++) {
279 dst[x] = SkPixel32ToPixel16(ctable[*src]);
280 src += deltaSrc;
281 }
282}
static U16CPU SkPixel32ToPixel16(SkPMColor c)
Definition: SkColorData.h:317

◆ swizzle_index_to_n32()

static void swizzle_index_to_n32 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 245 of file SkSwizzler.cpp.

247 {
248
249 src += offset;
251 for (int x = 0; x < dstWidth; x++) {
252 SkPMColor c = ctable[*src];
253 dst[x] = c;
254 src += deltaSrc;
255 }
256}

◆ swizzle_index_to_n32_skipZ()

static void swizzle_index_to_n32_skipZ ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 258 of file SkSwizzler.cpp.

260 {
261
262 src += offset;
264 for (int x = 0; x < dstWidth; x++) {
265 SkPMColor c = ctable[*src];
266 if (c != 0) {
267 dst[x] = c;
268 }
269 src += deltaSrc;
270 }
271}

◆ swizzle_rgb16_to_565()

static void swizzle_rgb16_to_565 ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 564 of file SkSwizzler.cpp.

566 {
567 auto strip16to565 = [](const uint8_t* ptr) {
568 return SkPack888ToRGB16(ptr[0], ptr[2], ptr[4]);
569 };
570
571 src += offset;
572 uint16_t* dst16 = (uint16_t*) dst;
573 for (int x = 0; x < width; x++) {
574 dst16[x] = strip16to565(src);
575 src += deltaSrc;
576 }
577}

◆ swizzle_rgb16_to_bgra()

static void swizzle_rgb16_to_bgra ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 549 of file SkSwizzler.cpp.

551 {
552 auto strip16to8 = [](const uint8_t* ptr) {
553 return 0xFF000000 | (ptr[0] << 16) | (ptr[2] << 8) | ptr[4];
554 };
555
556 src += offset;
557 uint32_t* dst32 = (uint32_t*) dst;
558 for (int x = 0; x < width; x++) {
559 dst32[x] = strip16to8(src);
560 src += deltaSrc;
561 }
562}

◆ swizzle_rgb16_to_rgba()

static void swizzle_rgb16_to_rgba ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 534 of file SkSwizzler.cpp.

536 {
537 auto strip16to8 = [](const uint8_t* ptr) {
538 return 0xFF000000 | (ptr[4] << 16) | (ptr[2] << 8) | ptr[0];
539 };
540
541 src += offset;
542 uint32_t* dst32 = (uint32_t*) dst;
543 for (int x = 0; x < width; x++) {
544 dst32[x] = strip16to8(src);
545 src += deltaSrc;
546 }
547}

◆ swizzle_rgb_to_565()

static void swizzle_rgb_to_565 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bytesPerPixel,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 448 of file SkSwizzler.cpp.

450 {
451
452 src += offset;
453 uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow;
454 for (int x = 0; x < dstWidth; x++) {
455 dst[x] = SkPack888ToRGB16(src[0], src[1], src[2]);
456 src += deltaSrc;
457 }
458}

◆ swizzle_rgb_to_bgra()

static void swizzle_rgb_to_bgra ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 414 of file SkSwizzler.cpp.

416 {
417
418 src += offset;
420 for (int x = 0; x < dstWidth; x++) {
421 dst[x] = SkPackARGB_as_BGRA(0xFF, src[0], src[1], src[2]);
422 src += deltaSrc;
423 }
424}

◆ swizzle_rgb_to_rgba()

static void swizzle_rgb_to_rgba ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 402 of file SkSwizzler.cpp.

404 {
405
406 src += offset;
408 for (int x = 0; x < dstWidth; x++) {
409 dst[x] = SkPackARGB_as_RGBA(0xFF, src[0], src[1], src[2]);
410 src += deltaSrc;
411 }
412}

◆ swizzle_rgba16_to_bgra_premul()

static void swizzle_rgba16_to_bgra_premul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 624 of file SkSwizzler.cpp.

626 {
627 auto stripAndPremul16to8 = [](const uint8_t* ptr) {
628 return premultiply_argb_as_bgra(ptr[6], ptr[0], ptr[2], ptr[4]);
629 };
630
631 src += offset;
632 uint32_t* dst32 = (uint32_t*) dst;
633 for (int x = 0; x < width; x++) {
634 dst32[x] = stripAndPremul16to8(src);
635 src += deltaSrc;
636 }
637}
static SkPMColor premultiply_argb_as_bgra(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkCodecPriv.h:220

◆ swizzle_rgba16_to_bgra_unpremul()

static void swizzle_rgba16_to_bgra_unpremul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 609 of file SkSwizzler.cpp.

611 {
612 auto strip16to8 = [](const uint8_t* ptr) {
613 return (ptr[6] << 24) | (ptr[0] << 16) | (ptr[2] << 8) | ptr[4];
614 };
615
616 src += offset;
617 uint32_t* dst32 = (uint32_t*) dst;
618 for (int x = 0; x < width; x++) {
619 dst32[x] = strip16to8(src);
620 src += deltaSrc;
621 }
622}

◆ swizzle_rgba16_to_rgba_premul()

static void swizzle_rgba16_to_rgba_premul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 594 of file SkSwizzler.cpp.

596 {
597 auto stripAndPremul16to8 = [](const uint8_t* ptr) {
598 return premultiply_argb_as_rgba(ptr[6], ptr[0], ptr[2], ptr[4]);
599 };
600
601 src += offset;
602 uint32_t* dst32 = (uint32_t*) dst;
603 for (int x = 0; x < width; x++) {
604 dst32[x] = stripAndPremul16to8(src);
605 src += deltaSrc;
606 }
607}
static SkPMColor premultiply_argb_as_rgba(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkCodecPriv.h:210

◆ swizzle_rgba16_to_rgba_unpremul()

static void swizzle_rgba16_to_rgba_unpremul ( void *  dst,
const uint8_t *  src,
int  width,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 579 of file SkSwizzler.cpp.

581 {
582 auto strip16to8 = [](const uint8_t* ptr) {
583 return (ptr[6] << 24) | (ptr[4] << 16) | (ptr[2] << 8) | ptr[0];
584 };
585
586 src += offset;
587 uint32_t* dst32 = (uint32_t*) dst;
588 for (int x = 0; x < width; x++) {
589 dst32[x] = strip16to8(src);
590 src += deltaSrc;
591 }
592}

◆ swizzle_rgba_to_bgra_premul()

static void swizzle_rgba_to_bgra_premul ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 474 of file SkSwizzler.cpp.

476 {
477
478 src += offset;
480 for (int x = 0; x < dstWidth; x++) {
481 dst[x] = premultiply_argb_as_bgra(src[3], src[0], src[1], src[2]);
482 src += deltaSrc;
483 }
484}

◆ swizzle_rgba_to_bgra_unpremul()

static void swizzle_rgba_to_bgra_unpremul ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 508 of file SkSwizzler.cpp.

510 {
511
512 src += offset;
513 uint32_t* SK_RESTRICT dst = reinterpret_cast<uint32_t*>(dstRow);
514 for (int x = 0; x < dstWidth; x++) {
515 unsigned alpha = src[3];
516 dst[x] = SkPackARGB_as_BGRA(alpha, src[0], src[1], src[2]);
517 src += deltaSrc;
518 }
519}

◆ swizzle_rgba_to_rgba_premul()

static void swizzle_rgba_to_rgba_premul ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 462 of file SkSwizzler.cpp.

464 {
465
466 src += offset;
468 for (int x = 0; x < dstWidth; x++) {
469 dst[x] = premultiply_argb_as_rgba(src[3], src[0], src[1], src[2]);
470 src += deltaSrc;
471 }
472}

◆ swizzle_small_index_to_565()

static void swizzle_small_index_to_565 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 201 of file SkSwizzler.cpp.

203 {
204
205 uint16_t* dst = (uint16_t*) dstRow;
206 src += offset / 8;
207 int bitIndex = offset % 8;
208 uint8_t currByte = *src;
209 const uint8_t mask = (1 << bpp) - 1;
210 uint8_t index = (currByte >> (8 - bpp - bitIndex)) & mask;
211 dst[0] = SkPixel32ToPixel16(ctable[index]);
212
213 for (int x = 1; x < dstWidth; x++) {
214 int bitOffset = bitIndex + deltaSrc;
215 bitIndex = bitOffset % 8;
216 currByte = *(src += bitOffset / 8);
217 index = (currByte >> (8 - bpp - bitIndex)) & mask;
218 dst[x] = SkPixel32ToPixel16(ctable[index]);
219 }
220}

◆ swizzle_small_index_to_n32()

static void swizzle_small_index_to_n32 ( void *SK_RESTRICT  dstRow,
const uint8_t *SK_RESTRICT  src,
int  dstWidth,
int  bpp,
int  deltaSrc,
int  offset,
const SkPMColor  ctable[] 
)
static

Definition at line 222 of file SkSwizzler.cpp.

224 {
225
226 SkPMColor* dst = (SkPMColor*) dstRow;
227 src += offset / 8;
228 int bitIndex = offset % 8;
229 uint8_t currByte = *src;
230 const uint8_t mask = (1 << bpp) - 1;
231 uint8_t index = (currByte >> (8 - bpp - bitIndex)) & mask;
232 dst[0] = ctable[index];
233
234 for (int x = 1; x < dstWidth; x++) {
235 int bitOffset = bitIndex + deltaSrc;
236 bitIndex = bitOffset % 8;
237 currByte = *(src += bitOffset / 8);
238 index = (currByte >> (8 - bpp - bitIndex)) & mask;
239 dst[x] = ctable[index];
240 }
241}