Roll Skia and remove PngPixelSerializer (flutter/engine#4472)
* Roll Skia and remove PngPixelSerializer * Update licenses
This commit is contained in:
2
DEPS
2
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,16 +8,9 @@
|
||||
#include <string>
|
||||
|
||||
#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
|
||||
|
||||
@@ -235,19 +235,7 @@ 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.encodeToData(pixmap));
|
||||
|
||||
return data;
|
||||
return SkEncodeBitmap(bitmap, SkEncodedImageFormat::kPNG, 100);
|
||||
}
|
||||
|
||||
static fml::WeakPtr<Rasterizer> GetRandomRasterizer() {
|
||||
@@ -339,10 +327,7 @@ bool PlatformViewServiceProtocol::ScreenshotSkp(const char* method,
|
||||
|
||||
latch.Wait();
|
||||
|
||||
SkDynamicMemoryWStream stream;
|
||||
PngPixelSerializer serializer;
|
||||
picture->serialize(&stream, &serializer);
|
||||
sk_sp<SkData> skp_data(stream.detachAsData());
|
||||
sk_sp<SkData> skp_data = picture->serialize();
|
||||
|
||||
size_t b64_size =
|
||||
SkBase64::Encode(skp_data->data(), skp_data->size(), nullptr);
|
||||
|
||||
Reference in New Issue
Block a user