aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-07-11 10:27:40 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-11 14:49:31 +0000
commitb99beddc7a0f6003d6dd88119e7f2734fc508322 (patch)
tree0b213528a3741e155c48c74a881af5c4c52b4a10 /include/core
parent327290fcafab2e702c839da8f3b7b29428294ea2 (diff)
Add serialize + catalog api to SkTextBlob
Bug: skia:6836 Change-Id: I858cf936b015c14f12a41a4912e19bb15de8abaa Reviewed-on: https://skia-review.googlesource.com/21730 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkTextBlob.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/core/SkTextBlob.h b/include/core/SkTextBlob.h
index 956c6a092d..a4d2dba9a0 100644
--- a/include/core/SkTextBlob.h
+++ b/include/core/SkTextBlob.h
@@ -17,6 +17,9 @@
class SkReadBuffer;
class SkWriteBuffer;
+typedef std::function<void(SkTypeface*)> SkTypefaceCataloger;
+typedef std::function<sk_sp<SkTypeface>(uint32_t)> SkTypefaceResolver;
+
/** \class SkTextBlob
SkTextBlob combines multiple text runs into an immutable, ref-counted structure.
@@ -57,6 +60,20 @@ public:
kFull_Positioning = 2 // Point positioning -- two scalars per glyph.
};
+ /**
+ * Serialize the typeface into a data blob, storing type uniqueID of each referenced typeface.
+ * During this process, each time a typeface is encountered, it is passed to the catalog,
+ * allowing the caller to what typeface IDs will need to be resolved in Deserialize().
+ */
+ sk_sp<SkData> serialize(const SkTypefaceCataloger&) 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.
+ */
+ static sk_sp<SkTextBlob> Deserialize(const void* data, size_t size, const SkTypefaceResolver&);
+
private:
friend class SkNVRefCnt<SkTextBlob>;
class RunRecord;