aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkFlattenable.h
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-04-22 12:43:07 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-22 12:43:07 -0700
commita3b3b238f507a6ec7f43febc6bf0bb17e04e770f (patch)
tree4a699b7a262309f9695db86c2e565109309aeb27 /include/core/SkFlattenable.h
parent4ff7c7423661db10ebaabda782fc8329e7a5f7ee (diff)
Enable flattening/unflattening with custom unflatten procs
Now flattenables are serialized using a string name, so that flattenables do not necessarily need to be registered before serialization. They just need to override getTypeName(). Allows custom unflatten procs to be set on the SkReadBuffer. This is optional if the flattenable is registered, but otherwise must be called. This was split off from: https://codereview.chromium.org/1837913003/ BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1858323002 Review URL: https://codereview.chromium.org/1858323002
Diffstat (limited to 'include/core/SkFlattenable.h')
-rw-r--r--include/core/SkFlattenable.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index c76f119c13..0ba83da087 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -92,9 +92,15 @@ public:
*/
virtual Factory getFactory() const = 0;
- /** Returns the name of the object's class
- */
- const char* getTypeName() const { return FactoryToName(getFactory()); }
+ /**
+ * Returns the name of the object's class.
+ *
+ * Subclasses should override this function if they intend to provide
+ * support for flattening without using the global registry.
+ *
+ * If the flattenable is registered, there is no need to override.
+ */
+ virtual const char* getTypeName() const { return FactoryToName(getFactory()); }
static Factory NameToFactory(const char name[]);
static const char* FactoryToName(Factory);