mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* 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.
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#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);
|
|
}
|
|
|
|
} // namespace shell
|