aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar Khushal <khushalsagar@chromium.org>2018-04-03 17:51:40 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-04 01:25:11 +0000
commit42f8bc40fd3702c801c9f5b9d438fabcc77fb58b (patch)
tree99f0fcd1ae3747d6553b9a77282442aa2693d78b /include/core
parent46117c83d22886286196f7965f5fdffeb7e43457 (diff)
Add API for SkTextBlob serialization into caller's memory.
R=reed@google.com Change-Id: Iaeb67504aabf0dc036e81fa23c1a3c949b72b2b9 Reviewed-on: https://skia-review.googlesource.com/114262 Commit-Queue: Khusal Sagar <khushalsagar@chromium.org> Reviewed-by: Mike Klein <mtklein@google.com> Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkFlattenable.h2
-rw-r--r--include/core/SkTextBlob.h6
2 files changed, 8 insertions, 0 deletions
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index 05b8fba9a7..ed343c82ae 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -135,6 +135,8 @@ public:
// public ways to serialize / deserialize
//
sk_sp<SkData> serialize(const SkSerialProcs* = nullptr) const;
+ size_t serialize(void* memory, size_t memory_size,
+ const SkSerialProcs* = nullptr) const;
static sk_sp<SkFlattenable> Deserialize(Type, const void* data, size_t length,
const SkDeserialProcs* procs = nullptr);
diff --git a/include/core/SkTextBlob.h b/include/core/SkTextBlob.h
index 89c6697cc9..59151d3002 100644
--- a/include/core/SkTextBlob.h
+++ b/include/core/SkTextBlob.h
@@ -67,6 +67,12 @@ public:
sk_sp<SkData> serialize(SkTypefaceCatalogerProc, void* ctx) const;
/**
+ * Similar to serialize above, but writes directly into |memory|. Returns bytes written or 0u
+ * if serialization failed due to insufficient size.
+ */
+ size_t serialize(const SkSerialProcs& procs, void* memory, size_t memory_size) const;
+
+ /**
* Re-create a text blob previously serialized. Since the serialized form records the uniqueIDs
* of its typefaces, deserialization requires that the caller provide the corresponding
* SkTypefaces for those IDs.