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

Side by Side Diff: tests/RecordDrawTest.cpp

Issue 231933003: SkRecordDraw: don't bother clipping an empty clip down further (Closed) Base URL: https://skia.googlesource.com/skia.git@clipping
Patch Set: add test 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/SkRecordDraw.cpp ('k') | no next file » | 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 "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
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 }
OLDNEW
« no previous file with comments | « src/record/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698