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

Unified Diff: src/core/SkRemote.cpp

Issue 1409273002: LookupScope does not need to be in SkRemote.h (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « src/core/SkRemote.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRemote.cpp
diff --git a/src/core/SkRemote.cpp b/src/core/SkRemote.cpp
index ae14a47d187b4b28d2b1acfd8913d57638de60ef..20f4c8989061cdd3bb3f1f1b5fea253b1fbf6b2e 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(); }
« no previous file with comments | « src/core/SkRemote.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698