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

Unified Diff: src/gpu/GrTestUtils.cpp

Issue 1957363002: Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
Patch Set: Remove dependency on SkDashPathEffect from GrDashingEffect.cpp Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrTestUtils.cpp
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index 86a84ceb0a3afe02c4b9f87d5146b959007904a7..c5b22801c05335a3c6a523ef98850fd6a4db30dd 100644
--- a/src/gpu/GrTestUtils.cpp
+++ b/src/gpu/GrTestUtils.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "GrStrokeInfo.h"
#include "GrTestUtils.h"
+#include "GrStyle.h"
#include "SkMatrix.h"
-#include "SkPathEffect.h"
#include "SkPath.h"
#include "SkRRect.h"
+#include "SkTemplates.h"
#ifdef GR_TEST_UTILS
@@ -237,24 +237,25 @@ SkStrokeRec TestStrokeRec(SkRandom* random) {
return rec;
}
-GrStrokeInfo TestStrokeInfo(SkRandom* random) {
- SkStrokeRec::InitStyle style =
+void TestStyle(SkRandom* random, GrStyle* style) {
+ SkStrokeRec::InitStyle initStyle =
SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_InitStyle + 1));
- GrStrokeInfo strokeInfo(style);
- randomize_stroke_rec(&strokeInfo, random);
- SkPathEffect::DashInfo dashInfo;
- dashInfo.fCount = random->nextRangeU(1, 50) * 2;
- dashInfo.fIntervals = new SkScalar[dashInfo.fCount];
- SkScalar sum = 0;
- for (int i = 0; i < dashInfo.fCount; i++) {
- dashInfo.fIntervals[i] = random->nextRangeScalar(SkDoubleToScalar(0.01),
- SkDoubleToScalar(10.0));
- sum += dashInfo.fIntervals[i];
+ SkStrokeRec stroke(initStyle);
+ randomize_stroke_rec(&stroke, random);
+ sk_sp<SkPathEffect> pe;
+ if (random->nextBool()) {
+ int cnt = random->nextRangeU(1, 50) * 2;
+ SkAutoTDeleteArray<SkScalar> intervals(new SkScalar[cnt]);
+ SkScalar sum = 0;
+ for (int i = 0; i < cnt; i++) {
+ intervals[i] = random->nextRangeScalar(SkDoubleToScalar(0.01),
+ SkDoubleToScalar(10.0));
+ sum += intervals[i];
+ }
+ SkScalar phase = random->nextRangeScalar(0, sum);
+ pe = TestDashPathEffect::Make(intervals.get(), cnt, phase);
}
- dashInfo.fPhase = random->nextRangeScalar(0, sum);
- strokeInfo.setDashInfo(dashInfo);
- delete[] dashInfo.fIntervals;
- return strokeInfo;
+ *style = GrStyle(stroke, pe.get());
}
};

Powered by Google App Engine
This is Rietveld 408576698