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

Unified Diff: tests/RecordTestUtils.h

Issue 767333002: Defer saves() until they're needed (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update tests Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/RecordReplaceDrawTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordTestUtils.h
diff --git a/tests/RecordTestUtils.h b/tests/RecordTestUtils.h
index 0575b83cdd57ee687aa585eec74763a2be158c68..4bab8e4a390b980c707824015399db551789b5e8 100644
--- a/tests/RecordTestUtils.h
+++ b/tests/RecordTestUtils.h
@@ -28,4 +28,28 @@ static const T* assert_type(skiatest::Reporter* r, const SkRecord& record, unsig
return reader.ptr;
}
+template <typename DrawT> struct MatchType {
+ template <typename T> int operator()(const T&) { return 0; }
+ int operator()(const DrawT&) { return 1; }
+};
+
+template <typename DrawT> int count_instances_of_type(const SkRecord& record) {
+ MatchType<DrawT> matcher;
+ int counter = 0;
+ for (unsigned i = 0; i < record.count(); i++) {
+ counter += record.visit<int>(i, matcher);
+ }
+ return counter;
+}
+
+template <typename DrawT> int find_first_instances_of_type(const SkRecord& record) {
+ MatchType<DrawT> matcher;
+ for (unsigned i = 0; i < record.count(); i++) {
+ if (record.visit<int>(i, matcher)) {
+ return i;
+ }
+ }
+ return -1;
+}
+
#endif//RecordTestUtils_DEFINED
« no previous file with comments | « tests/RecordReplaceDrawTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698