Skip to content

Commit a4959f7

Browse files
authored
[skia] Update SkSerialProcs to use new type (flutter#179347)
This lets us eventually use the const SkData version added in https://skia-review.googlesource.com/c/skia/+/1109339 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 45896dd commit a4959f7

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

engine/src/flutter/shell/common/rasterizer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ static sk_sp<SkData> ScreenshotLayerTreeAsPicture(
856856
#else
857857
SkSerialProcs procs = {0};
858858
procs.fTypefaceProc = SerializeTypefaceWithData;
859-
procs.fImageProc = [](SkImage* img, void*) -> sk_sp<SkData> {
859+
procs.fImageProc = [](SkImage* img, void*) -> SkSerialReturnType {
860860
return SkPngEncoder::Encode(nullptr, img, SkPngEncoder::Options{});
861861
};
862862
#endif

engine/src/flutter/shell/common/serialization_callbacks.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#include "flutter/shell/common/serialization_callbacks.h"
56
#include "flutter/fml/logging.h"
67
#include "third_party/skia/include/core/SkColorSpace.h"
78
#include "third_party/skia/include/core/SkImage.h"
@@ -11,11 +12,12 @@
1112

1213
namespace flutter {
1314

14-
sk_sp<SkData> SerializeTypefaceWithoutData(SkTypeface* typeface, void* ctx) {
15+
SkSerialReturnType SerializeTypefaceWithoutData(SkTypeface* typeface,
16+
void* ctx) {
1517
return SkData::MakeEmpty();
1618
}
1719

18-
sk_sp<SkData> SerializeTypefaceWithData(SkTypeface* typeface, void* ctx) {
20+
SkSerialReturnType SerializeTypefaceWithData(SkTypeface* typeface, void* ctx) {
1921
return typeface->serialize(SkTypeface::SerializeBehavior::kDoIncludeData);
2022
}
2123

@@ -33,7 +35,7 @@ struct ImageMetaData {
3335
bool has_color_space;
3436
} __attribute__((packed));
3537

36-
sk_sp<SkData> SerializeImageWithoutData(SkImage* image, void* ctx) {
38+
SkSerialReturnType SerializeImageWithoutData(SkImage* image, void* ctx) {
3739
const auto& info = image->imageInfo();
3840
SkDynamicMemoryWStream stream;
3941

engine/src/flutter/shell/common/serialization_callbacks.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77

88
#include "flutter/fml/logging.h"
99
#include "third_party/skia/include/core/SkImage.h"
10+
#include "third_party/skia/include/core/SkSerialProcs.h"
1011
#include "third_party/skia/include/core/SkTypeface.h"
1112

1213
namespace flutter {
1314

14-
sk_sp<SkData> SerializeTypefaceWithoutData(SkTypeface* typeface, void* ctx);
15-
sk_sp<SkData> SerializeTypefaceWithData(SkTypeface* typeface, void* ctx);
15+
SkSerialReturnType SerializeTypefaceWithoutData(SkTypeface* typeface,
16+
void* ctx);
17+
SkSerialReturnType SerializeTypefaceWithData(SkTypeface* typeface, void* ctx);
1618
sk_sp<SkTypeface> DeserializeTypefaceWithoutData(const void* data,
1719
size_t length,
1820
void* ctx);
1921

2022
// Serializes only the metadata of the image and not the underlying pixel data.
21-
sk_sp<SkData> SerializeImageWithoutData(SkImage* image, void* ctx);
23+
SkSerialReturnType SerializeImageWithoutData(SkImage* image, void* ctx);
2224
sk_sp<SkImage> DeserializeImageWithoutData(const void* data,
2325
size_t length,
2426
void* ctx);

0 commit comments

Comments
 (0)