aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkTLogic.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 21:59:52 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 21:59:52 +0000
commit73fffeb83aab56bc8c2c5ce143ee9d132d64ac37 (patch)
tree75fc97ceeb08d62fdd25de4affbe1639e0d66063 /src/utils/SkTLogic.h
parent06a32062620daee7a93742f553829a8d4f93f720 (diff)
Add pattern matchers for SkRecord
This is a mid-level library for finding patterns of commands in an SkRecord. At the API level, it's a bit regex inspired. Some examples: - Pattern1<Is<DrawRect>> matches a single DrawRect - Pattern1<Star<Is<DrawRect>>> matches 0 or more DrawRects - Pattern2<Is<ClipRect>, Is<DrawRect>> matches a single clip rect followed by a single draw rect - Pattern3<Is<Save>, Star<IsDraw>, Is<Restore>> matches a single Save, followed by any number of Draws, followed by Restore - Pattern1<Or<Is<DrawRect>, Is<ClipRect>>> matches a DrawRect or a ClipRect - Pattern1<Not<Is<ClipRect>>> matches a command that's notClipRect. Once you have a pattern, you can call .search() on it to step through ranges of matching commands. This means patterns can replace most of the custom iteration logic for optimization passes: the generic pattern searching steps through all the optimization candidates, which optimization-specific code further inspects and mutates. SkRecordTraits is now unused. Bye bye! Generated code and performance of SkRecordOpts is very similar to what it was before. (I had to use SK_ALWAYS_INLINE in a few places to make this so.) BUG=skia:2378 R=fmalita@chromium.org, bungeman@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/263063002 git-svn-id: http://skia.googlecode.com/svn/trunk@14582 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/SkTLogic.h')
-rw-r--r--src/utils/SkTLogic.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/utils/SkTLogic.h b/src/utils/SkTLogic.h
index 62952ad13c..925d4bdcd4 100644
--- a/src/utils/SkTLogic.h
+++ b/src/utils/SkTLogic.h
@@ -89,4 +89,14 @@ public:
static const bool value = sizeof(func<Derived>(NULL)) == sizeof(uint16_t); \
}
+// Same sort of thing as SK_CREATE_MEMBER_DETECTOR, but checks for the existence of a nested type.
+#define SK_CREATE_TYPE_DETECTOR(type) \
+template <typename T> \
+class HasType_##type { \
+ template <typename U> static uint8_t func(typename U::type*); \
+ template <typename U> static uint16_t func(...); \
+public: \
+ static const bool value = sizeof(func<T>(NULL)) == sizeof(uint8_t); \
+}
+
#endif