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

Side by Side Diff: tests/RecorderTest.cpp

Issue 231653002: SkRecordDraw: skip draw ops when the clip is empty (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pop cull unconditionally 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/RecordDrawTest.cpp ('k') | tools/bench_record.cpp » ('j') | 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 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 }
OLDNEW
« no previous file with comments | « tests/RecordDrawTest.cpp ('k') | tools/bench_record.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698