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

Side by Side Diff: tests/PictureTest.cpp

Issue 1813553005: switch patheffects over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try to fix xpsdevice 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 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0 )); 147 sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(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 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25); 236 paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25));
237 paint.setPathEffect(pe)->unref();
238 237
239 SkPoint points [2] = { { 0, 0 }, { 100, 0 } }; 238 SkPoint points [2] = { { 0, 0 }, { 100, 0 } };
240 239
241 for (int i = 0; i < 50; ++i) { 240 for (int i = 0; i < 50; ++i) {
242 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint); 241 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint);
243 } 242 }
244 } 243 }
245 picture = recorder.finishRecordingAsPicture(); 244 picture = recorder.finishRecordingAsPicture();
246 // fast-path dashed effects are fine for GPU rendering ... 245 // fast-path dashed effects are fine for GPU rendering ...
247 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr)); 246 REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
248 247
249 canvas = recorder.beginRecording(100, 100); 248 canvas = recorder.beginRecording(100, 100);
250 { 249 {
251 SkPaint paint; 250 SkPaint paint;
252 SkScalar intervals [] = { 10, 20 }; 251 SkScalar intervals [] = { 10, 20 };
253 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25); 252 paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25));
254 paint.setPathEffect(pe)->unref();
255 253
256 for (int i = 0; i < 50; ++i) { 254 for (int i = 0; i < 50; ++i) {
257 canvas->drawRect(SkRect::MakeWH(10, 10), paint); 255 canvas->drawRect(SkRect::MakeWH(10, 10), paint);
258 } 256 }
259 } 257 }
260 picture = recorder.finishRecordingAsPicture(); 258 picture = recorder.finishRecordingAsPicture();
261 // ... but only when applied to drawPoint() calls 259 // ... but only when applied to drawPoint() calls
262 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr)); 260 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
263 261
264 // Nest the previous picture inside a new one. 262 // Nest the previous picture inside a new one.
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 1404
1407 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); 1405 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
1408 sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream)); 1406 sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream));
1409 1407
1410 REPORTER_ASSERT(r, deserializedPicture != nullptr); 1408 REPORTER_ASSERT(r, deserializedPicture != nullptr);
1411 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); 1409 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
1412 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); 1410 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2);
1413 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); 1411 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
1414 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); 1412 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4);
1415 } 1413 }
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