OLD | NEW |
1 #include "Test.h" | 1 #include "Test.h" |
2 | 2 |
3 #include "SkDebugCanvas.h" | 3 #include "SkDebugCanvas.h" |
4 #include "SkRecord.h" | 4 #include "SkRecord.h" |
5 #include "SkRecordCulling.h" | 5 #include "SkRecordCulling.h" |
6 #include "SkRecordDraw.h" | 6 #include "SkRecordDraw.h" |
7 #include "SkRecorder.h" | 7 #include "SkRecorder.h" |
8 #include "SkRecords.h" | 8 #include "SkRecords.h" |
9 | 9 |
10 static const int W = 1920, H = 1080; | 10 static const int W = 1920, H = 1080; |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // We'll keep the clipRect call from above, and the outer two drawRects, and
the push/pop pair. | 37 // We'll keep the clipRect call from above, and the outer two drawRects, and
the push/pop pair. |
38 // If culling weren't working, we'd see 8 commands recorded here. | 38 // If culling weren't working, we'd see 8 commands recorded here. |
39 REPORTER_ASSERT(r, 5 == rerecord.count()); | 39 REPORTER_ASSERT(r, 5 == rerecord.count()); |
40 } | 40 } |
41 | 41 |
42 DEF_TEST(RecordDraw_Clipping, r) { | 42 DEF_TEST(RecordDraw_Clipping, r) { |
43 SkRecord record; | 43 SkRecord record; |
44 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, W, H); | 44 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, W, H); |
45 | 45 |
46 // 8 draw commands. | 46 // 9 draw commands. |
47 // The inner clipRect makes the clip empty, so the inner drawRect does nothi
ng. | |
48 recorder.save(); | 47 recorder.save(); |
49 recorder.clipRect(SkRect::MakeLTRB(0, 0, 100, 100)); | 48 recorder.clipRect(SkRect::MakeLTRB(0, 0, 100, 100)); |
50 recorder.drawRect(SkRect::MakeLTRB(20, 20, 40, 40), SkPaint()); | 49 recorder.drawRect(SkRect::MakeLTRB(20, 20, 40, 40), SkPaint()); |
51 recorder.save(); | 50 recorder.save(); |
| 51 // This first clipRect makes the clip empty, so the next two command
s do nothing. |
52 recorder.clipRect(SkRect::MakeLTRB(200, 200, 300, 300)); | 52 recorder.clipRect(SkRect::MakeLTRB(200, 200, 300, 300)); |
53 recorder.drawRect(SkRect::MakeLTRB(220, 220, 240, 240), SkPaint()); | 53 recorder.clipRect(SkRect::MakeLTRB(210, 210, 250, 250));
// Skipped |
| 54 recorder.drawRect(SkRect::MakeLTRB(220, 220, 240, 240), SkPaint());
// Skipped |
54 recorder.restore(); | 55 recorder.restore(); |
55 recorder.restore(); | 56 recorder.restore(); |
56 | 57 |
57 // Same deal as above: we need full SkCanvas semantics for clip skipping to
work. | 58 // Same deal as above: we need full SkCanvas semantics for clip skipping to
work. |
58 SkRecord rerecord; | 59 SkRecord rerecord; |
59 SkRecorder rerecorder(SkRecorder::kReadWrite_Mode, &rerecord, W, H); | 60 SkRecorder rerecorder(SkRecorder::kReadWrite_Mode, &rerecord, W, H); |
60 SkRecordDraw(record, &rerecorder); | 61 SkRecordDraw(record, &rerecorder); |
61 | 62 |
62 // All commands except the drawRect will be preserved. | 63 // All commands except the two marked // Skipped above will be preserved. |
63 REPORTER_ASSERT(r, 7 == rerecord.count()); | 64 REPORTER_ASSERT(r, 7 == rerecord.count()); |
64 } | 65 } |
OLD | NEW |