From 3df81cb50d35e5104b1112ade6ff30ca5bd48633 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Wed, 6 Sep 2023 19:52:39 +0000 Subject: [PATCH] Explicitly encode SkImages in SkPictures as PNG --- shell/common/rasterizer.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index 03e7c4e7a59d8..5c009c56dc124 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -26,6 +26,7 @@ #include "third_party/skia/include/core/SkSerialProcs.h" #include "third_party/skia/include/core/SkSize.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/skia/include/encode/SkPngEncoder.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h" @@ -696,6 +697,9 @@ static sk_sp ScreenshotLayerTreeAsPicture( #else SkSerialProcs procs = {0}; procs.fTypefaceProc = SerializeTypefaceWithData; + procs.fImageProc = [](SkImage* img, void*) -> sk_sp { + return SkPngEncoder::Encode(nullptr, img, SkPngEncoder::Options{}); + }; #endif return recorder.finishRecordingAsPicture()->serialize(&procs);