From 2ab8ce7c6487e372a86ea2c71258db5835a7488e Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Mon, 17 Apr 2023 11:44:49 +0000 Subject: [PATCH] Replace encodeToData with SkPngEncoder This was deprecated in https://skia-review.googlesource.com/c/skia/+/667296 Change-Id: Id05f4ce870165726e267ab642378178ece99ff01 --- libs/hwui/jni/android_graphics_HardwareRenderer.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp index de5c86a6e6bf4..5a537e7d99bb3 100644 --- a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp +++ b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ #include #include +#include #include #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 {