diff --git a/engine/src/flutter/display_list/testing/dl_test_surface_provider.cc b/engine/src/flutter/display_list/testing/dl_test_surface_provider.cc index 99ac2f77209..9615183d880 100644 --- a/engine/src/flutter/display_list/testing/dl_test_surface_provider.cc +++ b/engine/src/flutter/display_list/testing/dl_test_surface_provider.cc @@ -6,7 +6,9 @@ #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkData.h" +#include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/skia/include/encode/SkPngEncoder.h" #ifdef ENABLE_SOFTWARE_BENCHMARKS #include "flutter/display_list/testing/dl_test_surface_software.h" @@ -55,7 +57,7 @@ bool DlSurfaceProvider::Snapshot(std::string& filename) const { if (!raster) { return false; } - auto data = raster->encodeToData(); + auto data = SkPngEncoder::Encode(nullptr, raster.get(), {}); if (!data) { return false; } diff --git a/engine/src/flutter/flow/layers/offscreen_surface.cc b/engine/src/flutter/flow/layers/offscreen_surface.cc index 4f20fb0ac4e..8467f4bb00e 100644 --- a/engine/src/flutter/flow/layers/offscreen_surface.cc +++ b/engine/src/flutter/flow/layers/offscreen_surface.cc @@ -5,11 +5,13 @@ #include "flutter/flow/layers/offscreen_surface.h" #include "third_party/skia/include/core/SkColorSpace.h" +#include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkPictureRecorder.h" #include "third_party/skia/include/core/SkPixmap.h" #include "third_party/skia/include/core/SkSerialProcs.h" #include "third_party/skia/include/core/SkSurfaceCharacterization.h" +#include "third_party/skia/include/encode/SkPngEncoder.h" #include "third_party/skia/include/utils/SkBase64.h" namespace flutter { @@ -54,7 +56,7 @@ static sk_sp GetRasterData(const sk_sp& offscreen_surface, // If the caller want the pixels to be compressed, there is a Skia utility to // compress to PNG. Use that. if (compressed) { - return cpu_snapshot->encodeToData(); + return SkPngEncoder::Encode(nullptr, cpu_snapshot.get(), {}); } // Copy it into a bitmap and return the same. diff --git a/engine/src/flutter/flow/layers/performance_overlay_layer_unittests.cc b/engine/src/flutter/flow/layers/performance_overlay_layer_unittests.cc index 3c601b472a5..86049c4f0cd 100644 --- a/engine/src/flutter/flow/layers/performance_overlay_layer_unittests.cc +++ b/engine/src/flutter/flow/layers/performance_overlay_layer_unittests.cc @@ -12,10 +12,12 @@ #include "flutter/flow/testing/layer_test.h" #include "flutter/testing/mock_canvas.h" #include "third_party/skia/include/core/SkData.h" +#include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkSerialProcs.h" #include "third_party/skia/include/core/SkStream.h" #include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkTextBlob.h" +#include "third_party/skia/include/encode/SkPngEncoder.h" #include "third_party/skia/include/utils/SkBase64.h" namespace flutter { @@ -89,7 +91,8 @@ static void TestPerformanceOverlayLayerGold(int refresh_rate) { layer.Paint(paint_context); sk_sp snapshot = surface->makeImageSnapshot(); - sk_sp snapshot_data = snapshot->encodeToData(); + sk_sp snapshot_data = + SkPngEncoder::Encode(nullptr, snapshot.get(), {}); sk_sp golden_data = SkData::MakeFromFileName(golden_file_path.c_str()); diff --git a/engine/src/flutter/lib/ui/painting/image_decoder_unittests.cc b/engine/src/flutter/lib/ui/painting/image_decoder_unittests.cc index 0cc5165d537..439e17d2003 100644 --- a/engine/src/flutter/lib/ui/painting/image_decoder_unittests.cc +++ b/engine/src/flutter/lib/ui/painting/image_decoder_unittests.cc @@ -24,10 +24,10 @@ #include "flutter/testing/testing.h" #include "third_party/skia/include/codec/SkCodecAnimation.h" #include "third_party/skia/include/core/SkData.h" -#include "third_party/skia/include/core/SkEncodedImageFormat.h" #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkSize.h" +#include "third_party/skia/include/encode/SkPngEncoder.h" // CREATE_NATIVE_ENTRY is leaky by design // NOLINTBEGIN(clang-analyzer-core.StackAddressEscape) @@ -892,7 +892,7 @@ TEST(ImageDecoderTest, VerifySubpixelDecodingPreservesExifOrientation) { auto assert_image = [&](auto decoded_image) { ASSERT_EQ(decoded_image->dimensions(), SkISize::Make(300, 100)); - ASSERT_TRUE(decoded_image->encodeToData(SkEncodedImageFormat::kPNG, 100) + ASSERT_TRUE(SkPngEncoder::Encode(nullptr, decoded_image.get(), {}) ->equals(expected_data.get())); }; diff --git a/engine/src/flutter/lib/ui/painting/image_encoding.cc b/engine/src/flutter/lib/ui/painting/image_encoding.cc index ff243184fbd..75fc9fab3c8 100644 --- a/engine/src/flutter/lib/ui/painting/image_encoding.cc +++ b/engine/src/flutter/lib/ui/painting/image_encoding.cc @@ -17,8 +17,9 @@ #include "flutter/lib/ui/painting/image_encoding_impeller.h" #endif // IMPELLER_SUPPORTS_RENDERING #include "flutter/lib/ui/painting/image_encoding_skia.h" -#include "third_party/skia/include/core/SkEncodedImageFormat.h" +#include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/skia/include/encode/SkPngEncoder.h" #include "third_party/tonic/dart_persistent_value.h" #include "third_party/tonic/logging/dart_invoke.h" #include "third_party/tonic/typed_data/typed_list.h" @@ -116,8 +117,7 @@ sk_sp EncodeImage(const sk_sp& raster_image, switch (format) { case kPNG: { - auto png_image = - raster_image->encodeToData(SkEncodedImageFormat::kPNG, 0); + auto png_image = SkPngEncoder::Encode(nullptr, raster_image.get(), {}); if (png_image == nullptr) { FML_LOG(ERROR) << "Could not convert raster image to PNG."; diff --git a/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests_util.cc b/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests_util.cc index 44dbec80bd0..08dba18cb1d 100644 --- a/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests_util.cc +++ b/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests_util.cc @@ -12,6 +12,7 @@ #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/skia/include/encode/SkPngEncoder.h" namespace flutter { namespace testing { @@ -136,7 +137,7 @@ bool WriteImageToDisk(const fml::UniqueFD& directory, return false; } - auto data = image->encodeToData(); + auto data = SkPngEncoder::Encode(nullptr, image.get(), {}); if (!data) { return false;