From 0c2cf26813e077a2a55dff79f2940bd3809929b1 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Mon, 18 Dec 2017 15:44:54 -0500 Subject: [PATCH] Roll Skia and remove PngPixelSerializer (flutter/engine#4472) * Roll Skia and remove PngPixelSerializer * Update licenses --- DEPS | 2 +- .../shell/common/picture_serializer.cc | 20 +------------------ .../flutter/shell/common/picture_serializer.h | 7 ------- .../common/platform_view_service_protocol.cc | 19 ++---------------- 4 files changed, 4 insertions(+), 44 deletions(-) diff --git a/DEPS b/DEPS index 5ce5c7e7e4..9ae4e34236 100644 --- a/DEPS +++ b/DEPS @@ -23,7 +23,7 @@ vars = { 'fuchsia_git': 'https://fuchsia.googlesource.com', 'github_git': 'https://github.com', 'skia_git': 'https://skia.googlesource.com', - 'skia_revision': '58a3fcd4b3a2f7210586f4ec74dde8ac2b231e0f', + 'skia_revision': 'ef0384835757df463f5157145650a60ba8b14a63', # When updating the Dart revision, ensure that all entries that are # dependencies of Dart are also updated to match the entries in the diff --git a/engine/src/flutter/shell/common/picture_serializer.cc b/engine/src/flutter/shell/common/picture_serializer.cc index 0b68107cfc..b62e96d74f 100644 --- a/engine/src/flutter/shell/common/picture_serializer.cc +++ b/engine/src/flutter/shell/common/picture_serializer.cc @@ -4,31 +4,13 @@ #include "flutter/shell/common/picture_serializer.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "third_party/skia/include/core/SkData.h" -#include "third_party/skia/include/core/SkImageEncoder.h" -#include "third_party/skia/include/core/SkPixelSerializer.h" #include "third_party/skia/include/core/SkStream.h" namespace shell { -bool PngPixelSerializer::onUseEncodedData(const void*, size_t) { - return true; -} - -SkData* PngPixelSerializer::onEncode(const SkPixmap& pixmap) { - SkDynamicMemoryWStream stream; - - bool encode_result = SkEncodeImage( - &stream, pixmap, SkEncodedImageFormat::kPNG, 80 /* quality */); - - return encode_result ? stream.detachAsData().release() : nullptr; -} - void SerializePicture(const std::string& path, SkPicture* picture) { SkFILEWStream stream(path.c_str()); - PngPixelSerializer serializer; - picture->serialize(&stream, &serializer); + picture->serialize(&stream); } } // namespace shell diff --git a/engine/src/flutter/shell/common/picture_serializer.h b/engine/src/flutter/shell/common/picture_serializer.h index 9c7d5dd148..0416b2f0c6 100644 --- a/engine/src/flutter/shell/common/picture_serializer.h +++ b/engine/src/flutter/shell/common/picture_serializer.h @@ -8,16 +8,9 @@ #include #include "third_party/skia/include/core/SkPicture.h" -#include "third_party/skia/include/core/SkPixelSerializer.h" namespace shell { -class PngPixelSerializer : public SkPixelSerializer { - public: - bool onUseEncodedData(const void*, size_t) override; - SkData* onEncode(const SkPixmap& pixmap) override; -}; - void SerializePicture(const std::string& path, SkPicture* picture); } // namespace shell diff --git a/engine/src/flutter/shell/common/platform_view_service_protocol.cc b/engine/src/flutter/shell/common/platform_view_service_protocol.cc index 9f04656573..f29e190ecb 100644 --- a/engine/src/flutter/shell/common/platform_view_service_protocol.cc +++ b/engine/src/flutter/shell/common/platform_view_service_protocol.cc @@ -235,19 +235,7 @@ const char* PlatformViewServiceProtocol::kScreenshotExtensionName = "_flutter.screenshot"; static sk_sp EncodeBitmapAsPNG(const SkBitmap& bitmap) { - if (bitmap.empty()) { - return nullptr; - } - - SkPixmap pixmap; - if (!bitmap.peekPixels(&pixmap)) { - return nullptr; - } - - PngPixelSerializer serializer; - sk_sp data(serializer.encodeToData(pixmap)); - - return data; + return SkEncodeBitmap(bitmap, SkEncodedImageFormat::kPNG, 100); } static fml::WeakPtr GetRandomRasterizer() { @@ -339,10 +327,7 @@ bool PlatformViewServiceProtocol::ScreenshotSkp(const char* method, latch.Wait(); - SkDynamicMemoryWStream stream; - PngPixelSerializer serializer; - picture->serialize(&stream, &serializer); - sk_sp skp_data(stream.detachAsData()); + sk_sp skp_data = picture->serialize(); size_t b64_size = SkBase64::Encode(skp_data->data(), skp_data->size(), nullptr);