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

Unified Diff: tests/RecordOptsTest.cpp

Issue 277613002: Noop away PushCull/PopCull pairs with nothing between them. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/record/SkRecordOpts.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordOptsTest.cpp
diff --git a/tests/RecordOptsTest.cpp b/tests/RecordOptsTest.cpp
index c427c25119a08f93ac16f4f0c1346295c66a2d00..34229d7a6b69adcaaf583552444f05410d3a6280 100644
--- a/tests/RecordOptsTest.cpp
+++ b/tests/RecordOptsTest.cpp
@@ -60,6 +60,35 @@ DEF_TEST(RecordOpts_Culling, r) {
REPORTER_ASSERT(r, 2 == assert_type<SkRecords::PairedPushCull>(r, record, 4)->skip);
}
+DEF_TEST(RecordOpts_NoopCulls, r) {
+ SkRecord record;
+ SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, W, H);
+
+ // All should be nooped.
+ recorder.pushCull(SkRect::MakeWH(200, 200));
+ recorder.pushCull(SkRect::MakeWH(100, 100));
+ recorder.popCull();
+ recorder.popCull();
+
+ // Kept for now. We could peel off a layer of culling.
+ recorder.pushCull(SkRect::MakeWH(5, 5));
+ recorder.pushCull(SkRect::MakeWH(5, 5));
+ recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint());
+ recorder.popCull();
+ recorder.popCull();
+
+ SkRecordNoopCulls(&record);
+
+ for (unsigned i = 0; i < 4; i++) {
+ assert_type<SkRecords::NoOp>(r, record, i);
+ }
+ assert_type<SkRecords::PushCull>(r, record, 4);
+ assert_type<SkRecords::PushCull>(r, record, 5);
+ assert_type<SkRecords::DrawRect>(r, record, 6);
+ assert_type<SkRecords::PopCull>(r, record, 7);
+ assert_type<SkRecords::PopCull>(r, record, 8);
+}
+
static void draw_pos_text(SkCanvas* canvas, const char* text, bool constantY) {
const size_t len = strlen(text);
SkAutoTMalloc<SkPoint> pos(len);
« no previous file with comments | « src/record/SkRecordOpts.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698