commit-bot@chromium.org | 506db0b | 2014-04-08 23:31:35 +0000 | [diff] [blame] | 1 | #include "Test.h" |
| 2 | |
| 3 | #include "SkRecord.h" |
| 4 | #include "SkRecordCulling.h" |
| 5 | #include "SkRecorder.h" |
| 6 | #include "SkRecords.h" |
| 7 | |
| 8 | struct PushCullScanner { |
| 9 | template <typename T> void operator()(const T&) {} |
| 10 | |
| 11 | SkTDArray<unsigned> fPopOffsets; |
| 12 | }; |
| 13 | |
| 14 | template <> void PushCullScanner::operator()(const SkRecords::PushCull& record) { |
| 15 | *fPopOffsets.append() = record.popOffset; |
| 16 | } |
| 17 | |
| 18 | |
| 19 | DEF_TEST(RecordCulling, r) { |
| 20 | SkRecord record; |
commit-bot@chromium.org | d9ce2be | 2014-04-09 23:30:28 +0000 | [diff] [blame] | 21 | SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080); |
commit-bot@chromium.org | 506db0b | 2014-04-08 23:31:35 +0000 | [diff] [blame] | 22 | |
| 23 | recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint()); |
| 24 | |
| 25 | recorder.pushCull(SkRect::MakeWH(100, 100)); |
| 26 | recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); |
| 27 | recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint()); |
| 28 | recorder.pushCull(SkRect::MakeWH(5, 5)); |
| 29 | recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint()); |
| 30 | recorder.popCull(); |
| 31 | recorder.popCull(); |
| 32 | |
| 33 | SkRecordAnnotateCullingPairs(&record); |
| 34 | |
| 35 | PushCullScanner scan; |
| 36 | record.visit(scan); |
| 37 | |
| 38 | REPORTER_ASSERT(r, 2 == scan.fPopOffsets.count()); |
| 39 | REPORTER_ASSERT(r, 6 == scan.fPopOffsets[0]); |
| 40 | REPORTER_ASSERT(r, 2 == scan.fPopOffsets[1]); |
| 41 | } |