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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 SkPaint xfermodePaint; | 223 SkPaint xfermodePaint; |
224 xfermodePaint.setXfermodeMode(SkXfermode::kDstIn_Mode); | 224 xfermodePaint.setXfermodeMode(SkXfermode::kDstIn_Mode); |
225 SkPaint colorFilterPaint; | 225 SkPaint colorFilterPaint; |
226 colorFilterPaint.setColorFilter( | 226 colorFilterPaint.setColorFilter( |
227 SkColorFilter::CreateModeFilter(SK_ColorLTGRAY, SkXfermode::kSrcIn_Mode)
)->unref(); | 227 SkColorFilter::CreateModeFilter(SK_ColorLTGRAY, SkXfermode::kSrcIn_Mode)
)->unref(); |
228 | 228 |
229 SkPaint opaqueFilterLayerPaint; | 229 SkPaint opaqueFilterLayerPaint; |
230 opaqueFilterLayerPaint.setColor(0xFF020202); // Opaque. | 230 opaqueFilterLayerPaint.setColor(0xFF020202); // Opaque. |
231 SkPaint translucentFilterLayerPaint; | 231 SkPaint translucentFilterLayerPaint; |
232 translucentFilterLayerPaint.setColor(0x0F020202); // Not opaque. | 232 translucentFilterLayerPaint.setColor(0x0F020202); // Not opaque. |
233 SkAutoTUnref<SkPicture> shape; | 233 sk_sp<SkPicture> shape; |
234 { | 234 { |
235 SkPictureRecorder recorder; | 235 SkPictureRecorder recorder; |
236 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(100), SkIntToSc
alar(100)); | 236 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(100), SkIntToSc
alar(100)); |
237 SkPaint shapePaint; | 237 SkPaint shapePaint; |
238 shapePaint.setColor(SK_ColorWHITE); | 238 shapePaint.setColor(SK_ColorWHITE); |
239 canvas->drawRect(SkRect::MakeWH(SkIntToScalar(50), SkIntToScalar(50)), s
hapePaint); | 239 canvas->drawRect(SkRect::MakeWH(SkIntToScalar(50), SkIntToScalar(50)), s
hapePaint); |
240 shape.reset(recorder.endRecordingAsPicture()); | 240 shape = recorder.finishRecordingAsPicture(); |
241 } | 241 } |
242 translucentFilterLayerPaint.setImageFilter(SkPictureImageFilter::Create(shap
e))->unref(); | 242 translucentFilterLayerPaint.setImageFilter(SkPictureImageFilter::Create(shap
e.get()))->unref(); |
243 | 243 |
244 int index = 0; | 244 int index = 0; |
245 | 245 |
246 { | 246 { |
247 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(3, 3)); | 247 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(3, 3)); |
248 // first (null) should be optimized, 2nd should not | 248 // first (null) should be optimized, 2nd should not |
249 SkImageFilter* filters[] = { nullptr, filter.get() }; | 249 SkImageFilter* filters[] = { nullptr, filter.get() }; |
250 | 250 |
251 // Any combination of these should cause the pattern to be optimized. | 251 // Any combination of these should cause the pattern to be optimized. |
252 SkRect* firstBounds[] = { nullptr, &bounds }; | 252 SkRect* firstBounds[] = { nullptr, &bounds }; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 recorder.saveLayer(nullptr, &opaqueFilterLayerPaint); | 336 recorder.saveLayer(nullptr, &opaqueFilterLayerPaint); |
337 recorder.restore(); | 337 recorder.restore(); |
338 recorder.restore(); | 338 recorder.restore(); |
339 SkRecordMergeSvgOpacityAndFilterLayers(&record); | 339 SkRecordMergeSvgOpacityAndFilterLayers(&record); |
340 assert_type<SkRecords::SaveLayer>(r, record, index); | 340 assert_type<SkRecords::SaveLayer>(r, record, index); |
341 assert_type<SkRecords::SaveLayer>(r, record, index + 1); | 341 assert_type<SkRecords::SaveLayer>(r, record, index + 1); |
342 assert_type<SkRecords::Restore>(r, record, index + 2); | 342 assert_type<SkRecords::Restore>(r, record, index + 2); |
343 assert_type<SkRecords::Restore>(r, record, index + 3); | 343 assert_type<SkRecords::Restore>(r, record, index + 3); |
344 index += 4; | 344 index += 4; |
345 } | 345 } |
OLD | NEW |