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

Side by Side Diff: tests/EmptyPathTest.cpp

Issue 1330623003: more zero-length changes for svg compatibility (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify change to empty path test Created 5 years, 3 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 | « src/core/SkStroke.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 2011 Google Inc. 2 * Copyright 2011 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPath.h" 9 #include "SkPath.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 ERRORF(reporter, "%s style[%d] cap[%d] join[%d] antialias[%d]" 48 ERRORF(reporter, "%s style[%d] cap[%d] join[%d] antialias[%d]"
49 " filltype[%d] ptcount[%d]", str, paint.getStyle(), 49 " filltype[%d] ptcount[%d]", str, paint.getStyle(),
50 paint.getStrokeCap(), paint.getStrokeJoin(), 50 paint.getStrokeCap(), paint.getStrokeJoin(),
51 paint.isAntiAlias(), path.getFillType(), path.countPoints()); 51 paint.isAntiAlias(), path.getFillType(), path.countPoints());
52 // uncomment this if you want to step in to see the failure 52 // uncomment this if you want to step in to see the failure
53 // canvas.drawPath(path, p); 53 // canvas.drawPath(path, p);
54 } 54 }
55 } 55 }
56 56
57 static void iter_paint(skiatest::Reporter* reporter, const SkPath& path, bool sh ouldDraw) { 57 enum DrawCaps {
58 kDontDrawCaps,
59 kDrawCaps
60 };
61
62 static void iter_paint(skiatest::Reporter* reporter, const SkPath& path, bool sh ouldDraw,
63 DrawCaps drawCaps) {
58 static const SkPaint::Cap gCaps[] = { 64 static const SkPaint::Cap gCaps[] = {
59 SkPaint::kButt_Cap, 65 SkPaint::kButt_Cap,
60 SkPaint::kRound_Cap, 66 SkPaint::kRound_Cap,
61 SkPaint::kSquare_Cap 67 SkPaint::kSquare_Cap
62 }; 68 };
63 static const SkPaint::Join gJoins[] = { 69 static const SkPaint::Join gJoins[] = {
64 SkPaint::kMiter_Join, 70 SkPaint::kMiter_Join,
65 SkPaint::kRound_Join, 71 SkPaint::kRound_Join,
66 SkPaint::kBevel_Join 72 SkPaint::kBevel_Join
67 }; 73 };
68 static const SkPaint::Style gStyles[] = { 74 static const SkPaint::Style gStyles[] = {
69 SkPaint::kFill_Style, 75 SkPaint::kFill_Style,
70 SkPaint::kStroke_Style, 76 SkPaint::kStroke_Style,
71 SkPaint::kStrokeAndFill_Style 77 SkPaint::kStrokeAndFill_Style
72 }; 78 };
73 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) { 79 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) {
74 for (size_t join = 0; join < SK_ARRAY_COUNT(gJoins); ++join) { 80 for (size_t join = 0; join < SK_ARRAY_COUNT(gJoins); ++join) {
75 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style) { 81 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style) {
82 if (drawCaps && SkPaint::kButt_Cap != gCaps[cap]
83 && SkPaint::kFill_Style != gStyles[style]) {
84 continue;
85 }
86
76 SkPaint paint; 87 SkPaint paint;
77 paint.setStrokeWidth(SkIntToScalar(10)); 88 paint.setStrokeWidth(SkIntToScalar(10));
78 89
79 paint.setStrokeCap(gCaps[cap]); 90 paint.setStrokeCap(gCaps[cap]);
80 paint.setStrokeJoin(gJoins[join]); 91 paint.setStrokeJoin(gJoins[join]);
81 paint.setStyle(gStyles[style]); 92 paint.setStyle(gStyles[style]);
82 93
83 paint.setAntiAlias(false); 94 paint.setAntiAlias(false);
84 drawAndTest(reporter, path, paint, shouldDraw); 95 drawAndTest(reporter, path, paint, shouldDraw);
85 paint.setAntiAlias(true); 96 paint.setAntiAlias(true);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 SkPath::kInverseWinding_FillType, 131 SkPath::kInverseWinding_FillType,
121 SkPath::kInverseEvenOdd_FillType 132 SkPath::kInverseEvenOdd_FillType
122 }; 133 };
123 for (int doClose = 0; doClose < 2; ++doClose) { 134 for (int doClose = 0; doClose < 2; ++doClose) {
124 for (size_t i = 0; i < SK_ARRAY_COUNT(gMakeProc); ++i) { 135 for (size_t i = 0; i < SK_ARRAY_COUNT(gMakeProc); ++i) {
125 SkPath path; 136 SkPath path;
126 gMakeProc[i](&path); 137 gMakeProc[i](&path);
127 if (doClose) { 138 if (doClose) {
128 path.close(); 139 path.close();
129 } 140 }
141 /* zero length segments and close following moves draw round and squ are caps */
142 bool allowCaps = make_L == gMakeProc[i] || make_Q == gMakeProc[i]
143 || make_C == gMakeProc[i] || make_MZM == gMakeProc[i];
144 allowCaps |= SkToBool(doClose);
130 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) { 145 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) {
131 path.setFillType(gFills[fill]); 146 path.setFillType(gFills[fill]);
132 bool shouldDraw = path.isInverseFillType(); 147 bool shouldDraw = path.isInverseFillType();
133 iter_paint(reporter, path, shouldDraw); 148 iter_paint(reporter, path, shouldDraw, allowCaps ? kDrawCaps : k DontDrawCaps);
134 } 149 }
135 } 150 }
136 } 151 }
137 } 152 }
138 153
139 DEF_TEST(EmptyPath, reporter) { 154 DEF_TEST(EmptyPath, reporter) {
140 test_emptydrawing(reporter); 155 test_emptydrawing(reporter);
141 } 156 }
OLDNEW
« no previous file with comments | « src/core/SkStroke.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698