OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkRemote_DEFINED | 8 #ifndef SkRemote_DEFINED |
9 #define SkRemote_DEFINED | 9 #define SkRemote_DEFINED |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 virtual void save() = 0; | 51 virtual void save() = 0; |
52 virtual void restore() = 0; | 52 virtual void restore() = 0; |
53 | 53 |
54 virtual void setMatrix(ID matrix) = 0; | 54 virtual void setMatrix(ID matrix) = 0; |
55 | 55 |
56 virtual void clipPath(ID path, SkRegion::Op, bool aa) = 0; | 56 virtual void clipPath(ID path, SkRegion::Op, bool aa) = 0; |
57 virtual void fillPath(ID path, ID misc) = 0; | 57 virtual void fillPath(ID path, ID misc) = 0; |
58 virtual void strokePath(ID path, ID misc, ID stroke) = 0; | 58 virtual void strokePath(ID path, ID misc, ID stroke) = 0; |
59 }; | 59 }; |
60 | 60 |
61 struct Cache; | 61 class LookupScope; |
62 | |
63 // TODO: document | |
64 class LookupScope { | |
65 public: | |
66 LookupScope(Cache* cache, Encoder* encoder) : fCache(cache), fEncoder(en
coder) {} | |
67 ~LookupScope() { for (ID id : fToUndefine) { fEncoder->undefine(id); } } | |
68 void undefineWhenDone(ID id) { fToUndefine.push_back(id); } | |
69 | |
70 template <typename T> | |
71 ID lookup(const T&); | |
72 private: | |
73 Cache* fCache; | |
74 Encoder* fEncoder; | |
75 SkSTArray<4, ID> fToUndefine; | |
76 }; | |
77 | 62 |
78 // TODO: document | 63 // TODO: document |
79 struct Cache { | 64 struct Cache { |
80 virtual ~Cache() {} | 65 virtual ~Cache() {} |
81 | 66 |
82 static Cache* CreateNeverCache(); | 67 static Cache* CreateNeverCache(); |
83 static Cache* CreateAlwaysCache(); | 68 static Cache* CreateAlwaysCache(); |
84 | 69 |
85 virtual bool lookup(const SkMatrix&, ID*, LookupScope*) = 0; | 70 virtual bool lookup(const SkMatrix&, ID*, LookupScope*) = 0; |
86 virtual bool lookup(const Misc&, ID*, LookupScope*) = 0; | 71 virtual bool lookup(const Misc&, ID*, LookupScope*) = 0; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 IDMap<Misc , Type::kMisc > fMisc; | 150 IDMap<Misc , Type::kMisc > fMisc; |
166 IDMap<SkPath , Type::kPath > fPath; | 151 IDMap<SkPath , Type::kPath > fPath; |
167 IDMap<Stroke , Type::kStroke> fStroke; | 152 IDMap<Stroke , Type::kStroke> fStroke; |
168 | 153 |
169 SkCanvas* fCanvas; | 154 SkCanvas* fCanvas; |
170 }; | 155 }; |
171 | 156 |
172 } // namespace SkRemote | 157 } // namespace SkRemote |
173 | 158 |
174 #endif//SkRemote_DEFINED | 159 #endif//SkRemote_DEFINED |
OLD | NEW |