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

Side by Side Diff: src/gpu/GrTestUtils.cpp

Issue 1275553002: Implement caching of stroked paths in the tessellating path renderer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use IsStrokeHairlineOrEquivalent() instead of stroke->isHairline() Created 5 years, 4 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/gpu/GrTessellatingPathRenderer.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 2015 Google Inc. 2 * Copyright 2015 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 "GrStrokeInfo.h"
8 #include "GrTestUtils.h" 9 #include "GrTestUtils.h"
9 #include "SkMatrix.h" 10 #include "SkMatrix.h"
11 #include "SkPathEffect.h"
10 #include "SkPath.h" 12 #include "SkPath.h"
11 #include "SkRRect.h" 13 #include "SkRRect.h"
12 14
13 #ifdef GR_TEST_UTILS 15 #ifdef GR_TEST_UTILS
14 16
15 static const SkMatrix& test_matrix(SkRandom* random, bool includePerspective) { 17 static const SkMatrix& test_matrix(SkRandom* random, bool includePerspective) {
16 static SkMatrix gMatrices[5]; 18 static SkMatrix gMatrices[5];
17 static const int kPerspectiveCount = 1; 19 static const int kPerspectiveCount = 1;
18 static bool gOnce; 20 static bool gOnce;
19 if (!gOnce) { 21 if (!gOnce) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 gPath[2].lineTo(-50.0f, 31.0f); 211 gPath[2].lineTo(-50.0f, 31.0f);
210 212
211 for (size_t i = 0; i < SK_ARRAY_COUNT(gPath); i++) { 213 for (size_t i = 0; i < SK_ARRAY_COUNT(gPath); i++) {
212 SkASSERT(SkPath::kConvex_Convexity == gPath[i].getConvexity()); 214 SkASSERT(SkPath::kConvex_Convexity == gPath[i].getConvexity());
213 } 215 }
214 } 216 }
215 217
216 return gPath[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gPat h)))]; 218 return gPath[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gPat h)))];
217 } 219 }
218 220
221 static void randomize_stroke_rec(SkStrokeRec* rec, SkRandom* random) {
222 bool strokeAndFill = random->nextBool();
223 SkScalar strokeWidth = random->nextBool() ? 0.f : 1.f;
224 rec->setStrokeStyle(strokeWidth, strokeAndFill);
225
226 SkPaint::Cap cap = SkPaint::Cap(random->nextULessThan(SkPaint::kCapCount));
227 SkPaint::Join join = SkPaint::Join(random->nextULessThan(SkPaint::kJoinCount ));
228 SkScalar miterLimit = random->nextRangeScalar(1.f, 5.f);
229 rec->setStrokeParams(cap, join, miterLimit);
230 }
231
219 SkStrokeRec TestStrokeRec(SkRandom* random) { 232 SkStrokeRec TestStrokeRec(SkRandom* random) {
220 SkStrokeRec::InitStyle style = 233 SkStrokeRec::InitStyle style =
221 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init Style + 1)); 234 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init Style + 1));
222 SkStrokeRec rec(style); 235 SkStrokeRec rec(style);
223 bool strokeAndFill = random->nextBool(); 236 randomize_stroke_rec(&rec, random);
224 SkScalar strokeWidth = random->nextBool() ? 0.f : 1.f; 237 return rec;
225 rec.setStrokeStyle(strokeWidth, strokeAndFill); 238 }
226 239
227 SkPaint::Cap cap = SkPaint::Cap(random->nextULessThan(SkPaint::kCapCount)); 240 GrStrokeInfo TestStrokeInfo(SkRandom* random) {
228 SkPaint::Join join = SkPaint::Join(random->nextULessThan(SkPaint::kJoinCount )); 241 SkStrokeRec::InitStyle style =
229 SkScalar miterLimit = random->nextRangeScalar(1.f, 5.f); 242 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init Style + 1));
230 rec.setStrokeParams(cap, join, miterLimit); 243 GrStrokeInfo strokeInfo(style);
231 return rec; 244 randomize_stroke_rec(&strokeInfo, random);
245 SkPathEffect::DashInfo dashInfo;
246 dashInfo.fCount = random->nextRangeU(1, 50) * 2;
247 dashInfo.fIntervals = SkNEW_ARRAY(SkScalar, dashInfo.fCount);
mtklein_C 2015/08/06 18:42:03 This you? https://build.chromium.org/p/client.ski
Stephen White 2015/08/06 19:22:38 https://codereview.chromium.org/1274963003/
248 SkScalar sum = 0;
249 for (int i = 0; i < dashInfo.fCount; i++) {
250 dashInfo.fIntervals[i] = random->nextRangeScalar(SkDoubleToScalar(0.01),
251 SkDoubleToScalar(10.0)) ;
252 sum += dashInfo.fIntervals[i];
253 }
254 dashInfo.fPhase = random->nextRangeScalar(0, sum);
255 strokeInfo.setDashInfo(dashInfo);
256 return strokeInfo;
232 } 257 }
233 258
234 }; 259 };
235 260
236 #endif 261 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698