Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
png_codec.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
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
8#include "gm/gm.h"
16#include "include/core/SkRect.h"
17#include "include/core/SkSize.h"
24#include "src/utils/SkOSPath.h"
27
28#include <map>
29#include <memory>
30#include <string>
31#include <vector>
32
33DEFINE_string(pngCodecGMImages,
34 "",
35 "Zero or more images or directories where to find PNG images to test with "
36 "PNGCodecGM. Directories are scanned non-recursively. All files are assumed to be "
37 "PNG images.");
38DEFINE_string(pngCodecDecodeMode,
39 "",
40 "One of \"get-all-pixels\", \"incremental\" or \"zero-init\".");
41DEFINE_string(pngCodecDstColorType,
42 "",
43 "One of \"force-grayscale\", "
44 "\"force-nonnative-premul-color\" or \"get-from-canvas\".");
45DEFINE_string(pngCodecDstAlphaType, "", "One of \"premul\" or \"unpremul\".");
46
47static constexpr const char* sk_color_type_to_str(SkColorType colorType) {
48 switch (colorType) {
50 return "kUnknown_SkColorType";
52 return "kAlpha_8_SkColorType";
54 return "kRGB_565_SkColorType";
56 return "kARGB_4444_SkColorType";
58 return "kRGBA_8888_SkColorType";
60 return "kRGB_888x_SkColorType";
62 return "kBGRA_8888_SkColorType";
64 return "kRGBA_1010102_SkColorType";
66 return "kBGRA_1010102_SkColorType";
68 return "kRGB_101010x_SkColorType";
70 return "kBGR_101010x_SkColorType";
72 return "kBGR_101010x_XR_SkColorType";
74 return "kGray_8_SkColorType";
76 return "kRGBA_F16Norm_SkColorType";
78 return "kRGBA_F16_SkColorType";
80 return "kRGBA_F32_SkColorType";
82 return "kR8G8_unorm_SkColorType";
84 return "kA16_float_SkColorType";
86 return "kR16G16_float_SkColorType";
88 return "kA16_unorm_SkColorType";
90 return "kR16G16_unorm_SkColorType";
92 return "kR16G16B16A16_unorm_SkColorType";
94 return "kSRGBA_8888_SkColorType";
96 return "kR8_unorm_SkColorType";
98 return "kRGBA_10x6_SkColorType";
100 return "kBGRA_10101010_XR_SkColorType";
101 }
103}
104
105static constexpr const char* sk_alpha_type_to_str(SkAlphaType alphaType) {
106 switch (alphaType) {
108 return "kUnknown_SkAlphaType";
110 return "kOpaque_SkAlphaType";
112 return "kPremul_SkAlphaType";
114 return "kUnpremul_SkAlphaType";
115 }
117}
118
120 std::unique_ptr<SkCodec> codec;
121 std::string errorMsg;
122};
123
124static DecodeResult decode(std::string path) {
125 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
126 if (!encoded) {
127 return {.errorMsg = SkStringPrintf("Could not read \"%s\".", path.c_str()).c_str()};
128 }
130 std::unique_ptr<SkCodec> codec = SkPngDecoder::Decode(SkMemoryStream::Make(encoded), &result);
132 return {.errorMsg = SkStringPrintf("Could not create codec for \"%s\": %s.",
133 path.c_str(),
135 .c_str()};
136 }
137 return {.codec = std::move(codec)};
138}
139
140// This GM implements the PNG-related behaviors found in DM's CodecSrc class. It takes a single
141// image as an argument and applies the same logic as CodecSrc.
142//
143// See the CodecSrc class here:
144// https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.h#158.
145class PNGCodecGM : public skiagm::GM {
146public:
147 // Based on CodecSrc::Mode.
148 // https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.h#160
149 enum class DecodeMode {
152 kZeroInit,
153 };
154
155 // Based on CodecSrc::DstColorType.
156 // https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.h#172
162
163 static constexpr const char* DecodeModeToString(DecodeMode decodeMode) {
164 switch (decodeMode) {
166 return "kGetAllPixels";
168 return "kIncremental";
170 return "kZeroInit";
171 }
173 }
174
175 static constexpr const char* DstColorTypeToString(DstColorType dstColorType) {
176 switch (dstColorType) {
178 return "kForceGrayscale";
180 return "kForceNonNativePremulColor";
182 return "kGetFromCanvas";
183 }
185 }
186
187 // Based on DM's CodecSrc::CodecSrc().
188 // https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.cpp#371
189 PNGCodecGM(std::string path,
190 DecodeMode decodeMode,
191 DstColorType dstColorType,
192 SkAlphaType dstAlphaType)
193 : skiagm::GM()
194 , fPath(path)
195 , fDecodeMode(decodeMode)
196 , fDstColorType(dstColorType)
197 , fDstAlphaType(dstAlphaType) {}
198
199 bool isBazelOnly() const override {
200 // This GM class overlaps with DM's CodecSrc and related sources.
201 return true;
202 }
203
204 std::map<std::string, std::string> getGoldKeys() const override {
205 return std::map<std::string, std::string>{
206 {"name", getName().c_str()},
207 {"source_type", "image"},
208 {"decode_mode", DecodeModeToString(fDecodeMode)},
209 {"dst_color_type", DstColorTypeToString(fDstColorType)},
210 {"dst_alpha_type", sk_alpha_type_to_str(fDstAlphaType)},
211 };
212 }
213
214protected:
215 // Based on CodecSrc::name().
216 // https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.cpp#828
217 SkString getName() const override {
218 SkString name = SkOSPath::Basename(fPath.c_str());
219 return name;
220 }
221
222 // Based on CodecSrc::size().
223 // https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.cpp#803
224 SkISize getISize() override {
225 DecodeResult decodeResult = decode(fPath);
226 if (decodeResult.errorMsg != "") {
227 return {0, 0};
228 }
229 return decodeResult.codec->dimensions();
230 }
231
232 // Based on CodecSrc::draw().
233 // https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.cpp#450
234 DrawResult onDraw(SkCanvas* canvas, SkString* errorMsg) override {
235 DecodeResult decodeResult = decode(fPath);
236 if (decodeResult.errorMsg != "") {
237 *errorMsg = decodeResult.errorMsg.c_str();
238 return DrawResult::kFail;
239 }
240 std::unique_ptr<SkCodec> codec = std::move(decodeResult.codec);
241
242 SkImageInfo decodeInfo = codec->getInfo();
243 if (*errorMsg = validateCanvasColorTypeAndGetDecodeInfo(&decodeInfo,
244 canvas->imageInfo().colorType());
245 *errorMsg != SkString()) {
246 return DrawResult::kFail;
247 }
248
249 SkISize size = codec->dimensions();
250 decodeInfo = decodeInfo.makeDimensions(size);
251
252 const int bpp = decodeInfo.bytesPerPixel();
253 const size_t rowBytes = size.width() * bpp;
254 const size_t safeSize = decodeInfo.computeByteSize(rowBytes);
255 SkAutoMalloc pixels(safeSize);
256
258 if (DecodeMode::kZeroInit == fDecodeMode) {
259 memset(pixels.get(), 0, size.height() * rowBytes);
260 options.fZeroInitialized = SkCodec::kYes_ZeroInitialized;
261 }
262
263 // For codec srcs, we want the "draw" step to be a memcpy. Any interesting color space or
264 // color format conversions should be performed by the codec. Sometimes the output of the
265 // decode will be in an interesting color space. On our srgb and f16 backends, we need to
266 // "pretend" that the color space is standard sRGB to avoid triggering color conversion
267 // at draw time.
268 SkImageInfo bitmapInfo = decodeInfo.makeColorSpace(SkColorSpace::MakeSRGB());
269
270 if (kRGBA_8888_SkColorType == decodeInfo.colorType() ||
271 kBGRA_8888_SkColorType == decodeInfo.colorType()) {
272 bitmapInfo = bitmapInfo.makeColorType(kN32_SkColorType);
273 }
274
275 switch (fDecodeMode) {
278 switch (codec->getPixels(decodeInfo, pixels.get(), rowBytes, &options)) {
280 // We consider these to be valid, since we should still decode what is
281 // available.
284 break;
285 default:
286 // Everything else is considered a failure.
287 *errorMsg = SkStringPrintf("Couldn't getPixels %s.", fPath.c_str());
288 return DrawResult::kFail;
289 }
290
291 drawToCanvas(canvas, bitmapInfo, pixels.get(), rowBytes);
292 break;
293 }
295 void* dst = pixels.get();
296 uint32_t height = decodeInfo.height();
297 if (SkCodec::kSuccess ==
298 codec->startIncrementalDecode(decodeInfo, dst, rowBytes, &options)) {
299 int rowsDecoded;
300 auto result = codec->incrementalDecode(&rowsDecoded);
302 codec->fillIncompleteImage(decodeInfo,
303 dst,
304 rowBytes,
306 height,
307 rowsDecoded);
308 }
309 } else {
310 *errorMsg = "Could not start incremental decode";
311 return DrawResult::kFail;
312 }
313 drawToCanvas(canvas, bitmapInfo, dst, rowBytes);
314 break;
315 }
316 default:
317 SkASSERT(false);
318 *errorMsg = "Invalid fDecodeMode";
319 return DrawResult::kFail;
320 }
321 return DrawResult::kOk;
322 }
323
324private:
325 // Checks that the canvas color type, destination color and alpha types and input image
326 // constitute an interesting test case, and constructs the SkImageInfo to use when decoding the
327 // image.
328 //
329 // Based on DM's get_decode_info() function.
330 // https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.cpp#398
331 SkString validateCanvasColorTypeAndGetDecodeInfo(SkImageInfo* decodeInfo,
332 SkColorType canvasColorType) {
333 switch (fDstColorType) {
335 if (kRGB_565_SkColorType == canvasColorType) {
336 return SkStringPrintf(
337 "canvas color type %s and destination color type %s are redundant",
338 sk_color_type_to_str(canvasColorType),
339 DstColorTypeToString(fDstColorType));
340 }
341 *decodeInfo = decodeInfo->makeColorType(kGray_8_SkColorType);
342 break;
343
345 if (kRGB_565_SkColorType == canvasColorType ||
346 kRGBA_F16_SkColorType == canvasColorType) {
347 return SkStringPrintf(
348 "canvas color type %s and destination color type %s are redundant",
349 sk_color_type_to_str(canvasColorType),
350 DstColorTypeToString(fDstColorType));
351 }
352#ifdef SK_PMCOLOR_IS_RGBA
353 *decodeInfo = decodeInfo->makeColorType(kBGRA_8888_SkColorType);
354#else
355 *decodeInfo = decodeInfo->makeColorType(kRGBA_8888_SkColorType);
356#endif
357 break;
358
360 if (kRGB_565_SkColorType == canvasColorType &&
361 kOpaque_SkAlphaType != decodeInfo->alphaType()) {
362 return SkStringPrintf(
363 "image \"%s\" has alpha type %s; this is incompatible with with "
364 "canvas color type %s and destination color type %s",
365 fPath.c_str(),
366 sk_alpha_type_to_str(decodeInfo->alphaType()),
367 sk_color_type_to_str(canvasColorType),
368 DstColorTypeToString(fDstColorType));
369 }
370 *decodeInfo = decodeInfo->makeColorType(canvasColorType);
371 break;
372
373 default:
375 }
376
377 *decodeInfo = decodeInfo->makeAlphaType(fDstAlphaType);
378 return SkString();
379 }
380
381 // Based on DM's draw_to_canvas() function.
382 // https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.cpp#432
383 void drawToCanvas(SkCanvas* canvas,
384 const SkImageInfo& info,
385 void* pixels,
386 size_t rowBytes,
387 SkScalar left = 0,
388 SkScalar top = 0) {
390 bitmap.installPixels(info, pixels, rowBytes);
391 swapRbIfNecessary(bitmap);
392 canvas->drawImage(bitmap.asImage(), left, top);
393 }
394
395 // Allows us to test decodes to non-native 8888.
396 //
397 // Based on DM's swap_rb_if_necessary function.
398 // https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DMSrcSink.cpp#387
399 void swapRbIfNecessary(SkBitmap& bitmap) {
400 if (DstColorType::kForceNonNativePremulColor != fDstColorType) {
401 return;
402 }
403
404 for (int y = 0; y < bitmap.height(); y++) {
405 uint32_t* row = (uint32_t*)bitmap.getAddr(0, y);
406 SkOpts::RGBA_to_BGRA(row, row, bitmap.width());
407 }
408 }
409
410 std::string fPath;
411 DecodeMode fDecodeMode;
412 DstColorType fDstColorType;
413 SkAlphaType fDstAlphaType;
414};
415
416// Registers GMs with zero or more PNGCodecGM instances for the given image. Returns a non-empty,
417// human-friendly error message in the case of errors.
418//
419// Based on DM's push_codec_srcs() function. It only covers "simple" codecs (lines 740-834).
420// https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DM.cpp#740
421//
422// Specifically, this function does not capture any behaviors found in the following DM classes:
423//
424// - AndroidCodecSrc
425// - BRDSrc
426// - ImageGenSrc
427//
428// TODO(lovisolo): Implement the above sources as GMs (if necessary).
429static std::string registerGMsForImage(std::string path,
430 PNGCodecGM::DecodeMode decodeMode,
431 PNGCodecGM::DstColorType dstColorType,
432 SkAlphaType dstAlphaType) {
433 DecodeResult decodeResult = decode(path);
434 if (decodeResult.errorMsg != "") {
435 return decodeResult.errorMsg;
436 }
437
438 if (dstColorType == PNGCodecGM::DstColorType::kForceGrayscale &&
439 decodeResult.codec->getInfo().colorType() != kGray_8_SkColorType) {
440 return SkStringPrintf(
441 "image \"%s\" has color type %s; this is incompatible with the given "
442 "dstColorType argument: %s (expected image color type: %s)",
443 path.c_str(),
444 sk_color_type_to_str(decodeResult.codec->getInfo().colorType()),
447 .c_str();
448 }
449
450 if (dstAlphaType == kUnpremul_SkAlphaType &&
451 decodeResult.codec->getInfo().alphaType() == kOpaque_SkAlphaType) {
452 return SkStringPrintf(
453 "image \"%s\" has alpha type %s; this is incompatible with the given "
454 "dstAlphaType argument: %s",
455 path.c_str(),
458 .c_str();
459 }
460
461 skiagm::Register(new PNGCodecGM(path, decodeMode, dstColorType, dstAlphaType));
462 return "";
463}
464
465// Returns a non-empty message in the case of errors.
467 PNGCodecGM::DstColorType* dstColorType,
468 SkAlphaType* dstAlphaType) {
473 };
474 if (SkString errorMsg = FLAGS_pngCodecDecodeMode.parseAndValidate(
475 "--pngCodecDecodeMode", decodeModeValues, decodeMode);
476 errorMsg != SkString()) {
477 return errorMsg.c_str();
478 }
479
483 {SkString("force-nonnative-premul-color"),
485 };
486 if (SkString errorMsg = FLAGS_pngCodecDstColorType.parseAndValidate(
487 "--pngCodecDstColorType", dstColorTypeValues, dstColorType);
488 errorMsg != SkString()) {
489 return errorMsg.c_str();
490 }
491
493 {SkString("premul"), kPremul_SkAlphaType},
494 {SkString("unpremul"), kUnpremul_SkAlphaType},
495 };
496 if (SkString errorMsg = FLAGS_pngCodecDstAlphaType.parseAndValidate(
497 "--pngCodecDstAlphaType", dstAlphaTypeValues, dstAlphaType);
498 errorMsg != SkString()) {
499 return errorMsg.c_str();
500 }
501
502 return "";
503}
504
505// Registers one PNGCodecGM instance for each image passed via the --pngCodecGMImages flag, which
506// can take files and directories. Directories are scanned non-recursively.
507//
508// Based on DM's gather_srcs() function.
509// https://skia.googlesource.com/skia/+/ce49fc71bc7cc25244020cd3e64764a6d08e54fb/dm/DM.cpp#953
510DEF_GM_REGISTERER_FN([]() -> std::string {
511 // Parse flags.
512 PNGCodecGM::DecodeMode decodeMode;
513 PNGCodecGM::DstColorType dstColorType;
514 SkAlphaType dstAlphaType;
515 if (std::string errorMsg = parse_and_validate_flags(&decodeMode, &dstColorType, &dstAlphaType);
516 errorMsg != "") {
517 return errorMsg;
518 }
519
520 // Collect images.
522 if (!CommonFlags::CollectImages(FLAGS_pngCodecGMImages, &images)) {
523 return "Failed to collect images.";
524 }
525
526 // Register one GM per image.
527 for (const SkString& image : images) {
528 if (std::string errorMsg =
529 registerGMsForImage(image.c_str(), decodeMode, dstColorType, dstAlphaType);
530 errorMsg != "") {
531 return errorMsg;
532 }
533 }
534
535 return "";
536});
#define DEFINE_string(name, defaultValue, helpString)
const char * options
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
kUnpremul_SkAlphaType
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 SkUNREACHABLE
Definition SkAssert.h:135
#define SkASSERT(cond)
Definition SkAssert.h:116
SkColorType
Definition SkColorType.h:19
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
Definition SkColorType.h:50
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
Definition SkColorType.h:33
@ kR8_unorm_SkColorType
Definition SkColorType.h:54
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
Definition SkColorType.h:30
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition SkColorType.h:23
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
Definition SkColorType.h:43
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
Definition SkColorType.h:48
@ 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
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
Definition SkColorType.h:29
@ kSRGBA_8888_SkColorType
Definition SkColorType.h:53
@ 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
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
Definition SkColorType.h:32
@ 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
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:28
@ kA16_float_SkColorType
pixel with a half float for alpha
Definition SkColorType.h:45
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
Definition SkColorType.h:40
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:27
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Definition SkColorType.h:31
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
Definition SkColorType.h:49
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
Definition SkColorType.h:36
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20
@ kR16G16_float_SkColorType
pixel with a half float for red and green
Definition SkColorType.h:46
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static bool left(const SkPoint &p0, const SkPoint &p1)
SK_API SkString static SkString SkStringPrintf()
Definition SkString.h:287
SkISize getISize() override
static constexpr const char * DstColorTypeToString(DstColorType dstColorType)
bool isBazelOnly() const override
SkString getName() const override
static constexpr const char * DecodeModeToString(DecodeMode decodeMode)
std::map< std::string, std::string > getGoldKeys() const override
PNGCodecGM(std::string path, DecodeMode decodeMode, DstColorType dstColorType, SkAlphaType dstAlphaType)
DrawResult onDraw(SkCanvas *canvas, SkString *errorMsg) override
void * get()
SkImageInfo imageInfo() const
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
@ kYes_ZeroInitialized
Definition SkCodec.h:308
@ kNo_ZeroInitialized
Definition SkCodec.h:315
static const char * ResultToString(Result)
Definition SkCodec.cpp:880
@ kIncompleteInput
Definition SkCodec.h:84
@ kSuccess
Definition SkCodec.h:80
@ kErrorInInput
Definition SkCodec.h:91
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkData > MakeFromFileName(const char path[])
Definition SkData.cpp:148
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
Definition SkStream.cpp:314
static SkString Basename(const char *fullPath)
Definition SkOSPath.cpp:23
const char * c_str() const
Definition SkString.h:133
GM(SkColor backgroundColor=SK_ColorWHITE)
Definition gm.cpp:81
SkScalar height()
Definition gm.h:162
sk_sp< SkImage > image
Definition examples.cpp:29
float SkScalar
Definition extension.cpp:12
GAsyncResult * result
const char * name
Definition fuchsia.cc:50
#define DEF_GM_REGISTERER_FN(FN)
Definition gm.h:73
std::array< MockImage, 3 > images
double y
bool CollectImages(const CommandLineFlags::StringArray &dir, skia_private::TArray< SkString > *output)
Swizzle_8888_u32 RGBA_to_BGRA
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
void Register(skiagm::GM *gm)
Definition gm.cpp:256
DrawResult
Definition gm.h:104
static std::string parse_and_validate_flags(PNGCodecGM::DecodeMode *decodeMode, PNGCodecGM::DstColorType *dstColorType, SkAlphaType *dstAlphaType)
static DecodeResult decode(std::string path)
static std::string registerGMsForImage(std::string path, PNGCodecGM::DecodeMode decodeMode, PNGCodecGM::DstColorType dstColorType, SkAlphaType dstAlphaType)
static constexpr const char * sk_alpha_type_to_str(SkAlphaType alphaType)
static constexpr const char * sk_color_type_to_str(SkColorType colorType)
Definition png_codec.cpp:47
std::unique_ptr< SkCodec > codec
std::string errorMsg
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
size_t computeByteSize(size_t rowBytes) const
SkImageInfo makeDimensions(SkISize newSize) const
int bytesPerPixel() const
SkImageInfo makeColorSpace(sk_sp< SkColorSpace > cs) const
SkAlphaType alphaType() const
SkColorType colorType() const
int height() const
SkImageInfo makeColorType(SkColorType newColorType) const