OLD | NEW |
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 } |
OLD | NEW |