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

Side by Side Diff: tests/RecordOptsTest.cpp

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « tests/PictureTest.cpp ('k') | tests/RecordReplaceDrawTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « tests/PictureTest.cpp ('k') | tests/RecordReplaceDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698