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

Unified Diff: tests/RecordOptsTest.cpp

Issue 798593003: Revert of Defer saves() until they're needed (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « tests/RecordDrawTest.cpp ('k') | tests/RecordPatternTest.cpp » ('j') | 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 cdc0350e535ddfc81450a44a50f78a11ebd5afc4..c5c4471d6715937383b9d8b122acc843d0e44e3e 100644
--- a/tests/RecordOptsTest.cpp
+++ b/tests/RecordOptsTest.cpp
@@ -16,19 +16,26 @@
static const int W = 1920, H = 1080;
-DEF_TEST(RecordOpts_NoopDraw, r) {
+DEF_TEST(RecordOpts_NoopDrawSaveRestore, r) {
SkRecord record;
SkRecorder recorder(&record, W, H);
- recorder.drawRect(SkRect::MakeWH(200, 200), SkPaint());
- recorder.drawRect(SkRect::MakeWH(300, 300), SkPaint());
- recorder.drawRect(SkRect::MakeWH(100, 100), SkPaint());
+ // The save and restore are pointless if there's only draw commands in the middle.
+ recorder.save();
+ recorder.drawRect(SkRect::MakeWH(200, 200), SkPaint());
+ recorder.drawRect(SkRect::MakeWH(300, 300), SkPaint());
+ recorder.drawRect(SkRect::MakeWH(100, 100), SkPaint());
+ recorder.restore();
- record.replace<SkRecords::NoOp>(1); // NoOps should be allowed.
+ record.replace<SkRecords::NoOp>(2); // NoOps should be allowed.
SkRecordNoopSaveRestores(&record);
- REPORTER_ASSERT(r, 2 == count_instances_of_type<SkRecords::DrawRect>(record));
+ assert_type<SkRecords::NoOp>(r, record, 0);
+ assert_type<SkRecords::DrawRect>(r, record, 1);
+ assert_type<SkRecords::NoOp>(r, record, 2);
+ assert_type<SkRecords::DrawRect>(r, record, 3);
+ assert_type<SkRecords::NoOp>(r, record, 4);
}
DEF_TEST(RecordOpts_SingleNoopSaveRestore, r) {
@@ -63,7 +70,7 @@
recorder.restore();
SkRecordNoopSaveRestores(&record);
- for (unsigned index = 0; index < record.count(); index++) {
+ for (unsigned index = 0; index < 8; index++) {
assert_type<SkRecords::NoOp>(r, record, index);
}
}
@@ -79,22 +86,10 @@
recorder.restore();
SkRecordNoopSaveRestores(&record);
- switch (record.count()) {
- case 4:
- assert_type<SkRecords::Save> (r, record, 0);
- assert_type<SkRecords::SaveLayer>(r, record, 1);
- assert_type<SkRecords::Restore> (r, record, 2);
- assert_type<SkRecords::Restore> (r, record, 3);
- break;
- case 2:
- assert_type<SkRecords::SaveLayer>(r, record, 0);
- assert_type<SkRecords::Restore> (r, record, 1);
- break;
- case 0:
- break;
- default:
- REPORTER_ASSERT(r, false);
- }
+ assert_type<SkRecords::Save> (r, record, 0);
+ assert_type<SkRecords::SaveLayer>(r, record, 1);
+ assert_type<SkRecords::Restore> (r, record, 2);
+ assert_type<SkRecords::Restore> (r, record, 3);
}
static void assert_savelayer_restore(skiatest::Reporter* r,
« no previous file with comments | « tests/RecordDrawTest.cpp ('k') | tests/RecordPatternTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698