| OLD | NEW |
| 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 #include "RecordTestUtils.h" | 9 #include "RecordTestUtils.h" |
| 10 | 10 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 SkRecordNoopSaveLayerDrawRestores(record); | 107 SkRecordNoopSaveLayerDrawRestores(record); |
| 108 if (shouldBeNoOped) { | 108 if (shouldBeNoOped) { |
| 109 assert_type<SkRecords::NoOp>(r, *record, i); | 109 assert_type<SkRecords::NoOp>(r, *record, i); |
| 110 assert_type<SkRecords::NoOp>(r, *record, i+2); | 110 assert_type<SkRecords::NoOp>(r, *record, i+2); |
| 111 } else { | 111 } else { |
| 112 assert_type<SkRecords::SaveLayer>(r, *record, i); | 112 assert_type<SkRecords::SaveLayer>(r, *record, i); |
| 113 assert_type<SkRecords::Restore>(r, *record, i+2); | 113 assert_type<SkRecords::Restore>(r, *record, i+2); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 #include "SkBlurImageFilter.h" |
| 117 DEF_TEST(RecordOpts_NoopSaveLayerDrawRestore, r) { | 118 DEF_TEST(RecordOpts_NoopSaveLayerDrawRestore, r) { |
| 118 SkRecord record; | 119 SkRecord record; |
| 119 SkRecorder recorder(&record, W, H); | 120 SkRecorder recorder(&record, W, H); |
| 120 | 121 |
| 121 SkRect bounds = SkRect::MakeWH(100, 200); | 122 SkRect bounds = SkRect::MakeWH(100, 200); |
| 122 SkRect draw = SkRect::MakeWH(50, 60); | 123 SkRect draw = SkRect::MakeWH(50, 60); |
| 123 | 124 |
| 124 SkPaint alphaOnlyLayerPaint, translucentLayerPaint, xfermodeLayerPaint; | 125 SkPaint alphaOnlyLayerPaint, translucentLayerPaint, xfermodeLayerPaint; |
| 125 alphaOnlyLayerPaint.setColor(0x03000000); // Only alpha. | 126 alphaOnlyLayerPaint.setColor(0x03000000); // Only alpha. |
| 126 translucentLayerPaint.setColor(0x03040506); // Not only alpha. | 127 translucentLayerPaint.setColor(0x03040506); // Not only alpha. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 165 |
| 165 // SaveLayer/Restore removed: we can fold in the alpha! | 166 // SaveLayer/Restore removed: we can fold in the alpha! |
| 166 recorder.saveLayer(nullptr, &alphaOnlyLayerPaint); | 167 recorder.saveLayer(nullptr, &alphaOnlyLayerPaint); |
| 167 recorder.drawRect(draw, opaqueDrawPaint); | 168 recorder.drawRect(draw, opaqueDrawPaint); |
| 168 recorder.restore(); | 169 recorder.restore(); |
| 169 assert_savelayer_restore(r, &record, 15, true); | 170 assert_savelayer_restore(r, &record, 15, true); |
| 170 | 171 |
| 171 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
cord, 16); | 172 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
cord, 16); |
| 172 REPORTER_ASSERT(r, drawRect != nullptr); | 173 REPORTER_ASSERT(r, drawRect != nullptr); |
| 173 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202); | 174 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202); |
| 175 |
| 176 // saveLayer w/ backdrop should NOT go away |
| 177 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(3, 3)); |
| 178 recorder.saveLayer({ nullptr, nullptr, filter, 0}); |
| 179 recorder.drawRect(draw, opaqueDrawPaint); |
| 180 recorder.restore(); |
| 181 assert_savelayer_restore(r, &record, 18, false); |
| 174 } | 182 } |
| 175 | 183 |
| 176 static void assert_merge_svg_opacity_and_filter_layers(skiatest::Reporter* r, | 184 static void assert_merge_svg_opacity_and_filter_layers(skiatest::Reporter* r, |
| 177 SkRecord* record, | 185 SkRecord* record, |
| 178 int i, | 186 int i, |
| 179 bool shouldBeNoOped) { | 187 bool shouldBeNoOped) { |
| 180 SkRecordMergeSvgOpacityAndFilterLayers(record); | 188 SkRecordMergeSvgOpacityAndFilterLayers(record); |
| 181 if (shouldBeNoOped) { | 189 if (shouldBeNoOped) { |
| 182 assert_type<SkRecords::NoOp>(r, *record, i); | 190 assert_type<SkRecords::NoOp>(r, *record, i); |
| 183 assert_type<SkRecords::NoOp>(r, *record, i + 6); | 191 assert_type<SkRecords::NoOp>(r, *record, i + 6); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 recorder.saveLayer(nullptr, &opaqueFilterLayerPaint); | 309 recorder.saveLayer(nullptr, &opaqueFilterLayerPaint); |
| 302 recorder.restore(); | 310 recorder.restore(); |
| 303 recorder.restore(); | 311 recorder.restore(); |
| 304 SkRecordMergeSvgOpacityAndFilterLayers(&record); | 312 SkRecordMergeSvgOpacityAndFilterLayers(&record); |
| 305 assert_type<SkRecords::SaveLayer>(r, record, index); | 313 assert_type<SkRecords::SaveLayer>(r, record, index); |
| 306 assert_type<SkRecords::SaveLayer>(r, record, index + 1); | 314 assert_type<SkRecords::SaveLayer>(r, record, index + 1); |
| 307 assert_type<SkRecords::Restore>(r, record, index + 2); | 315 assert_type<SkRecords::Restore>(r, record, index + 2); |
| 308 assert_type<SkRecords::Restore>(r, record, index + 3); | 316 assert_type<SkRecords::Restore>(r, record, index + 3); |
| 309 index += 4; | 317 index += 4; |
| 310 } | 318 } |
| OLD | NEW |