9#ifdef SK_ENABLE_NDK_IMAGES
28 auto gen = SkImageGeneratorNDK::MakeFromEncodedNDK(std::move(
data));
32 ERRORF(r,
"Failed to create NDK generator from %s\n",
path);
44 {
"images/CMYK.jpg", {642, 516}},
45 {
"images/arrow.png", {187, 312}},
46 {
"images/baby_tux.webp", {386, 395}},
47 {
"images/color_wheel.gif", {128, 128}},
48 {
"images/rle.bmp", {320, 240}},
49 {
"images/color_wheel.ico", {128, 128}},
50 {
"images/google_chrome.ico", {256, 256}},
51 {
"images/mandrill.wbmp", {512, 512}},
53 for (
auto& rec : recs) {
54 auto gen = make_generator(rec.fPath, r);
57 const auto&
info =
gen->getInfo();
72 auto gen = SkImageGeneratorNDK::MakeFromEncodedNDK(
nullptr);
79 {0.486143, 0.323835, 0.154234},
80 {0.226676, 0.710327, 0.0629966},
81 {0.000800549, 0.0432385, 0.78275},
84DEF_TEST(NdkDecode_reportedColorSpace, r) {
115 auto gen = SkImageGeneratorNDK::MakeFromEncodedNDK(
stream.detachAsData());
117 ERRORF(r,
"Failed to encode!");
128 for (
const char*
path: {
131 "images/baby_tux.webp",
132 "images/color_wheel.gif",
134 "images/color_wheel.ico",
135 "images/google_chrome.ico",
136 "images/mandrill.wbmp",
138 auto gen = make_generator(
path, r);
151 auto info =
gen->getInfo().makeColorSpace(cs);
158 std::vector<sk_sp<SkColorSpace>> unsupportedCs;
201DEF_TEST(NdkDecode_reuseNoColorSpace, r) {
202 static const struct {
213 for (
auto& rec : recs) {
214 auto gen = make_generator(rec.fPath, r);
220 auto noColorCorrection =
gen->getInfo().makeColorSpace(
nullptr);
232 corrected.
allocPixels(noColorCorrection.makeColorSpace(rec.fCorrectedColorSpace));
248 for (
const char*
path: {
251 "images/baby_tux.webp",
252 "images/color_wheel.gif",
254 "images/color_wheel.ico",
255 "images/google_chrome.ico",
256 "images/mandrill.wbmp",
258 auto gen = make_generator(
path, r);
261 const auto actualDimensions =
gen->getInfo().dimensions();
262 const int width = actualDimensions.width();
263 const int height = actualDimensions.height();
268 auto info =
gen->getInfo().makeDimensions(dims);
277DEF_TEST(NdkDecode_webpArbitraryDownscale, r) {
278 for (
const char*
path: {
279 "images/baby_tux.webp",
280 "images/yellow_rose.webp",
281 "images/webp-color-profile-lossless.webp",
283 auto gen = make_generator(
path, r);
286 const auto actualDimensions =
gen->getInfo().dimensions();
287 const int width = actualDimensions.width();
288 const int height = actualDimensions.height();
297 auto info =
gen->getInfo().makeDimensions(dims);
311DEF_TEST(NdkDecode_jpegDownscale, r) {
312 static const struct {
316 {
"images/CMYK.jpg", {{642,516},{321,258},{161,129},{81,65}}},
317 {
"images/dog.jpg", {{180,180},{90,90},{45,45},{23,23}}},
318 {
"images/grayscale.jpg", {{128,128},{64,64},{32,32},{16,16}}},
319 {
"images/brickwork-texture.jpg", {{512,512},{256,256},{128,128},{64,64}}},
320 {
"images/mandrill_h2v1.jpg", {{512,512},{256,256},{128,128},{64,64}}},
321 {
"images/ducky.jpg", {{489,537},{245,269},{123,135},{62,68}}},
323 for (
auto& rec : recs) {
324 auto gen = make_generator(rec.fPath, r);
327 for (
SkISize dims : rec.fSupportedSizes) {
328 auto info =
gen->getInfo().makeDimensions(dims);
332 ERRORF(r,
"failed to decode %s to {%i,%i}\n", rec.fPath, dims.
width(),
345 auto gen = make_generator(
"images/CMYK.jpg", r);
368 for (
const char*
path: {
370 "images/color_wheel.gif",
372 "images/color_wheel.ico",
373 "images/google_chrome.ico",
374 "images/mandrill.wbmp",
376 auto gen = make_generator(
path, r);
379 const auto actualDimensions =
gen->getInfo().dimensions();
380 const int width = actualDimensions.width();
381 const int height = actualDimensions.height();
389 auto info =
gen->getInfo().makeDimensions(dims);
398 static const struct {
402 {
"images/CMYK.jpg",
false},
403 {
"images/arrow.png",
false},
404 {
"images/baby_tux.webp",
false},
405 {
"images/color_wheel.gif",
false},
406 {
"images/rle.bmp",
false},
407 {
"images/color_wheel.ico",
false},
408 {
"images/google_chrome.ico",
false},
409 {
"images/mandrill.wbmp",
true},
410 {
"images/grayscale.jpg",
true},
411 {
"images/grayscale.png",
true},
413 for (
auto& rec : recs) {
414 auto gen = make_generator(rec.fPath, r);
418 if (rec.fGrayscale) {
426 bool success =
gen->getPixels(bm.
pixmap());
427 if (success != rec.fGrayscale) {
428 ERRORF(r,
"Expected decoding %s to Gray8 to %s. Actual: %s\n", rec.fPath,
429 (rec.fGrayscale ?
"succeed" :
"fail"), (success ?
"succeed" :
"fail"));
434DEF_TEST(NdkDecode_Opaque_and_565, r) {
435 for (
const char*
path: {
440 "images/example_1.png",
441 "images/explosion_sprites.png",
442 "images/lut_identity.png",
443 "images/grayscale.png",
444 "images/baby_tux.webp",
445 "images/yellow_rose.webp",
446 "images/webp-color-profile-lossless.webp",
447 "images/colorTables.gif",
448 "images/color_wheel.gif",
449 "images/flightAnim.gif",
450 "images/randPixels.gif",
452 "images/color_wheel.ico",
453 "images/google_chrome.ico",
454 "images/mandrill.wbmp",
456 auto gen = make_generator(
path, r);
462 bool success =
gen->getPixels(bm.
pixmap());
472DEF_TEST(NdkDecode_AlwaysSupportedColorTypes, r) {
473 for (
const char*
path: {
478 "images/example_1.png",
479 "images/explosion_sprites.png",
480 "images/lut_identity.png",
481 "images/grayscale.png",
482 "images/baby_tux.webp",
483 "images/yellow_rose.webp",
484 "images/webp-color-profile-lossless.webp",
485 "images/colorTables.gif",
486 "images/color_wheel.gif",
487 "images/flightAnim.gif",
488 "images/randPixels.gif",
490 "images/color_wheel.ico",
491 "images/google_chrome.ico",
492 "images/mandrill.wbmp",
494 auto gen = make_generator(
path, r);
510DEF_TEST(NdkDecode_UnsupportedColorTypes, r) {
511 for (
const char*
path: {
516 "images/example_1.png",
517 "images/explosion_sprites.png",
518 "images/lut_identity.png",
519 "images/grayscale.png",
520 "images/baby_tux.webp",
521 "images/yellow_rose.webp",
522 "images/webp-color-profile-lossless.webp",
523 "images/colorTables.gif",
524 "images/color_wheel.gif",
525 "images/flightAnim.gif",
526 "images/randPixels.gif",
528 "images/color_wheel.ico",
529 "images/google_chrome.ico",
530 "images/mandrill.wbmp",
532 auto gen = make_generator(
path, r);
554 auto info =
gen->getInfo().makeColorType(ct);
558 ERRORF(r,
"Expected decoding %s to %i to fail!",
path, ct);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
sk_sp< SkData > GetResourceAsData(const char *resource)
@ kOpaque_SkAlphaType
pixel is opaque
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
@ 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
@ 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
@ 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
@ 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
constexpr SkColor SK_ColorBLUE
static constexpr skcms_TransferFunction k2Dot6
static constexpr skcms_Matrix3x3 kDCIP3
#define DEF_TEST(name, reporter)
#define REPORTER_ASSERT(r, cond,...)
void allocPixels(const SkImageInfo &info, size_t rowBytes)
const SkPixmap & pixmap() const
void eraseColor(SkColor4f) const
static bool Equals(const SkColorSpace *, const SkColorSpace *)
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
static sk_sp< SkColorSpace > MakeSRGBLinear()
uint32_t uint32_t * format
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
static constexpr skcms_Matrix3x3 kSRGB
static constexpr skcms_Matrix3x3 kAdobeRGB
static constexpr skcms_Matrix3x3 kXYZ
static constexpr skcms_Matrix3x3 kRec2020
static constexpr skcms_Matrix3x3 kDisplayP3
static constexpr skcms_TransferFunction kRec2020
static constexpr skcms_TransferFunction k2Dot2
static constexpr skcms_TransferFunction kSRGB
static constexpr skcms_TransferFunction kHLG
static constexpr skcms_TransferFunction kPQ
static constexpr skcms_TransferFunction kLinear
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
static bool unsupported()
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
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
constexpr int32_t width() const
constexpr int32_t height() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data