Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ReadPixelsTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 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
22#include "include/core/SkRect.h"
32#include "src/base/SkHalf.h"
33#include "src/base/SkMathPriv.h"
35#include "tests/Test.h"
36
37#include <cstdint>
38#include <cstring>
39#include <initializer_list>
40#include <memory>
41#include <string>
42
43static const int DEV_W = 100, DEV_H = 100;
47
48static SkPMColor get_src_color(int x, int y) {
49 SkASSERT(x >= 0 && x < DEV_W);
50 SkASSERT(y >= 0 && y < DEV_H);
51
52 U8CPU r = x;
53 U8CPU g = y;
54 U8CPU b = 0xc;
55
56 U8CPU a = 0xff;
57 switch ((x+y) % 5) {
58 case 0:
59 a = 0xff;
60 break;
61 case 1:
62 a = 0x80;
63 break;
64 case 2:
65 a = 0xCC;
66 break;
67 case 4:
68 a = 0x01;
69 break;
70 case 3:
71 a = 0x00;
72 break;
73 }
74 return SkPremultiplyARGBInline(a, r, g, b);
75}
76
77static SkPMColor get_dst_bmp_init_color(int x, int y, int w) {
78 int n = y * w + x;
79
80 U8CPU b = n & 0xff;
81 U8CPU g = (n >> 8) & 0xff;
82 U8CPU r = (n >> 16) & 0xff;
83 return SkPackARGB32(0xff, r, g , b);
84}
85
86// TODO: Make this consider both ATs
87static SkPMColor convert_to_pmcolor(SkColorType ct, SkAlphaType at, const uint32_t* addr,
88 bool* doUnpremul) {
89 *doUnpremul = (kUnpremul_SkAlphaType == at);
90
91 const uint8_t* c = reinterpret_cast<const uint8_t*>(addr);
92 U8CPU a,r,g,b;
93 switch (ct) {
95 b = static_cast<U8CPU>(c[0]);
96 g = static_cast<U8CPU>(c[1]);
97 r = static_cast<U8CPU>(c[2]);
98 a = static_cast<U8CPU>(c[3]);
99 break;
100 case kRGB_888x_SkColorType: // fallthrough
102 r = static_cast<U8CPU>(c[0]);
103 g = static_cast<U8CPU>(c[1]);
104 b = static_cast<U8CPU>(c[2]);
105 // We set this even for kRGB_888x because our caller will validate that it is 0xff.
106 a = static_cast<U8CPU>(c[3]);
107 break;
108 default:
109 SkDEBUGFAIL("Unexpected colortype");
110 return 0;
111 }
112
113 if (*doUnpremul) {
114 r = SkMulDiv255Ceiling(r, a);
115 g = SkMulDiv255Ceiling(g, a);
117 }
118 return SkPackARGB32(a, r, g, b);
119}
120
122 static SkBitmap bmp;
123 if (bmp.isNull()) {
125 intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
126 for (int y = 0; y < DEV_H; ++y) {
127 for (int x = 0; x < DEV_W; ++x) {
128 SkPMColor* pixel = reinterpret_cast<SkPMColor*>(pixels + y * bmp.rowBytes() + x * bmp.bytesPerPixel());
129 *pixel = get_src_color(x, y);
130 }
131 }
132 bmp.setImmutable();
133 }
134 return bmp.asImage();
135}
136
137static void fill_src_canvas(SkCanvas* canvas) {
138 canvas->save();
139 canvas->setMatrix(SkMatrix::I());
142 paint.setBlendMode(SkBlendMode::kSrc);
143 canvas->drawImage(make_src_image(), 0, 0, SkSamplingOptions(), &paint);
144 canvas->restore();
145}
146
148 int w = bitmap->width();
149 int h = bitmap->height();
150 intptr_t pixels = reinterpret_cast<intptr_t>(bitmap->getPixels());
151 for (int y = 0; y < h; ++y) {
152 for (int x = 0; x < w; ++x) {
153 SkPMColor initColor = get_dst_bmp_init_color(x, y, w);
154 if (kAlpha_8_SkColorType == bitmap->colorType()) {
155 uint8_t* alpha = reinterpret_cast<uint8_t*>(pixels + y * bitmap->rowBytes() + x);
156 *alpha = SkGetPackedA32(initColor);
157 } else {
158 SkPMColor* pixel = reinterpret_cast<SkPMColor*>(pixels + y * bitmap->rowBytes() + x * bitmap->bytesPerPixel());
159 *pixel = initColor;
160 }
161 }
162 }
163}
164
165static bool check_read_pixel(SkPMColor a, SkPMColor b, bool didPremulConversion) {
166 if (!didPremulConversion) {
167 return a == b;
168 }
169 int32_t aA = static_cast<int32_t>(SkGetPackedA32(a));
170 int32_t aR = static_cast<int32_t>(SkGetPackedR32(a));
171 int32_t aG = static_cast<int32_t>(SkGetPackedG32(a));
172 int32_t aB = SkGetPackedB32(a);
173
174 int32_t bA = static_cast<int32_t>(SkGetPackedA32(b));
175 int32_t bR = static_cast<int32_t>(SkGetPackedR32(b));
176 int32_t bG = static_cast<int32_t>(SkGetPackedG32(b));
177 int32_t bB = static_cast<int32_t>(SkGetPackedB32(b));
178
179 return aA == bA &&
180 SkAbs32(aR - bR) <= 1 &&
181 SkAbs32(aG - bG) <= 1 &&
182 SkAbs32(aB - bB) <= 1;
183}
184
185// checks the bitmap contains correct pixels after the readPixels
186// if the bitmap was prefilled with pixels it checks that these weren't
187// overwritten in the area outside the readPixels.
188static bool check_read(skiatest::Reporter* reporter, const SkBitmap& bitmap, int x, int y,
189 bool checkSurfacePixels, bool checkBitmapPixels,
190 const SkImageInfo& surfaceInfo) {
191 SkAlphaType bmpAT = bitmap.alphaType();
192 SkColorType bmpCT = bitmap.colorType();
193 SkASSERT(!bitmap.isNull());
194 SkASSERT(checkSurfacePixels || checkBitmapPixels);
195
196 int bw = bitmap.width();
197 int bh = bitmap.height();
198
199 SkIRect srcRect = SkIRect::MakeXYWH(x, y, bw, bh);
200 SkIRect clippedSrcRect = DEV_RECT;
201 if (!clippedSrcRect.intersect(srcRect)) {
202 clippedSrcRect.setEmpty();
203 }
204 if (kAlpha_8_SkColorType == bmpCT) {
205 for (int by = 0; by < bh; ++by) {
206 for (int bx = 0; bx < bw; ++bx) {
207 int devx = bx + srcRect.fLeft;
208 int devy = by + srcRect.fTop;
209 const uint8_t* alpha = bitmap.getAddr8(bx, by);
210
211 if (clippedSrcRect.contains(devx, devy)) {
212 if (checkSurfacePixels) {
213 uint8_t surfaceAlpha = (surfaceInfo.alphaType() == kOpaque_SkAlphaType)
214 ? 0xFF
215 : SkGetPackedA32(get_src_color(devx, devy));
216 if (surfaceAlpha != *alpha) {
218 "Expected readback alpha (%d, %d) value 0x%02x, got 0x%02x. ",
219 bx, by, surfaceAlpha, *alpha);
220 return false;
221 }
222 }
223 } else if (checkBitmapPixels) {
224 uint32_t origDstAlpha = SkGetPackedA32(get_dst_bmp_init_color(bx, by, bw));
225 if (origDstAlpha != *alpha) {
226 ERRORF(reporter, "Expected clipped out area of readback to be unchanged. "
227 "Expected 0x%02x, got 0x%02x", origDstAlpha, *alpha);
228 return false;
229 }
230 }
231 }
232 }
233 return true;
234 }
235 for (int by = 0; by < bh; ++by) {
236 for (int bx = 0; bx < bw; ++bx) {
237 int devx = bx + srcRect.fLeft;
238 int devy = by + srcRect.fTop;
239
240 const uint32_t* pixel = bitmap.getAddr32(bx, by);
241
242 if (clippedSrcRect.contains(devx, devy)) {
243 if (checkSurfacePixels) {
244 SkPMColor surfacePMColor = get_src_color(devx, devy);
245 if (SkColorTypeIsAlphaOnly(surfaceInfo.colorType())) {
246 surfacePMColor &= 0xFF000000;
247 }
248 if (kOpaque_SkAlphaType == surfaceInfo.alphaType() || kOpaque_SkAlphaType == bmpAT) {
249 surfacePMColor |= 0xFF000000;
250 }
251 bool didPremul;
252 SkPMColor pmPixel = convert_to_pmcolor(bmpCT, bmpAT, pixel, &didPremul);
253 if (!check_read_pixel(pmPixel, surfacePMColor, didPremul)) {
255 "Expected readback pixel (%d, %d) value 0x%08x, got 0x%08x. "
256 "Readback was unpremul: %d",
257 bx, by, surfacePMColor, pmPixel, didPremul);
258 return false;
259 }
260 }
261 } else if (checkBitmapPixels) {
262 uint32_t origDstPixel = get_dst_bmp_init_color(bx, by, bw);
263 if (origDstPixel != *pixel) {
264 ERRORF(reporter, "Expected clipped out area of readback to be unchanged. "
265 "Expected 0x%08x, got 0x%08x", origDstPixel, *pixel);
266 return false;
267 }
268 }
269 }
270 }
271 return true;
272}
273
274enum class TightRowBytes : bool { kNo, kYes };
275
276static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, TightRowBytes tightRB,
277 SkColorType ct, SkAlphaType at) {
278 SkImageInfo info = SkImageInfo::Make(rect.size(), ct, at);
279 size_t rowBytes = 0;
280 if (tightRB == TightRowBytes::kNo) {
281 rowBytes = SkAlign4((info.width() + 16) * info.bytesPerPixel());
282 }
283 bitmap->allocPixels(info, rowBytes);
284}
285
286static const struct {
289} gReadPixelsConfigs[] = {
298 // entire thing
299 DEV_RECT,
300 // larger on all sides
301 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, DEV_H + 10),
302 // fully contained
303 SkIRect::MakeLTRB(DEV_W / 4, DEV_H / 4, 3 * DEV_W / 4, 3 * DEV_H / 4),
304 // outside top left
305 SkIRect::MakeLTRB(-10, -10, -1, -1),
306 // touching top left corner
307 SkIRect::MakeLTRB(-10, -10, 0, 0),
308 // overlapping top left corner
309 SkIRect::MakeLTRB(-10, -10, DEV_W / 4, DEV_H / 4),
310 // overlapping top left and top right corners
311 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, DEV_H / 4),
312 // touching entire top edge
313 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, 0),
314 // overlapping top right corner
315 SkIRect::MakeLTRB(3 * DEV_W / 4, -10, DEV_W + 10, DEV_H / 4),
316 // contained in x, overlapping top edge
317 SkIRect::MakeLTRB(DEV_W / 4, -10, 3 * DEV_W / 4, DEV_H / 4),
318 // outside top right corner
319 SkIRect::MakeLTRB(DEV_W + 1, -10, DEV_W + 10, -1),
320 // touching top right corner
321 SkIRect::MakeLTRB(DEV_W, -10, DEV_W + 10, 0),
322 // overlapping top left and bottom left corners
323 SkIRect::MakeLTRB(-10, -10, DEV_W / 4, DEV_H + 10),
324 // touching entire left edge
325 SkIRect::MakeLTRB(-10, -10, 0, DEV_H + 10),
326 // overlapping bottom left corner
327 SkIRect::MakeLTRB(-10, 3 * DEV_H / 4, DEV_W / 4, DEV_H + 10),
328 // contained in y, overlapping left edge
329 SkIRect::MakeLTRB(-10, DEV_H / 4, DEV_W / 4, 3 * DEV_H / 4),
330 // outside bottom left corner
331 SkIRect::MakeLTRB(-10, DEV_H + 1, -1, DEV_H + 10),
332 // touching bottom left corner
333 SkIRect::MakeLTRB(-10, DEV_H, 0, DEV_H + 10),
334 // overlapping bottom left and bottom right corners
335 SkIRect::MakeLTRB(-10, 3 * DEV_H / 4, DEV_W + 10, DEV_H + 10),
336 // touching entire left edge
338 // overlapping bottom right corner
339 SkIRect::MakeLTRB(3 * DEV_W / 4, 3 * DEV_H / 4, DEV_W + 10, DEV_H + 10),
340 // overlapping top right and bottom right corners
341 SkIRect::MakeLTRB(3 * DEV_W / 4, -10, DEV_W + 10, DEV_H + 10),
342};
343
344bool read_should_succeed(const SkIRect& srcRect, const SkImageInfo& dstInfo,
345 const SkImageInfo& srcInfo) {
346 return SkIRect::Intersects(srcRect, DEV_RECT) && SkImageInfoValidConversion(dstInfo, srcInfo);
347}
348
350 const SkImageInfo& surfaceInfo) {
351 SkCanvas* canvas = surface->getCanvas();
352 fill_src_canvas(canvas);
353 for (size_t rect = 0; rect < std::size(gReadPixelsTestRects); ++rect) {
354 const SkIRect& srcRect = gReadPixelsTestRects[rect];
355 for (auto tightRB : {TightRowBytes::kYes, TightRowBytes::kNo}) {
356 for (size_t c = 0; c < std::size(gReadPixelsConfigs); ++c) {
357 SkBitmap bmp;
358 init_bitmap(&bmp, srcRect, tightRB, gReadPixelsConfigs[c].fColorType,
360
361 // if the bitmap has pixels allocated before the readPixels,
362 // note that and fill them with pattern
363 bool startsWithPixels = !bmp.isNull();
364 if (startsWithPixels) {
366 }
367 uint32_t idBefore = surface->generationID();
368 bool success = surface->readPixels(bmp, srcRect.fLeft, srcRect.fTop);
369 uint32_t idAfter = surface->generationID();
370
371 // we expect to succeed when the read isn't fully clipped out and the infos are
372 // compatible.
373 bool expectSuccess = read_should_succeed(srcRect, bmp.info(), surfaceInfo);
374 // determine whether we expected the read to succeed.
375 REPORTER_ASSERT(reporter, expectSuccess == success,
376 "Read succeed=%d unexpectedly, src ct/at: %d/%d, dst ct/at: %d/%d",
377 success, surfaceInfo.colorType(), surfaceInfo.alphaType(),
378 bmp.info().colorType(), bmp.info().alphaType());
379 // read pixels should never change the gen id
380 REPORTER_ASSERT(reporter, idBefore == idAfter);
381
382 if (success || startsWithPixels) {
383 check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop, success,
384 startsWithPixels, surfaceInfo);
385 } else {
386 // if we had no pixels beforehand and the readPixels
387 // failed then our bitmap should still not have pixels
389 }
390 }
391 }
392 }
393}
394
400
401///////////////////////////////////////////////////////////////////////////////////////////////////
402
403static const uint32_t kNumPixels = 5;
404
405// The five reference pixels are: red, green, blue, white, black.
406// Five is an interesting number to test because we'll exercise a full 4-wide SIMD vector
407// plus a tail pixel.
408static const uint32_t rgba[kNumPixels] = {
409 0xFF0000FF, 0xFF00FF00, 0xFFFF0000, 0xFFFFFFFF, 0xFF000000
410};
411static const uint32_t bgra[kNumPixels] = {
412 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000
413};
414static const uint16_t rgb565[kNumPixels] = {
416};
417
418static const uint16_t rgba4444[kNumPixels] = { 0xF00F, 0x0F0F, 0x00FF, 0xFFFF, 0x000F };
419
420static const uint64_t kRed = (uint64_t) SK_Half1 << 0;
421static const uint64_t kGreen = (uint64_t) SK_Half1 << 16;
422static const uint64_t kBlue = (uint64_t) SK_Half1 << 32;
423static const uint64_t kAlpha = (uint64_t) SK_Half1 << 48;
424static const uint64_t f16[kNumPixels] = {
426};
427
428static const uint8_t alpha8[kNumPixels] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
429static const uint8_t gray8[kNumPixels] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
430
432 switch (colorType) {
434 return nullptr;
436 return alpha8;
438 return rgb565;
440 return rgba4444;
442 return rgba;
444 return bgra;
446 return gray8;
448 return f16;
449 default:
450 return nullptr;
451 }
452
453 SkASSERT(false);
454 return nullptr;
455}
456
457static void test_conversion(skiatest::Reporter* r, const SkImageInfo& dstInfo,
458 const SkImageInfo& srcInfo) {
459 if (!SkImageInfoIsValid(srcInfo)) {
460 return;
461 }
462
463 const void* srcPixels = five_reference_pixels(srcInfo.colorType());
464 SkPixmap srcPixmap(srcInfo, srcPixels, srcInfo.minRowBytes());
465 sk_sp<SkImage> src = SkImages::RasterFromPixmap(srcPixmap, nullptr, nullptr);
466 REPORTER_ASSERT(r, src);
467
468 // Enough space for 5 pixels when color type is F16, more than enough space in other cases.
469 uint64_t dstPixels[kNumPixels];
470 SkPixmap dstPixmap(dstInfo, dstPixels, dstInfo.minRowBytes());
471 bool success = src->readPixels(nullptr, dstPixmap, 0, 0);
472 REPORTER_ASSERT(r, success == SkImageInfoValidConversion(dstInfo, srcInfo));
473
474 if (success) {
475 if (kGray_8_SkColorType == srcInfo.colorType() &&
476 kGray_8_SkColorType != dstInfo.colorType()) {
477 // TODO: test (r,g,b) == (gray,gray,gray)?
478 return;
479 }
480
481 if (kGray_8_SkColorType == dstInfo.colorType() &&
482 kGray_8_SkColorType != srcInfo.colorType()) {
483 // TODO: test gray = luminance?
484 return;
485 }
486
487 if (kAlpha_8_SkColorType == srcInfo.colorType() &&
488 kAlpha_8_SkColorType != dstInfo.colorType()) {
489 // TODO: test output = black with this alpha?
490 return;
491 }
492
493 REPORTER_ASSERT(r, 0 == memcmp(dstPixels, five_reference_pixels(dstInfo.colorType()),
495 }
496}
497
498DEF_TEST(ReadPixels_ValidConversion, reporter) {
499 const SkColorType kColorTypes[] = {
508 };
509
510 const SkAlphaType kAlphaTypes[] = {
515 };
516
517 const sk_sp<SkColorSpace> kColorSpaces[] = {
518 nullptr,
520 };
521
522 for (SkColorType dstCT : kColorTypes) {
523 for (SkAlphaType dstAT : kAlphaTypes) {
524 for (const sk_sp<SkColorSpace>& dstCS : kColorSpaces) {
525 for (SkColorType srcCT : kColorTypes) {
526 for (SkAlphaType srcAT : kAlphaTypes) {
527 for (const sk_sp<SkColorSpace>& srcCS : kColorSpaces) {
529 SkImageInfo::Make(kNumPixels, 1, dstCT, dstAT, dstCS),
530 SkImageInfo::Make(kNumPixels, 1, srcCT, srcAT, srcCS));
531 }
532 }
533 }
534 }
535 }
536 }
537}
538
539DEF_TEST(ReadPixels_InvalidRowBytes, reporter) {
541 auto surf = SkSurfaces::Raster(srcII);
542 for (int ct = 0; ct < kLastEnum_SkColorType + 1; ++ct) {
543 auto colorType = static_cast<SkColorType>(ct);
545 if (bpp <= 1) {
546 continue;
547 }
548 auto dstII = srcII.makeColorType(colorType);
549 size_t badRowBytes = (surf->width() + 1)*bpp - 1;
550 auto storage = std::make_unique<char[]>(badRowBytes*surf->height());
551 REPORTER_ASSERT(reporter, !surf->readPixels(dstII, storage.get(), badRowBytes, 0, 0));
552 }
553}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
reporter
kUnpremul_SkAlphaType
static void fill_src_canvas(SkCanvas *canvas)
static const uint32_t kNumPixels
static void test_conversion(skiatest::Reporter *r, const SkImageInfo &dstInfo, const SkImageInfo &srcInfo)
static const uint16_t rgba4444[kNumPixels]
static const uint32_t bgra[kNumPixels]
static const SkRect DEV_RECT_S
static const int DEV_H
static const uint8_t alpha8[kNumPixels]
static bool check_read_pixel(SkPMColor a, SkPMColor b, bool didPremulConversion)
static void fill_dst_bmp_with_init_data(SkBitmap *bitmap)
static const uint16_t rgb565[kNumPixels]
static SkPMColor get_src_color(int x, int y)
static const uint64_t kGreen
static sk_sp< SkImage > make_src_image()
static void test_readpixels(skiatest::Reporter *reporter, const sk_sp< SkSurface > &surface, const SkImageInfo &surfaceInfo)
static const uint32_t rgba[kNumPixels]
SkColorType fColorType
static SkPMColor convert_to_pmcolor(SkColorType ct, SkAlphaType at, const uint32_t *addr, bool *doUnpremul)
static const uint64_t kAlpha
static const struct @443 gReadPixelsConfigs[]
bool read_should_succeed(const SkIRect &srcRect, const SkImageInfo &dstInfo, const SkImageInfo &srcInfo)
static SkPMColor get_dst_bmp_init_color(int x, int y, int w)
static const uint64_t kBlue
static const uint64_t f16[kNumPixels]
static const void * five_reference_pixels(SkColorType colorType)
TightRowBytes
SkAlphaType fAlphaType
static const uint64_t kRed
const SkIRect gReadPixelsTestRects[]
static const SkIRect DEV_RECT
static const uint8_t gray8[kNumPixels]
static void init_bitmap(SkBitmap *bitmap, const SkIRect &rect, TightRowBytes tightRB, SkColorType ct, SkAlphaType at)
static const int DEV_W
static bool check_read(skiatest::Reporter *reporter, const SkBitmap &bitmap, int x, int y, bool checkSurfacePixels, bool checkBitmapPixels, const SkImageInfo &surfaceInfo)
static constexpr T SkAlign4(T x)
Definition SkAlign.h:16
SkAlphaType
Definition SkAlphaType.h:26
@ kUnknown_SkAlphaType
uninitialized
Definition SkAlphaType.h:27
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118
#define SkASSERT(cond)
Definition SkAssert.h:116
unsigned U8CPU
Definition SkCPUTypes.h:18
#define SK_R16_MASK_IN_PLACE
#define SK_G16_MASK_IN_PLACE
#define SK_B16_MASK_IN_PLACE
#define SkGetPackedB32(packed)
Definition SkColorPriv.h:95
#define SkGetPackedR32(packed)
Definition SkColorPriv.h:93
static SkPMColor SkPremultiplyARGBInline(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkGetPackedA32(packed)
Definition SkColorPriv.h:92
#define SkGetPackedG32(packed)
Definition SkColorPriv.h:94
static SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
SkColorType
Definition SkColorType.h:19
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition SkColorType.h:23
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ 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
@ kLastEnum_SkColorType
last valid value
Definition SkColorType.h:56
@ 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
@ 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
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20
uint32_t SkPMColor
Definition SkColor.h:205
static constexpr uint16_t SK_Half1
Definition SkHalf.h:23
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static bool SkColorTypeIsAlphaOnly(SkColorType ct)
static bool SkImageInfoIsValid(const SkImageInfo &info)
static bool SkImageInfoValidConversion(const SkImageInfo &dst, const SkImageInfo &src)
SK_API int SkColorTypeBytesPerPixel(SkColorType ct)
static U8CPU SkMulDiv255Ceiling(U8CPU a, U8CPU b)
Definition SkMathPriv.h:102
static int32_t SkAbs32(int32_t value)
Definition SkSafe32.h:41
#define SK_Scalar1
Definition SkScalar.h:18
#define DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
#define ERRORF(r,...)
Definition Test.h:293
sk_sp< SkImage > asImage() const
Definition SkBitmap.cpp:645
void setImmutable()
Definition SkBitmap.cpp:400
size_t rowBytes() const
Definition SkBitmap.h:238
bool isNull() const
Definition SkBitmap.h:219
void * getPixels() const
Definition SkBitmap.h:283
const SkImageInfo & info() const
Definition SkBitmap.h:139
int bytesPerPixel() const
Definition SkBitmap.h:187
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition SkBitmap.cpp:232
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void restore()
Definition SkCanvas.cpp:465
int save()
Definition SkCanvas.cpp:451
void setMatrix(const SkM44 &matrix)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
static sk_sp< SkColorSpace > MakeSRGB()
static const SkMatrix & I()
const Paint & paint
VkSurfaceKHR surface
Definition main.cc:49
static bool b
struct MyStruct a[10]
double y
double x
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SkScalar w
SkScalar h
bool intersect(const SkIRect &r)
Definition SkRect.h:513
static bool Intersects(const SkIRect &a, const SkIRect &b)
Definition SkRect.h:535
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
Definition SkRect.h:91
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
void setEmpty()
Definition SkRect.h:242
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33
bool contains(int32_t x, int32_t y) const
Definition SkRect.h:463
static SkImageInfo MakeN32Premul(int width, int height)
size_t minRowBytes() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkAlphaType alphaType() const
SkColorType colorType() const
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609