diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-07 17:17:48 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-07 17:17:48 +0000 |
commit | 467705adf05ba99bbd9ccdf6a40eb463484a6fbf (patch) | |
tree | dfd983e32dea0359e6b09c316132057c1dc45fbe /tests | |
parent | 44e3f715e694e2a97ab283a10dcbc26556d92018 (diff) |
save-draw*-restore -> noop-draw*-noop
save-drawA-drawB-drawC-restore always means drawA-drawB-drawC,
no matter what flags we use for save().
This one triggers all over the silk SKPs and in several of the bot SKPs, typically as save-drawBitmap-restore.
BUG=skia:2378
R=robertphillips@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/267793006
git-svn-id: http://skia.googlecode.com/svn/trunk@14618 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/RecordOptsTest.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/tests/RecordOptsTest.cpp b/tests/RecordOptsTest.cpp index 90347eda1f..33142c8a3d 100644 --- a/tests/RecordOptsTest.cpp +++ b/tests/RecordOptsTest.cpp @@ -108,6 +108,28 @@ DEF_TEST(RecordOpts_TextBounding, r) { REPORTER_ASSERT(r, bounded->maxY >= SK_Scalar1 + defaults.getTextSize()); } +DEF_TEST(RecordOpts_NoopDrawSaveRestore, r) { + SkRecord record; + SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, W, H); + + // 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>(2); // NoOps should be allowed. + + SkRecordNoopSaveRestores(&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) { SkRecord record; SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, W, H); @@ -139,19 +161,10 @@ DEF_TEST(RecordOpts_NoopSaveRestores, r) { recorder.restore(); recorder.restore(); - // These will be kept (though some future optimization might noop the save and restore). - recorder.save(); - recorder.drawRect(SkRect::MakeWH(200, 200), SkPaint()); - recorder.restore(); - SkRecordNoopSaveRestores(&record); - for (unsigned index = 0; index < 8; index++) { assert_type<SkRecords::NoOp>(r, record, index); } - assert_type<SkRecords::Save>(r, record, 8); - assert_type<SkRecords::DrawRect>(r, record, 9); - assert_type<SkRecords::Restore>(r, record, 10); } static void assert_savelayer_restore(skiatest::Reporter* r, |