forked from firka/flutter
Update Skia revision to pull in GL native interface construction fixes on iOS. (flutter/engine#3265)
* Update Skia revision to pull in GL native interface construction fixes on iOS. Fixed in https://skia-review.googlesource.com/c/5212/ * Use the new image encoder API from Skia.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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<SkData> EncodeBitmapAsPNG(const SkBitmap& bitmap) {
|
||||
if (bitmap.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkPixmap pixmap;
|
||||
if (!bitmap.peekPixels(&pixmap)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PngPixelSerializer serializer;
|
||||
sk_sp<SkData> 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<SkData> png(
|
||||
SkImageEncoder::EncodeData(bitmap, SkImageEncoder::Type::kPNG_Type,
|
||||
SkImageEncoder::kDefaultQuality));
|
||||
sk_sp<SkData> png(EncodeBitmapAsPNG(bitmap));
|
||||
|
||||
if (!png)
|
||||
return ErrorServer(json_object, "can not encode screenshot");
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user