66 {
69 return {};
70 }
77 }
83 nullptr);
85
86 unsigned char* yuvPixels[] = {
87 static_cast<unsigned char*>(pixmaps.planes()[0].writable_addr()),
88 static_cast<unsigned char*>(pixmaps.planes()[1].writable_addr()),
89 static_cast<unsigned char*>(pixmaps.planes()[2].writable_addr()),
90 static_cast<unsigned char*>(pixmaps.planes()[3].writable_addr()),
91 };
92
95
96
97 for (
int j = 0; j < pixmaps.planes()[0].
height(); ++j) {
98 for (
int i = 0;
i < pixmaps.planes()[0].
width(); ++
i) {
100 auto r = (
rgba & 0x000000ff) >> 0;
101 auto g = (
rgba & 0x0000ff00) >> 8;
102 auto b = (
rgba & 0x00ff0000) >> 16;
103 auto a = (
rgba & 0xff000000) >> 24;
104 yuvPixels[0][j*pixmaps.planes()[0].width() +
i] =
SkToU8(
107 m[15]*r +
m[16]*g +
m[17]*
b +
m[18]*
a + 255*
m[19]));
108 }
109 }
110 for (
int j = 0; j < pixmaps.planes()[1].
height(); ++j) {
111 for (
int i = 0;
i < pixmaps.planes()[1].
width(); ++
i) {
112
113 int rgba[] = {0, 0, 0, 0};
114 int denom = 0;
115 int ylimit =
std::min(2*j + 2, pixmaps.planes()[0].height());
116 int xlimit =
std::min(2*
i + 2, pixmaps.planes()[0].width());
117 for (
int y = 2*j;
y < ylimit; ++
y) {
118 for (
int x = 2*
i;
x < xlimit; ++
x) {
120 rgba[0] += (
src & 0x000000ff) >> 0;
121 rgba[1] += (
src & 0x0000ff00) >> 8;
122 rgba[2] += (
src & 0x00ff0000) >> 16;
123 rgba[3] += (
src & 0xff000000) >> 24;
124 ++denom;
125 }
126 }
127 for (int c = 0; c < 4; ++c) {
129 }
130 int uvIndex = j*pixmaps.planes()[1].width() +
i;
135 }
136 }
138 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static const uint32_t rgba[kNumPixels]
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
#define sk_float_round2int(x)
@ kJPEG_Full_SkYUVColorSpace
describes full range
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
constexpr uint8_t SkToU8(S x)
void SkColorMatrix_RGB2YUV(SkYUVColorSpace cs, float m[20])
SkISize dimensions() const
SkColorType colorType() const
const SkImageInfo & info() const
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
uint32_t * getAddr32(int x, int y) const
@ kY_U_V_A
Plane 0: Y, Plane 1: U, Plane 2: V, Plane 3: A.
@ k420
1 set of UV values for each 2x2 block of Y values.
@ kUnorm8
8 bit unsigned normalized
static SkYUVAPixmaps Allocate(const SkYUVAPixmapInfo &yuvaPixmapInfo)
static std::unique_ptr< LazyYUVImage > Make(sk_sp< SkData > data, skgpu::Mipmapped=skgpu::Mipmapped::kNo, sk_sp< SkColorSpace >=nullptr)
static float min(float r, float g, float b)
DEF_SWITCHES_START aot vmservice shared library name
SkImageInfo makeColorType(SkColorType newColorType) const