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

Side by Side Diff: src/record/SkRecordTraits.h

Issue 263063002: Add pattern matchers for SkRecord (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: yet more notes Created 6 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 #include "SkRecords.h"
2 #include "SkTLogic.h"
3
4 // Type traits that are useful for working with SkRecords.
5
6 namespace SkRecords {
7
8 namespace {
9
10 // Abstracts away whether the T is optional or not.
11 template <typename T> const T* as_ptr(const SkRecords::Optional<T>& x) { return x; }
12 template <typename T> const T* as_ptr(const T& x) { return &x; }
13
14 } // namespace
15
16 // Gets the paint from any command that may have one.
17 template <typename Command> const SkPaint* GetPaint(const Command& x) { return a s_ptr(x.paint); }
18
19 // Have a paint? You are a draw command!
20 template <typename Command> struct IsDraw {
21 SK_CREATE_MEMBER_DETECTOR(paint);
22 static const bool value = HasMember_paint<Command>::value;
23 };
24
25 // Have a clip op? You are a clip command.
26 template <typename Command> struct IsClip {
27 SK_CREATE_MEMBER_DETECTOR(op);
28 static const bool value = HasMember_op<Command>::value;
29 };
30
31 } // namespace SkRecords
OLDNEW
« no previous file with comments | « src/record/SkRecordPattern.h ('k') | src/utils/SkTLogic.h » ('j') | src/utils/SkTLogic.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698