additional serialize(void*, size_t) to match SkTextBlob
Add serialize(void*, size_t) to mirror the SkTextBlob serialization methods. Bug: chromium:1278340 Change-Id: Ie3868d882263a0ec8833d4c9404e7410d30ac6ae Reviewed-on: https://skia-review.googlesource.com/c/skia/+/511798 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
c25fd021ed
commit
98209f67c0
@ -47,6 +47,7 @@ public:
|
||||
|
||||
// Serialize the slug.
|
||||
sk_sp<SkData> serialize() const;
|
||||
size_t serialize(void* buffer, size_t size) const;
|
||||
|
||||
// Set the client parameter to the appropriate SkStrikeClient when typeface ID translation
|
||||
// is needed.
|
||||
|
@ -25,6 +25,17 @@ sk_sp<SkData> GrSlug::serialize() const {
|
||||
return buffer.snapshotAsData();
|
||||
}
|
||||
|
||||
size_t GrSlug::serialize(void* buffer, size_t size) const {
|
||||
SkBinaryWriteBuffer writeBuffer{buffer, size};
|
||||
this->doFlatten(writeBuffer);
|
||||
|
||||
// If we overflow the given buffer, then SkWriteBuffer allocates a new larger buffer. Check
|
||||
// to see if an additional buffer was allocated, if it wasn't then everything fit, else
|
||||
// return 0 signaling the buffer overflowed.
|
||||
// N.B. This is the idiom from SkTextBlob.
|
||||
return writeBuffer.usingInitialStorage() ? writeBuffer.bytesWritten() : 0u;
|
||||
}
|
||||
|
||||
sk_sp<GrSlug> SkMakeSlugFromBuffer(SkReadBuffer& buffer, const SkStrikeClient* client);
|
||||
sk_sp<GrSlug> GrSlug::Deserialize(const void* data, size_t size, const SkStrikeClient* client) {
|
||||
SkReadBuffer buffer{data, size};
|
||||
|
Loading…
Reference in New Issue
Block a user