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

Side by Side Diff: tests/RecordDrawTest.cpp

Issue 258183002: Don't bother doing the empty clip check in SkRecordDraw. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments and tests Created 6 years, 7 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 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 9
10 #include "SkDebugCanvas.h" 10 #include "SkDebugCanvas.h"
(...skipping 27 matching lines...) Expand all
38 SkRecorder rerecorder(SkRecorder::kReadWrite_Mode, &rerecord, W, H); 38 SkRecorder rerecorder(SkRecorder::kReadWrite_Mode, &rerecord, W, H);
39 // This clip intersects the outer cull, but allows us to quick reject the in ner one. 39 // This clip intersects the outer cull, but allows us to quick reject the in ner one.
40 rerecorder.clipRect(SkRect::MakeLTRB(20, 20, 200, 200)); 40 rerecorder.clipRect(SkRect::MakeLTRB(20, 20, 200, 200));
41 41
42 SkRecordDraw(record, &rerecorder); 42 SkRecordDraw(record, &rerecorder);
43 43
44 // We'll keep the clipRect call from above, and the outer two drawRects, and the push/pop pair. 44 // We'll keep the clipRect call from above, and the outer two drawRects, and the push/pop pair.
45 // If culling weren't working, we'd see 8 commands recorded here. 45 // If culling weren't working, we'd see 8 commands recorded here.
46 REPORTER_ASSERT(r, 5 == rerecord.count()); 46 REPORTER_ASSERT(r, 5 == rerecord.count());
47 } 47 }
48
49 DEF_TEST(RecordDraw_Clipping, r) {
50 SkRecord record;
51 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, W, H);
52
53 // 8 draw commands.
54 recorder.save();
55 recorder.clipRect(SkRect::MakeLTRB(0, 0, 100, 100));
56 recorder.drawRect(SkRect::MakeLTRB(20, 20, 40, 40), SkPaint());
57 recorder.save();
58 // This clipRect makes the clip empty, so the next command does noth ing.
59 recorder.clipRect(SkRect::MakeLTRB(200, 200, 300, 300));
60 recorder.drawRect(SkRect::MakeLTRB(220, 220, 240, 240), SkPaint()); // Skipped
61 recorder.restore();
62 recorder.restore();
63
64 // Same deal as above: we need full SkCanvas semantics for clip skipping to work.
65 SkRecord rerecord;
66 SkRecorder rerecorder(SkRecorder::kReadWrite_Mode, &rerecord, W, H);
67 SkRecordDraw(record, &rerecorder);
68
69 // All commands except the one marked // Skipped will be preserved.
70 REPORTER_ASSERT(r, 7 == rerecord.count());
71 }
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