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

Side by Side Diff: tests/RecordCullingTest.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 | « src/record/SkRecorder.cpp ('k') | tests/RecordDrawTest.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 "SkRecordCulling.h" 4 #include "SkRecordCulling.h"
5 #include "SkRecorder.h" 5 #include "SkRecorder.h"
6 #include "SkRecords.h" 6 #include "SkRecords.h"
7 7
8 struct PushCullScanner { 8 struct PushCullScanner {
9 template <typename T> void operator()(const T&) {} 9 template <typename T> void operator()(const T&) {}
10 10
11 SkTDArray<unsigned> fPopOffsets; 11 SkTDArray<unsigned> fPopOffsets;
12 }; 12 };
13 13
14 template <> void PushCullScanner::operator()(const SkRecords::PushCull& record) { 14 template <> void PushCullScanner::operator()(const SkRecords::PushCull& record) {
15 *fPopOffsets.append() = record.popOffset; 15 *fPopOffsets.append() = record.popOffset;
16 } 16 }
17 17
18 18
19 DEF_TEST(RecordCulling, r) { 19 DEF_TEST(RecordCulling, r) {
20 SkRecord record; 20 SkRecord record;
21 SkRecorder recorder(&record, 1920, 1080); 21 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080);
22 22
23 recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint()); 23 recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint());
24 24
25 recorder.pushCull(SkRect::MakeWH(100, 100)); 25 recorder.pushCull(SkRect::MakeWH(100, 100));
26 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); 26 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
27 recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint()); 27 recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint());
28 recorder.pushCull(SkRect::MakeWH(5, 5)); 28 recorder.pushCull(SkRect::MakeWH(5, 5));
29 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint()); 29 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint());
30 recorder.popCull(); 30 recorder.popCull();
31 recorder.popCull(); 31 recorder.popCull();
32 32
33 SkRecordAnnotateCullingPairs(&record); 33 SkRecordAnnotateCullingPairs(&record);
34 34
35 PushCullScanner scan; 35 PushCullScanner scan;
36 record.visit(scan); 36 record.visit(scan);
37 37
38 REPORTER_ASSERT(r, 2 == scan.fPopOffsets.count()); 38 REPORTER_ASSERT(r, 2 == scan.fPopOffsets.count());
39 REPORTER_ASSERT(r, 6 == scan.fPopOffsets[0]); 39 REPORTER_ASSERT(r, 6 == scan.fPopOffsets[0]);
40 REPORTER_ASSERT(r, 2 == scan.fPopOffsets[1]); 40 REPORTER_ASSERT(r, 2 == scan.fPopOffsets[1]);
41 } 41 }
OLDNEW
« no previous file with comments | « src/record/SkRecorder.cpp ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698