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

Side by Side Diff: tests/PictureTest.cpp

Issue 1817543002: Revert of switch patheffects over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GpuDrawPathTest.cpp ('k') | tools/debugger/SkDrawCommand.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 2012 Google Inc. 2 * Copyright 2012 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 "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 static void test_gpu_veto(skiatest::Reporter* reporter) { 137 static void test_gpu_veto(skiatest::Reporter* reporter) {
138 SkPictureRecorder recorder; 138 SkPictureRecorder recorder;
139 139
140 SkCanvas* canvas = recorder.beginRecording(100, 100); 140 SkCanvas* canvas = recorder.beginRecording(100, 100);
141 { 141 {
142 SkPath path; 142 SkPath path;
143 path.moveTo(0, 0); 143 path.moveTo(0, 0);
144 path.lineTo(50, 50); 144 path.lineTo(50, 50);
145 145
146 SkScalar intervals[] = { 1.0f, 1.0f }; 146 SkScalar intervals[] = { 1.0f, 1.0f };
147 sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0)); 147 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0 ));
148 148
149 SkPaint paint; 149 SkPaint paint;
150 paint.setStyle(SkPaint::kStroke_Style); 150 paint.setStyle(SkPaint::kStroke_Style);
151 paint.setPathEffect(dash); 151 paint.setPathEffect(dash);
152 152
153 for (int i = 0; i < 50; ++i) { 153 for (int i = 0; i < 50; ++i) {
154 canvas->drawPath(path, paint); 154 canvas->drawPath(path, paint);
155 } 155 }
156 } 156 }
157 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); 157 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 226 }
227 } 227 }
228 picture = recorder.finishRecordingAsPicture(); 228 picture = recorder.finishRecordingAsPicture();
229 // hairline stroked AA concave paths are fine for GPU rendering 229 // hairline stroked AA concave paths are fine for GPU rendering
230 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr)); 230 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
231 231
232 canvas = recorder.beginRecording(100, 100); 232 canvas = recorder.beginRecording(100, 100);
233 { 233 {
234 SkPaint paint; 234 SkPaint paint;
235 SkScalar intervals [] = { 10, 20 }; 235 SkScalar intervals [] = { 10, 20 };
236 paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25)); 236 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
237 paint.setPathEffect(pe)->unref();
237 238
238 SkPoint points [2] = { { 0, 0 }, { 100, 0 } }; 239 SkPoint points [2] = { { 0, 0 }, { 100, 0 } };
239 240
240 for (int i = 0; i < 50; ++i) { 241 for (int i = 0; i < 50; ++i) {
241 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint); 242 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint);
242 } 243 }
243 } 244 }
244 picture = recorder.finishRecordingAsPicture(); 245 picture = recorder.finishRecordingAsPicture();
245 // fast-path dashed effects are fine for GPU rendering ... 246 // fast-path dashed effects are fine for GPU rendering ...
246 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr)); 247 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
247 248
248 canvas = recorder.beginRecording(100, 100); 249 canvas = recorder.beginRecording(100, 100);
249 { 250 {
250 SkPaint paint; 251 SkPaint paint;
251 SkScalar intervals [] = { 10, 20 }; 252 SkScalar intervals [] = { 10, 20 };
252 paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25)); 253 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
254 paint.setPathEffect(pe)->unref();
253 255
254 for (int i = 0; i < 50; ++i) { 256 for (int i = 0; i < 50; ++i) {
255 canvas->drawRect(SkRect::MakeWH(10, 10), paint); 257 canvas->drawRect(SkRect::MakeWH(10, 10), paint);
256 } 258 }
257 } 259 }
258 picture = recorder.finishRecordingAsPicture(); 260 picture = recorder.finishRecordingAsPicture();
259 // ... but only when applied to drawPoint() calls 261 // ... but only when applied to drawPoint() calls
260 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr)); 262 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
261 263
262 // Nest the previous picture inside a new one. 264 // Nest the previous picture inside a new one.
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 1406
1405 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); 1407 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
1406 sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream)); 1408 sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream));
1407 1409
1408 REPORTER_ASSERT(r, deserializedPicture != nullptr); 1410 REPORTER_ASSERT(r, deserializedPicture != nullptr);
1409 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); 1411 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
1410 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); 1412 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2);
1411 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); 1413 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
1412 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); 1414 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4);
1413 } 1415 }
OLDNEW
« no previous file with comments | « tests/GpuDrawPathTest.cpp ('k') | tools/debugger/SkDrawCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698