LookupScope does not need to be in SkRemote.h
It's only used by Cache and Client.
This moves it to SkRemote.cpp, where they live.
BUG=skia:
Review URL: https://codereview.chromium.org/1409273002
diff --git a/src/core/SkRemote.cpp b/src/core/SkRemote.cpp
index ae14a47..20f4c89 100644
--- a/src/core/SkRemote.cpp
+++ b/src/core/SkRemote.cpp
@@ -61,6 +61,28 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
+ class LookupScope {
+ public:
+ LookupScope(Cache* cache, Encoder* encoder) : fCache(cache), fEncoder(encoder) {}
+ ~LookupScope() { for (ID id : fToUndefine) { fEncoder->undefine(id); } }
+ void undefineWhenDone(ID id) { fToUndefine.push_back(id); }
+
+ template <typename T>
+ ID lookup(const T& val) {
+ ID id;
+ if (!fCache->lookup(val, &id, this)) {
+ fEncoder->define(id, val);
+ }
+ return id;
+ }
+
+ private:
+ Cache* fCache;
+ Encoder* fEncoder;
+ SkSTArray<4, ID> fToUndefine;
+ };
+
+
Cache* Cache::CreateNeverCache() {
struct NeverCache final : public Cache {
NeverCache()
@@ -164,15 +186,6 @@
fCache->cleanup(fEncoder);
}
- template <typename T>
- ID LookupScope::lookup(const T& val) {
- ID id;
- if (!fCache->lookup(val, &id, this)) {
- fEncoder->define(id, val);
- }
- return id;
- }
-
void Client::willSave() { fEncoder->save(); }
void Client::didRestore() { fEncoder->restore(); }
diff --git a/src/core/SkRemote.h b/src/core/SkRemote.h
index 87333d8..3bbb3b7 100644
--- a/src/core/SkRemote.h
+++ b/src/core/SkRemote.h
@@ -58,22 +58,7 @@
virtual void strokePath(ID path, ID misc, ID stroke) = 0;
};
- struct Cache;
-
- // TODO: document
- class LookupScope {
- public:
- LookupScope(Cache* cache, Encoder* encoder) : fCache(cache), fEncoder(encoder) {}
- ~LookupScope() { for (ID id : fToUndefine) { fEncoder->undefine(id); } }
- void undefineWhenDone(ID id) { fToUndefine.push_back(id); }
-
- template <typename T>
- ID lookup(const T&);
- private:
- Cache* fCache;
- Encoder* fEncoder;
- SkSTArray<4, ID> fToUndefine;
- };
+ class LookupScope;
// TODO: document
struct Cache {