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

Side by Side Diff: tests/GpuDrawPathTest.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/DrawPathTest.cpp ('k') | tests/PictureTest.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 2013 Google Inc. 2 * Copyright 2013 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 "SkTypes.h" 8 #include "SkTypes.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 paint.setStrokeWidth(SkIntToScalar(20)); 42 paint.setStrokeWidth(SkIntToScalar(20));
43 paint.setStrokeJoin(SkPaint::kRound_Join); 43 paint.setStrokeJoin(SkPaint::kRound_Join);
44 canvas->drawRect(emptyRect, paint); 44 canvas->drawRect(emptyRect, paint);
45 canvas->drawPath(SkPath(), paint); 45 canvas->drawPath(SkPath(), paint);
46 canvas->drawOval(emptyRect, paint); 46 canvas->drawOval(emptyRect, paint);
47 canvas->drawRect(emptyRect, paint); 47 canvas->drawRect(emptyRect, paint);
48 canvas->drawRRect(SkRRect::MakeRect(emptyRect), paint); 48 canvas->drawRRect(SkRRect::MakeRect(emptyRect), paint);
49 } 49 }
50 50
51 static void fill_and_stroke(SkCanvas* canvas, const SkPath& p1, const SkPath& p2 , 51 static void fill_and_stroke(SkCanvas* canvas, const SkPath& p1, const SkPath& p2 ,
52 sk_sp<SkPathEffect> effect) { 52 SkPathEffect* effect) {
53 SkPaint paint; 53 SkPaint paint;
54 paint.setAntiAlias(true); 54 paint.setAntiAlias(true);
55 paint.setPathEffect(effect); 55 paint.setPathEffect(effect);
56 56
57 canvas->drawPath(p1, paint); 57 canvas->drawPath(p1, paint);
58 canvas->drawPath(p2, paint); 58 canvas->drawPath(p2, paint);
59 59
60 paint.setStyle(SkPaint::kStroke_Style); 60 paint.setStyle(SkPaint::kStroke_Style);
61 canvas->drawPath(p1, paint); 61 canvas->drawPath(p1, paint);
62 canvas->drawPath(p2, paint); 62 canvas->drawPath(p2, paint);
63 } 63 }
64 64
65 static void test_drawSameRectOvals(skiatest::Reporter*, SkCanvas* canvas) { 65 static void test_drawSameRectOvals(skiatest::Reporter*, SkCanvas* canvas) {
66 // Drawing ovals with similar bounds but different points order should not c rash. 66 // Drawing ovals with similar bounds but different points order should not c rash.
67 67
68 SkPath oval1, oval2; 68 SkPath oval1, oval2;
69 const SkRect rect = SkRect::MakeWH(100, 50); 69 const SkRect rect = SkRect::MakeWH(100, 50);
70 oval1.addOval(rect, SkPath::kCW_Direction); 70 oval1.addOval(rect, SkPath::kCW_Direction);
71 oval2.addOval(rect, SkPath::kCCW_Direction); 71 oval2.addOval(rect, SkPath::kCCW_Direction);
72 72
73 fill_and_stroke(canvas, oval1, oval2, nullptr); 73 fill_and_stroke(canvas, oval1, oval2, nullptr);
74 74
75 const SkScalar intervals[] = { 1, 1 }; 75 const SkScalar intervals[] = { 1, 1 };
76 fill_and_stroke(canvas, oval1, oval2, SkDashPathEffect::Make(intervals, 2, 0 )); 76 SkAutoTUnref<SkPathEffect> dashEffect(SkDashPathEffect::Create(intervals, 2, 0));
77 fill_and_stroke(canvas, oval1, oval2, dashEffect);
77 } 78 }
78 79
79 DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuDrawPath, reporter, context) { 80 DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuDrawPath, reporter, context) {
80 for (auto& test_func : { &test_drawPathEmpty, &test_drawSameRectOvals }) { 81 for (auto& test_func : { &test_drawPathEmpty, &test_drawSameRectOvals }) {
81 for (auto& sampleCount : {0, 4, 16}) { 82 for (auto& sampleCount : {0, 4, 16}) {
82 SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255); 83 SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
83 SkAutoTUnref<SkSurface> surface( 84 SkAutoTUnref<SkSurface> surface(
84 SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 85 SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info,
85 sampleCount, nullptr)); 86 sampleCount, nullptr));
86 if (!surface) { 87 if (!surface) {
(...skipping 17 matching lines...) Expand all
104 105
105 bool isVolatile; 106 bool isVolatile;
106 GrUniqueKey key1, key2; 107 GrUniqueKey key1, key2;
107 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle); 108 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
108 GrPath::ComputeKey(path1, stroke, &key1, &isVolatile); 109 GrPath::ComputeKey(path1, stroke, &key1, &isVolatile);
109 GrPath::ComputeKey(path2, stroke, &key2, &isVolatile); 110 GrPath::ComputeKey(path2, stroke, &key2, &isVolatile);
110 REPORTER_ASSERT(reporter, key1 != key2); 111 REPORTER_ASSERT(reporter, key1 != key2);
111 } 112 }
112 113
113 #endif 114 #endif
OLDNEW
« no previous file with comments | « tests/DrawPathTest.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698