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

Side by Side Diff: tests/RecorderTest.cpp

Issue 229523002: SkRecord: make culling work if SkRecordAnnotateCullingPairs is called. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 8 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
« no previous file with comments | « tests/RecordTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Test.h" 1 #include "Test.h"
2 2
3 #include "SkRecord.h" 3 #include "SkRecord.h"
4 #include "SkRecorder.h" 4 #include "SkRecorder.h"
5 #include "SkRecords.h" 5 #include "SkRecords.h"
6 6
7 #define COUNT(T) + 1 7 #define COUNT(T) + 1
8 static const int kRecordTypes = SK_RECORD_TYPES(COUNT); 8 static const int kRecordTypes = SK_RECORD_TYPES(COUNT);
9 #undef COUNT 9 #undef COUNT
10 10
11 // Tallies the types of commands it sees into histogram. 11 // Tallies the types of commands it sees into a histogram.
12 class Tally { 12 class Tally {
13 public: 13 public:
14 explicit Tally(int histogram[kRecordTypes]) : fHistogram(histogram) {} 14 Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); }
15 15
16 template <typename T> void operator()(const T&) { 16 template <typename T>
17 ++fHistogram[T::kType]; 17 void operator()(const T&) { ++fHistogram[T::kType]; }
18 } 18
19 template <typename T>
20 int count() const { return fHistogram[T::kType]; }
19 21
20 private: 22 private:
21 int* fHistogram; 23 int fHistogram[kRecordTypes];
22 }; 24 };
23 25
24 DEF_TEST(Recorder, r) { 26 DEF_TEST(Recorder, r) {
25 SkRecord record; 27 SkRecord record;
26 SkRecorder recorder(&record, 1920, 1080); 28 SkRecorder recorder(&record, 1920, 1080);
27 29
28 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); 30 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
29 31
30 int histogram[kRecordTypes]; 32 Tally tally;
31 sk_bzero(&histogram, sizeof(histogram)); 33 record.visit(tally);
32 34
33 record.visit(Tally(histogram)); 35 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>());
34
35 REPORTER_ASSERT(r, 1 == histogram[SkRecords::DrawRect::kType]);
36 } 36 }
OLDNEW
« no previous file with comments | « tests/RecordTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698