Replace encodeToData with SkPngEncoder

This was deprecated in https://skia-review.googlesource.com/c/skia/+/667296

Change-Id: Id05f4ce870165726e267ab642378178ece99ff01
This commit is contained in:
Kevin Lubick
2023-04-17 11:44:49 +00:00
parent a6a3a65379
commit 2ab8ce7c64

View File

@@ -35,6 +35,7 @@
#include <SkTypeface.h>
#include <dlfcn.h>
#include <gui/TraceUtils.h>
#include <include/encode/SkPngEncoder.h>
#include <inttypes.h>
#include <media/NdkImage.h>
#include <media/NdkImageReader.h>
@@ -54,6 +55,7 @@
#include <algorithm>
#include <atomic>
#include <log/log.h>
#include <vector>
#include "JvmErrorReporter.h"
@@ -520,7 +522,16 @@ public:
if (iter != context->mTextureMap.end()) {
img = iter->second.get();
}
return img->encodeToData();
if (!img) {
return nullptr;
}
// The following encode (specifically the pixel readback) will fail on a
// texture-backed image. They should already be raster images, but on
// the off-chance they aren't, we will just serialize it as nothing.
if (img->isTextureBacked()) {
return SkData::MakeEmpty();
}
return SkPngEncoder::Encode(nullptr, img, {});
}
void serialize(SkWStream* stream) const override {