diff --git a/DEPS b/DEPS index 0905530891a..0a1614bd68b 100644 --- a/DEPS +++ b/DEPS @@ -23,7 +23,7 @@ vars = { 'skia_git': 'https://skia.googlesource.com', 'github_git': 'https://github.com', 'base_revision': 'b2412302ed4e45bfb47d7b5c0c3418077009e1ce', - 'skia_revision': '06a65e2799eaead18f778792801406aff4aec0d9', + 'skia_revision': '130a118cc68f8f9973e9572356011de378463fea', # Note: When updating the Dart revision, ensure that all entries that are # dependencies of dart are also updated diff --git a/shell/common/picture_serializer.cc b/shell/common/picture_serializer.cc index b925cf29481..0b68107cfc9 100644 --- a/shell/common/picture_serializer.cc +++ b/shell/common/picture_serializer.cc @@ -17,14 +17,12 @@ bool PngPixelSerializer::onUseEncodedData(const void*, size_t) { } SkData* PngPixelSerializer::onEncode(const SkPixmap& pixmap) { - SkBitmap bitmap; + SkDynamicMemoryWStream stream; - if (!bitmap.installPixels(pixmap)) { - return nullptr; - } + bool encode_result = SkEncodeImage( + &stream, pixmap, SkEncodedImageFormat::kPNG, 80 /* quality */); - return SkImageEncoder::EncodeData(bitmap, SkImageEncoder::Type::kPNG_Type, - SkImageEncoder::kDefaultQuality); + return encode_result ? stream.detachAsData().release() : nullptr; } void SerializePicture(const std::string& path, SkPicture* picture) { diff --git a/shell/common/platform_view_service_protocol.cc b/shell/common/platform_view_service_protocol.cc index 8effa833ac0..0e9f40da431 100644 --- a/shell/common/platform_view_service_protocol.cc +++ b/shell/common/platform_view_service_protocol.cc @@ -11,10 +11,10 @@ #include "base/base64.h" #include "flutter/common/threads.h" +#include "flutter/shell/common/picture_serializer.h" #include "flutter/shell/common/rasterizer.h" #include "flutter/shell/common/shell.h" #include "lib/ftl/memory/weak_ptr.h" -#include "third_party/skia/include/core/SkImageEncoder.h" #include "third_party/skia/include/core/SkSurface.h" namespace shell { @@ -235,6 +235,22 @@ bool PlatformViewServiceProtocol::ListViews(const char* method, 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.encode(pixmap)); + + return data; +} + bool PlatformViewServiceProtocol::Screenshot(const char* method, const char** param_keys, const char** param_values, @@ -250,12 +266,7 @@ bool PlatformViewServiceProtocol::Screenshot(const char* method, latch.Wait(); - if (bitmap.empty()) - return ErrorServer(json_object, "no screenshot available"); - - sk_sp png( - SkImageEncoder::EncodeData(bitmap, SkImageEncoder::Type::kPNG_Type, - SkImageEncoder::kDefaultQuality)); + sk_sp png(EncodeBitmapAsPNG(bitmap)); if (!png) return ErrorServer(json_object, "can not encode screenshot"); diff --git a/shell/gpu/gpu_surface_gl.cc b/shell/gpu/gpu_surface_gl.cc index 6181bb89342..814b5296fb7 100644 --- a/shell/gpu/gpu_surface_gl.cc +++ b/shell/gpu/gpu_surface_gl.cc @@ -85,6 +85,7 @@ bool GPUSurfaceGL::Setup() { flow::GLConnection connection; FTL_LOG(INFO) << "Failed to setup GL context. Aborting."; FTL_LOG(INFO) << connection.Description(); + return false; } context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount,