OLD | NEW |
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 a histogram. | 11 // Tallies the types of commands it sees into a histogram. |
12 class Tally { | 12 class Tally { |
13 public: | 13 public: |
14 Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); } | 14 Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); } |
15 | 15 |
16 template <typename T> | 16 template <typename T> |
17 void operator()(const T&) { ++fHistogram[T::kType]; } | 17 void operator()(const T&) { ++fHistogram[T::kType]; } |
18 | 18 |
19 template <typename T> | 19 template <typename T> |
20 int count() const { return fHistogram[T::kType]; } | 20 int count() const { return fHistogram[T::kType]; } |
21 | 21 |
22 private: | 22 private: |
23 int fHistogram[kRecordTypes]; | 23 int fHistogram[kRecordTypes]; |
24 }; | 24 }; |
25 | 25 |
26 DEF_TEST(Recorder, r) { | 26 DEF_TEST(Recorder, r) { |
27 SkRecord record; | 27 SkRecord record; |
28 SkRecorder recorder(&record, 1920, 1080); | 28 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080); |
29 | 29 |
30 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); | 30 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); |
31 | 31 |
32 Tally tally; | 32 Tally tally; |
33 record.visit(tally); | 33 record.visit(tally); |
34 | 34 |
35 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); | 35 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); |
36 } | 36 } |
OLD | NEW |