From 73fffeb83aab56bc8c2c5ce143ee9d132d64ac37 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Mon, 5 May 2014 21:59:52 +0000 Subject: 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> matches a single DrawRect - Pattern1>> matches 0 or more DrawRects - Pattern2, Is> matches a single clip rect followed by a single draw rect - Pattern3, Star, Is> matches a single Save, followed by any number of Draws, followed by Restore - Pattern1, Is>> matches a DrawRect or a ClipRect - Pattern1>> 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 --- src/utils/SkTLogic.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/utils/SkTLogic.h') 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(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 \ +class HasType_##type { \ + template static uint8_t func(typename U::type*); \ + template static uint16_t func(...); \ +public: \ + static const bool value = sizeof(func(NULL)) == sizeof(uint8_t); \ +} + #endif -- cgit v1.2.3