OLD | NEW |
1 #ifndef SkRecordPattern_DEFINED | 1 #ifndef SkRecordPattern_DEFINED |
2 #define SkRecordPattern_DEFINED | 2 #define SkRecordPattern_DEFINED |
3 | 3 |
4 #include "SkTLogic.h" | 4 #include "SkTLogic.h" |
5 | 5 |
6 namespace SkRecords { | 6 namespace SkRecords { |
7 | 7 |
8 // First, some matchers. These match a single command in the SkRecord, | 8 // First, some matchers. These match a single command in the SkRecord, |
9 // and may hang onto some data from it. If so, you can get the data by calling
.get(). | 9 // and may hang onto some data from it. If so, you can get the data by calling
.get(). |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 fPaint = AsPtr(draw->paint); | 46 fPaint = AsPtr(draw->paint); |
47 return true; | 47 return true; |
48 } | 48 } |
49 | 49 |
50 template <typename T> | 50 template <typename T> |
51 SK_WHEN(!HasMember_paint<T>, bool) match(T*) { | 51 SK_WHEN(!HasMember_paint<T>, bool) match(T*) { |
52 fPaint = NULL; | 52 fPaint = NULL; |
53 return false; | 53 return false; |
54 } | 54 } |
55 | 55 |
| 56 // SaveLayer has an SkPaint named paint, but it's not a draw. |
| 57 bool match(SaveLayer*) { |
| 58 fPaint = NULL; |
| 59 return false; |
| 60 } |
| 61 |
56 private: | 62 private: |
57 // Abstracts away whether the paint is always part of the command or optiona
l. | 63 // Abstracts away whether the paint is always part of the command or optiona
l. |
58 template <typename T> static T* AsPtr(SkRecords::Optional<T>& x) { return x;
} | 64 template <typename T> static T* AsPtr(SkRecords::Optional<T>& x) { return x;
} |
59 template <typename T> static T* AsPtr(T& x) { return &x; } | 65 template <typename T> static T* AsPtr(T& x) { return &x; } |
60 | 66 |
61 type* fPaint; | 67 type* fPaint; |
62 }; | 68 }; |
63 | 69 |
64 // Matches if Matcher doesn't. Stores nothing. | 70 // Matches if Matcher doesn't. Stores nothing. |
65 template <typename Matcher> | 71 template <typename Matcher> |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 216 |
211 template <typename A, typename B> | 217 template <typename A, typename B> |
212 struct Pattern2 : Cons<A, Pattern1<B> > {}; | 218 struct Pattern2 : Cons<A, Pattern1<B> > {}; |
213 | 219 |
214 template <typename A, typename B, typename C> | 220 template <typename A, typename B, typename C> |
215 struct Pattern3 : Cons<A, Pattern2<B, C> > {}; | 221 struct Pattern3 : Cons<A, Pattern2<B, C> > {}; |
216 | 222 |
217 } // namespace SkRecords | 223 } // namespace SkRecords |
218 | 224 |
219 #endif//SkRecordPattern_DEFINED | 225 #endif//SkRecordPattern_DEFINED |
OLD | NEW |