Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: src/core/SkFlattenable.cpp

Issue 1853383002: Revert of Delete SkFlattenable::Type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/core/SkFlattenableSerialization.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFlattenable.cpp
diff --git a/src/core/SkFlattenable.cpp b/src/core/SkFlattenable.cpp
index 506a7b14e7c5f3b96e08fc986a432476cb782dea..c759a1ab388951b1bb305b80ac283712ddcd111b 100644
--- a/src/core/SkFlattenable.cpp
+++ b/src/core/SkFlattenable.cpp
@@ -53,18 +53,20 @@
struct Entry {
const char* fName;
SkFlattenable::Factory fFactory;
+ SkFlattenable::Type fType;
};
static int gCount = 0;
static Entry gEntries[MAX_ENTRY_COUNT];
-void SkFlattenable::Register(const char name[], Factory factory) {
+void SkFlattenable::Register(const char name[], Factory factory, SkFlattenable::Type type) {
SkASSERT(name);
SkASSERT(factory);
SkASSERT(gCount < MAX_ENTRY_COUNT);
gEntries[gCount].fName = name;
gEntries[gCount].fFactory = factory;
+ gEntries[gCount].fType = type;
gCount += 1;
}
@@ -92,6 +94,22 @@
return nullptr;
}
+bool SkFlattenable::NameToType(const char name[], SkFlattenable::Type* type) {
+ SkASSERT(type);
+ InitializeFlattenablesIfNeeded();
+#ifdef SK_DEBUG
+ report_no_entries(__FUNCTION__);
+#endif
+ const Entry* entries = gEntries;
+ for (int i = gCount - 1; i >= 0; --i) {
+ if (strcmp(entries[i].fName, name) == 0) {
+ *type = entries[i].fType;
+ return true;
+ }
+ }
+ return false;
+}
+
const char* SkFlattenable::FactoryToName(Factory fact) {
InitializeFlattenablesIfNeeded();
#ifdef SK_DEBUG
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/core/SkFlattenableSerialization.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698