50 src.fImage, src.fRowBytes);
74 SkASSERT(
static_cast<unsigned>(r.
fLeft) <
static_cast<unsigned>(this->width()));
75 SkASSERT(
static_cast<unsigned>(r.
fTop) <
static_cast<unsigned>(this->height()));
77 const void* pixels =
nullptr;
80 pixels = (
const uint8_t*)fPixels + r.
fTop * fRowBytes + r.
fLeft * bpp;
91 return static_cast<const char*
>(pm.
addr()) +
y * pm.
rowBytes() +
x;
117 value =
static_cast<const uint8_t*
>(srcPtr)[0] * (1.0f/255);
120 value =
static_cast<const uint16_t*
>(srcPtr)[0] * (1.0f/65535);
128 uint16_t u16 =
static_cast<const uint16_t*
>(srcPtr)[0];
135 value =
static_cast<const uint8_t*
>(srcPtr)[3] * (1.0f/255);
139 uint32_t u32 =
static_cast<const uint32_t*
>(srcPtr)[0];
140 value = (u32 >> 30) * (1.0f/3);
144 uint64_t u64 =
static_cast<const uint64_t*
>(srcPtr)[0];
145 value = ((u64 >> 54) - 384) / 510.f;
149 uint64_t u64 =
static_cast<const uint64_t*
>(srcPtr)[0];
150 value = (u64 >> 54) * (1.0f/1023);
154 uint64_t u64 =
static_cast<const uint64_t*
>(srcPtr)[0];
155 value = (u64 >> 48) * (1.0f/65535);
164 value =
static_cast<const float*
>(srcPtr)[3];
171 int x,
int y)
const {
181 const void* srcPixels = this->
addr(rec.
fX, rec.
fY);
193 auto toColor = [needsUnpremul](uint32_t maybePremulColor) {
228 return (uint32_t)( ((
value >> 0) & 0xff) ) << 16
229 | (uint32_t)( ((
value >> 8) & 0xff) ) << 8
234 return (uint32_t)( ((
value >> 0) & 0xffff) * (255/65535.0f) ) << 16
235 | (uint32_t)( ((
value >> 16) & 0xffff) * (255/65535.0f) ) << 8
242 return (r << 16) | (g << 8) | 0xff000000;
260 return (
x <= 0.04045f) ?
x * (1 / 12.92f)
261 : std::pow(
x * (1 / 1.055f) + (0.055f / 1.055f), 2.4f);
265 float r = ((
value >> 0) & 0xff) * (1/255.0f),
266 g = ((
value >> 8) & 0xff) * (1/255.0f),
267 b = ((
value >> 16) & 0xff) * (1/255.0f),
268 a = ((
value >> 24) & 0xff) * (1/255.0f);
272 if (
a != 0 && needsUnpremul) {
277 return (uint32_t)( r * 255.0f ) << 16
278 | (uint32_t)( g * 255.0f ) << 8
279 | (uint32_t)(
b * 255.0f ) << 0
280 | (uint32_t)(
a * 255.0f ) << 24;
285 return (uint32_t)( ((
value >> 0) & 0x3ff) * (255/1023.0f) ) << 16
286 | (uint32_t)( ((
value >> 10) & 0x3ff) * (255/1023.0f) ) << 8
287 | (uint32_t)( ((
value >> 20) & 0x3ff) * (255/1023.0f) ) << 0
297 return (uint32_t)( ((
value >> 0) & 0x3ff) * (255/1023.0f) ) << 0
298 | (uint32_t)( ((
value >> 10) & 0x3ff) * (255/1023.0f) ) << 8
299 | (uint32_t)( ((
value >> 20) & 0x3ff) * (255/1023.0f) ) << 16
306 float r = ((
value >> 0) & 0x3ff) * (1/1023.0f),
307 g = ((
value >> 10) & 0x3ff) * (1/1023.0f),
308 b = ((
value >> 20) & 0x3ff) * (1/1023.0f),
309 a = ((
value >> 30) & 0x3 ) * (1/ 3.0f);
313 if (
a != 0 && needsUnpremul) {
318 return (uint32_t)( r * 255.0f ) << 16
319 | (uint32_t)( g * 255.0f ) << 8
320 | (uint32_t)(
b * 255.0f ) << 0
321 | (uint32_t)(
a * 255.0f ) << 24;
329 float r = ((
value >> 6) & 0x3ff) * (1/1023.0f),
330 g = ((
value >> 22) & 0x3ff) * (1/1023.0f),
331 b = ((
value >> 38) & 0x3ff) * (1/1023.0f),
332 a = ((
value >> 54) & 0x3ff) * (1/1023.0f);
333 return (uint32_t)( r * 255.0f ) << 16
334 | (uint32_t)( g * 255.0f ) << 8
335 | (uint32_t)(
b * 255.0f ) << 0
336 | (uint32_t)(
a * 255.0f ) << 24;
341 float r = ((
value ) & 0xffff) * (1/65535.0f),
342 g = ((
value >> 16) & 0xffff) * (1/65535.0f),
343 b = ((
value >> 32) & 0xffff) * (1/65535.0f),
344 a = ((
value >> 48) & 0xffff) * (1/65535.0f);
345 if (
a != 0 && needsUnpremul) {
350 return (uint32_t)( r * 255.0f ) << 16
351 | (uint32_t)( g * 255.0f ) << 8
352 | (uint32_t)(
b * 255.0f ) << 0
353 | (uint32_t)(
a * 255.0f ) << 24;
357 const uint64_t*
addr =
358 (
const uint64_t*)fPixels +
y * (fRowBytes >> 3) +
x;
360 if (p4[3] && needsUnpremul) {
361 float inva = 1 / p4[3];
369 (
const float*)fPixels + 4*
y*(fRowBytes >> 4) + 4*
x;
372 if (p4[3] && needsUnpremul) {
373 float inva = 1 / p4[3];
394 auto toColor = [needsUnpremul](uint32_t maybePremulColor) {
432 (uint32_t)(((
value >> 8) & 0xff)) << 8 | 0xff000000;
437 SkColor c = (uint32_t)(((
value >> 0) & 0xffff) * (255 / 65535.0f)) << 16 |
438 (uint32_t)(((
value >> 16) & 0xffff) * (255 / 65535.0f)) << 8 | 0xff000000;
464 return (
x <= 0.04045f) ?
x * (1 / 12.92f)
465 : std::pow(
x * (1 / 1.055f) + (0.055f / 1.055f), 2.4f);
469 float r = ((
value >> 0) & 0xff) * (1 / 255.0f),
470 g = ((
value >> 8) & 0xff) * (1 / 255.0f),
471 b = ((
value >> 16) & 0xff) * (1 / 255.0f),
472 a = ((
value >> 24) & 0xff) * (1 / 255.0f);
476 if (
a != 0 && needsUnpremul) {
490 float r = (uint32_t)((
value >> 0) & 0x3ff) / (1023.0f);
491 float g = (uint32_t)((
value >> 10) & 0x3ff) / (1023.0f);
492 float b = (uint32_t)((
value >> 20) & 0x3ff) / (1023.0f);
499 float r = (uint32_t)((
value >> 20) & 0x3ff) / (1023.0f);
500 float g = (uint32_t)((
value >> 10) & 0x3ff) / (1023.0f);
501 float b = (uint32_t)((
value >> 0) & 0x3ff) / (1023.0f);
509 float r = ((
value >> 0) & 0x3ff) * (1 / 1023.0f),
510 g = ((
value >> 10) & 0x3ff) * (1 / 1023.0f),
511 b = ((
value >> 20) & 0x3ff) * (1 / 1023.0f),
512 a = ((
value >> 30) & 0x3) * (1 / 3.0f);
516 if (
a != 0 && needsUnpremul) {
530 float r = ((
value >> 6) & 0x3ff) * (1/1023.0f),
531 g = ((
value >> 22) & 0x3ff) * (1/1023.0f),
532 b = ((
value >> 38) & 0x3ff) * (1/1023.0f),
533 a = ((
value >> 54) & 0x3ff) * (1/1023.0f);
539 float r = ((
value)&0xffff) * (1 / 65535.0f),
540 g = ((
value >> 16) & 0xffff) * (1 / 65535.0f),
541 b = ((
value >> 32) & 0xffff) * (1 / 65535.0f),
542 a = ((
value >> 48) & 0xffff) * (1 / 65535.0f);
543 if (
a != 0 && needsUnpremul) {
552 const uint64_t*
addr = (
const uint64_t*)fPixels +
y * (fRowBytes >> 3) +
x;
554 if (p4[3] && needsUnpremul) {
555 float inva = 1 / p4[3];
558 return SkColor4f{p4[0], p4[1], p4[2], p4[3]};
561 const float*
rgba = (
const float*)fPixels + 4 *
y * (fRowBytes >> 4) + 4 *
x;
564 if (p4[3] && needsUnpremul) {
565 float inva = 1 / p4[3];
568 return SkColor4f{p4[0], p4[1], p4[2], p4[3]};
585 const uint8_t* row = this->
addr8(0,
y);
598 const uint16_t* row = this->
addr16(0,
y);
672 const float* row = (
const float*)this->
addr();
675 if (row[4 *
x + 3] < 1.0f) {
687 const uint32_t* row = this->
addr32(0,
y);
691 if (0b11 != c >> 30) {
698 static constexpr uint64_t
kOne = 510 + 384;
700 const uint64_t* row = this->
addr64(0,
y);
702 if ((row[
x] >> 54) <
kOne) {
710 uint16_t acc = 0xFFC0;
712 const uint64_t* row = this->
addr64(0,
y);
714 acc &= (row[
x] >> 48);
723 uint16_t acc = 0xFFFF;
725 const uint64_t* row = this->
addr64(0,
y);
727 acc &= (row[
x] >> 48);
752 if (subset && !
clip.intersect(*subset)) {
758 const auto c =
color.premul();
764 uint64_t dstPixel[2] = {};
765 SkASSERT((
size_t)dst.bytesPerPixel() <=
sizeof(dstPixel));
767 if (!
SkConvertPixels(dst, dstPixel,
sizeof(dstPixel), src, &c,
sizeof(c))) {
773 memcpy(&dstColor, dstPixel,
sizeof(dstColor));
776 SK_OPTS_NS::memsetT(
addr, dstColor,
clip.width());
779 using MemSet = void(*)(
void*, uint64_t c,
int count);
780 const MemSet procs[] = {
783 SK_OPTS_NS::memsetT((uint8_t*)
addr, (uint8_t)c,
count);
787 SK_OPTS_NS::memsetT((uint16_t*)
addr, (uint16_t)c,
count);
791 SK_OPTS_NS::memsetT((uint32_t*)
addr, (uint32_t)c,
count);
794 SK_OPTS_NS::memsetT((uint64_t*)
addr, c,
count);
800 auto proc = procs[shift];
static float srgb_to_linear(float srgb)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static const uint32_t rgba[kNumPixels]
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SkDEBUGFAIL(message)
static SkPMColor SkPixel4444ToPixel32(U16CPU c)
static uint32_t SkSwizzle_RB(uint32_t c)
static SkColor SkPixel16ToColor(U16CPU src)
static SkPMColor SkSwizzle_RGBA_to_PMColor(uint32_t c)
static SkPMColor SkSwizzle_BGRA_to_PMColor(uint32_t c)
#define SkGetPackedA4444(c)
#define SkGetPackedA32(packed)
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
@ kSRGBA_8888_SkColorType
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
@ kA16_float_SkColorType
pixel with a half float for alpha
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
@ kUnknown_SkColorType
uninitialized
@ kR16G16_float_SkColorType
pixel with a half float for red and green
#define SkColorSetRGB(r, g, b)
static constexpr SkColor SkColorSetA(SkColor c, U8CPU a)
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
bool SkConvertPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRB, const SkImageInfo &srcInfo, const void *srcPixels, size_t srcRB)
float SkHalfToFloat(SkHalf h)
static constexpr uint16_t SK_Half1
static int SkColorTypeShiftPerPixel(SkColorType ct)
static bool SkImageInfoValidConversion(const SkImageInfo &dst, const SkImageInfo &src)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static const void * fast_getaddr(const SkPixmap &pm, int x, int y)
sk_sp< T > sk_ref_sp(T *obj)
static uint32_t Sk4f_toL32(const skvx::float4 &px)
static skvx::float4 swizzle_rb(const skvx::float4 &x)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
const uint8_t * addr8() const
SkColor getColor(int x, int y) const
bool computeIsOpaque() const
const uint64_t * addr64() const
const uint32_t * addr32() const
bool erase(SkColor color, const SkIRect &subset) const
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes) const
SkColorType colorType() const
void setColorSpace(sk_sp< SkColorSpace > colorSpace)
SkColorSpace * colorSpace() const
const SkImageInfo & info() const
const uint16_t * addr16() const
SkColor4f getColor4f(int x, int y) const
void * writable_addr() const
float getAlphaf(int x, int y) const
const void * addr() const
sk_sp< SkColorSpace > refColorSpace() const
SkAlphaType alphaType() const
bool extractSubset(SkPixmap *subset, const SkIRect &area) const
static SkColor PMColorToColor(SkPMColor c)
constexpr SkColor4f kTransparent
bool intersect(const SkIRect &r)
constexpr SkISize size() const
int32_t fTop
smaller y-axis bounds
constexpr int32_t width() const
void setWH(int32_t width, int32_t height)
int32_t fLeft
smaller x-axis bounds
sk_sp< SkColorSpace > refColorSpace() const
SkImageInfo makeDimensions(SkISize newSize) const
SkColorSpace * colorSpace() const
int bytesPerPixel() const
SkISize dimensions() const
SkImageInfo makeColorSpace(sk_sp< SkColorSpace > cs) const
static SkImageInfo MakeUnknown()
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkAlphaType alphaType() const
bool validRowBytes(size_t rowBytes) const
static SkImageInfo MakeA8(int width, int height)
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
static SkRGBA4f FromColor(SkColor color)
bool trim(int srcWidth, int srcHeight)
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)