diff options
author | mtklein <mtklein@chromium.org> | 2015-10-16 15:33:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-16 15:33:18 -0700 |
commit | 56f152b53f911b578e305d3461fb001585984a67 (patch) | |
tree | 13ed16eff3f801c2770b3ff925d9e56ee1932e9d /src | |
parent | 82e341ff8764ef6168a0c9322089c391d657ae7f (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkRemote.cpp | 31 | ||||
-rw-r--r-- | src/core/SkRemote.h | 17 |
2 files changed, 23 insertions, 25 deletions
diff --git a/src/core/SkRemote.cpp b/src/core/SkRemote.cpp index ae14a47d18..20f4c89890 100644 --- a/src/core/SkRemote.cpp +++ b/src/core/SkRemote.cpp @@ -61,6 +61,28 @@ namespace SkRemote { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // + 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 @@ namespace SkRemote { 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 87333d82f7..3bbb3b793a 100644 --- a/src/core/SkRemote.h +++ b/src/core/SkRemote.h @@ -58,22 +58,7 @@ namespace SkRemote { 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 { |