52 if (!
bitmap.peekPixels(&pm)) {
53 return "peekPixels failed";
63 return "SkPngEncoder::Encode failed";
71 static const size_t kMaxBase64Length = 1024 * 1024;
72 if (
len > kMaxBase64Length) {
79 return "data:image/png;base64," +
out;
110 std::optional<SkAlphaType>,
115 auto [
image, getImageResult] = codec->getImage();
123 surface->getCanvas()->drawPicture(pic);
127 if (!
surface->readPixels(recordedBitmap, 0, 0)) {
139 if (!
surface->readPixels(referenceBitmap, 0, 0)) {
146 SkStringPrintf(
"Recorded and reference bitmap dimensions do not match: "
147 "expected byte size %lu, width %d and height %d; "
148 "got %lu, %d and %d",
157 if (0 != memcmp(recordedBitmap.
getPixels(),
161 SkStringPrintf(
"Recorded and reference bitmap pixels do not match.\n"
162 "Recorded image:\n%s\nReference image:\n%s",
183 if (via ==
"direct") {
185 }
else if (via ==
"picture") {
187 }
else if (via ==
"picture_serialization") {
190 SK_ABORT(
"unknown --via flag value: %s", via.c_str());
GMOutput draw(skiagm::GM *gm, SkSurface *surface, std::string via)
static std::string bitmap_to_base64_data_uri(const SkBitmap &bitmap)
static GMOutput draw_direct(skiagm::GM *gm, SkSurface *surface)
static GMOutput draw_via_picture(skiagm::GM *gm, SkSurface *surface, bool serialize)
#define SK_ABORT(message,...)
#define SkASSERT_RELEASE(cond)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
size_t computeByteSize() const
@ kZeroPixels_AllocFlag
zero pixel memory. No effect. This is the default.
void allocPixelsFlags(const SkImageInfo &info, uint32_t flags)
const void * data() const
sk_sp< SkData > detachAsData()
virtual bool isTextureBacked() const =0
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
sk_sp< SkData > serialize(const SkSerialProcs *procs=nullptr) const
static sk_sp< SkPicture > MakeFromData(const SkData *data, const SkDeserialProcs *procs=nullptr)
const char * c_str() const
virtual SkISize getISize()=0
DrawResult draw(SkCanvas *canvas)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
sk_sp< const SkImage > image
static size_t EncodedSize(size_t srcDataLength)
static size_t Encode(const void *src, size_t length, void *dst, const char *encode=nullptr)
SkDeserialImageFromDataProc fImageDataProc
constexpr int32_t height() const
constexpr int32_t width() const
constexpr int32_t width() const
constexpr int32_t height() const
SkSerialImageProc fImageProc
std::shared_ptr< const fml::Mapping > data