9#ifdef SK_ENABLE_NDK_IMAGES
28static const char* kPng =
"png";
29static const char* kJpeg =
"jpeg";
30static const char* kWebpLossless =
"webp_lossless";
31static const char* kWebpLossy =
"webp_lossy";
78 for (
const auto& rec : gRecs) {
79 auto encoded = encode_ndk(bm.
pixmap(), rec.format, rec.quality);
101 for (
int x = 0;
x < bm.
width();
x++)
109 if (rec.name == kPng || rec.name == kWebpLossless) {
122DEF_TEST(NdkEncode_unsupportedFormats, r) {
153 for (
int quality : {-1, -100, 101, 200}) {
165 for (
const auto& rec : gRecs) {
183 if (
sizeof(
size_t) >
sizeof(uint32_t)) {
185 static_cast<size_t>(UINT32_MAX) + 1);
187 for (
const auto& pm : pixmaps) {
188 for (
const auto& rec : gRecs) {
195DEF_TEST(NdkEncode_unsupportedColorTypes, r) {
220 for (
const auto& rec : gRecs) {
229 for (
const auto& rec : gRecs) {
236DEF_TEST(NdkEncode_unsupportedAlphaTypes, r) {
242 size_t rowBytes =
info.minRowBytes();
245 for (
const auto& rec : gRecs) {
256 {0.486143, 0.323835, 0.154234},
257 {0.226676, 0.710327, 0.0629966},
258 {0.000800549, 0.0432385, 0.78275},
263 return fabs(
a -
b) < .002f;
277 for (
int i = 0;
i < 3;
i++)
278 for (
int j = 0; j < 3; j++) {
287 return a &&
b &&
a->isNumericalTransferFn(&fnA) &&
a->toXYZD50(&gamutA)
288 &&
b->isNumericalTransferFn(&fnB) &&
b->toXYZD50(&gamutB)
306 for (
const auto& colorSpace : colorSpaces) {
312 for (
const auto& rec : gRecs) {
313 auto encoded = encode_ndk(bm.
pixmap(), rec.format, rec.quality);
319 auto* actual =
gen->getInfo().colorSpace();
321 const char*
name =
"unknown";
322 for (
auto named : colorSpaces) {
329 ERRORF(r,
"Mismatch: expected: %s\tactual:%s", colorSpace.name,
name);
336DEF_TEST(NdkEncode_unsupportedColorSpace, r) {
337 std::vector<sk_sp<SkColorSpace>> unsupportedCs;
376 for (
const auto& rec : gRecs) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kUnknown_SkAlphaType
uninitialized
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ 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
#define SkColorGetR(color)
#define SkColorGetG(color)
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
#define SkColorGetA(color)
#define SkColorGetB(color)
SK_API bool SkColorTypeIsAlwaysOpaque(SkColorType ct)
static void * sk_malloc_throw(size_t size)
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)
void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const
SkColor getColor(int x, int y) const
const SkPixmap & pixmap() const
SkColorType colorType() const
const SkImageInfo & info() const
void eraseColor(SkColor4f) const
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
static sk_sp< SkColorSpace > MakeSRGBLinear()
sk_sp< SkData > detachAsData()
uint32_t uint32_t * format
std::unique_ptr< SkImageGenerator > MakeFromEncoded(sk_sp< SkData > data, std::optional< SkAlphaType > at)
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
SIN Vec< N, float > abs(const Vec< N, float > &x)
static bool nearly_equal(SkColor4f x, SkColor4f y)
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo MakeUnknown()
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)