Particles: remove non-stable random, add better enum reflection
The other generator was never used (or useful). String-based serialization
of enums is quite helpful, though.
Bug: skia:
Change-Id: Ic9d58f8d20cfe7aba47722bd74f1e6f8f0f219e5
Reviewed-on: https://skia-review.googlesource.com/c/195368
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/modules/particles/include/SkParticleSerialization.h b/modules/particles/include/SkParticleSerialization.h
index c90fbad..dbcfe66 100644
--- a/modules/particles/include/SkParticleSerialization.h
+++ b/modules/particles/include/SkParticleSerialization.h
@@ -31,6 +31,9 @@
void visit(const char* name, SkString& s) override {
fWriter.appendString(name, s.c_str());
}
+ void visit(const char* name, int& i, const EnumStringMapping* map, int count) override {
+ fWriter.appendString(name, EnumToString(i, map, count));
+ }
// Compound types
void visit(const char* name, SkPoint& p) override {
@@ -87,6 +90,12 @@
void visit(const char* name, SkString& s) override {
TryParse(get(name), s);
}
+ void visit(const char* name, int& i, const EnumStringMapping* map, int count) override {
+ SkString str;
+ if (TryParse(get(name), str)) {
+ i = StringToEnum(str.c_str(), map, count);
+ }
+ }
void visit(const char* name, SkPoint& p) override {
if (const skjson::ObjectValue* obj = get(name)) {