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

Side by Side Diff: tests/RecordReplaceDrawTest.cpp

Issue 2106843004: Experiment: add flag for finish-recording to return null (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address comments from #21 Created 4 years, 5 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
« include/core/SkPictureRecorder.h ('K') | « tests/PictureTest.cpp ('k') | no next file » | 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 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 sk_sp<SkPicture> pic; 71 sk_sp<SkPicture> pic;
72 72
73 { 73 {
74 SkPictureRecorder recorder; 74 SkPictureRecorder recorder;
75 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT oScalar(kHeight)); 75 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT oScalar(kHeight));
76 76
77 // We won't balance this, but GrRecordReplaceDraw will for us. 77 // We won't balance this, but GrRecordReplaceDraw will for us.
78 canvas->save(); 78 canvas->save();
79 canvas->scale(2, 2); 79 canvas->scale(2, 2);
80 pic = recorder.finishRecordingAsPicture(); 80 pic = recorder.finishRecordingAsPicture();
81
82 // we may have optimized everything away. If so, just return
83 if (pic->approximateOpCount() == 0) {
84 return;
85 }
81 } 86 }
82 87
83 SkRecord rerecord; 88 SkRecord rerecord;
84 SkRecorder canvas(&rerecord, kWidth, kHeight); 89 SkRecorder canvas(&rerecord, kWidth, kHeight);
85 90
86 GrRecordReplaceDraw(pic.get(), &canvas, nullptr, SkMatrix::I(), nullptr/*cal lback*/); 91 GrRecordReplaceDraw(pic.get(), &canvas, nullptr, SkMatrix::I(), nullptr/*cal lback*/);
87 92
88 // ensure rerecord is balanced (in this case by checking that the count is o dd) 93 // ensure rerecord is balanced (in this case by checking that the count is o dd)
89 REPORTER_ASSERT(r, (rerecord.count() & 1) == 1); 94 REPORTER_ASSERT(r, (rerecord.count() & 1) == 1);
90 } 95 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 REPORTER_ASSERT(r, 1 == numLayers); 150 REPORTER_ASSERT(r, 1 == numLayers);
146 } 151 }
147 } 152 }
148 153
149 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RecordReplaceDraw, r, ctxInfo) { 154 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RecordReplaceDraw, r, ctxInfo) {
150 test_replacements(r, ctxInfo.grContext(), true); 155 test_replacements(r, ctxInfo.grContext(), true);
151 test_replacements(r, ctxInfo.grContext(), false); 156 test_replacements(r, ctxInfo.grContext(), false);
152 } 157 }
153 158
154 #endif 159 #endif
OLDNEW
« include/core/SkPictureRecorder.h ('K') | « tests/PictureTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698