aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTestUtils.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-05-10 06:19:21 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-10 06:19:21 -0700
commit85d9667f59d4138438427bb2cdf67992d100e1a0 (patch)
tree1d86fd1d78a1bdd36f6b250bf31dd285986db5ef /src/gpu/GrTestUtils.cpp
parent00e9452791a80ed9fb824214b259ecb9af0c25c6 (diff)
Revert of Replace GrStrokeInfo with GrStyle. (patchset #4 id:160001 of https://codereview.chromium.org/1957363002/ )
Reason for revert: Breaking some bots Original issue's description: > Replace GrStrokeInfo with GrStyle. > > A side effect is that arbitrary path effects can no be pushed deeper into the Ganesh flow for paths. They may be applied by path renderers. > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1957363002 > > Committed: https://skia.googlesource.com/skia/+/33595bdf4b64a745f6340338d307e806e96c587f TBR=egdaniel@google.com,robertphillips@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/1967513002
Diffstat (limited to 'src/gpu/GrTestUtils.cpp')
-rw-r--r--src/gpu/GrTestUtils.cpp65
1 files changed, 19 insertions, 46 deletions
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index e962978fc3..86a84ceb0a 100644
--- a/src/gpu/GrTestUtils.cpp
+++ b/src/gpu/GrTestUtils.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
+#include "GrStrokeInfo.h"
#include "GrTestUtils.h"
-#include "GrStyle.h"
-#include "SkDashPathPriv.h"
#include "SkMatrix.h"
+#include "SkPathEffect.h"
#include "SkPath.h"
#include "SkRRect.h"
@@ -237,53 +237,26 @@ SkStrokeRec TestStrokeRec(SkRandom* random) {
return rec;
}
-void TestStyle(SkRandom* random, GrStyle* style) {
- SkStrokeRec::InitStyle initStyle =
+GrStrokeInfo TestStrokeInfo(SkRandom* random) {
+ SkStrokeRec::InitStyle style =
SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_InitStyle + 1));
- 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);
+ 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];
}
- *style = GrStyle(stroke, pe.get());
-}
-
-TestDashPathEffect::TestDashPathEffect(const SkScalar* intervals, int count, SkScalar phase) {
- fCount = count;
- fIntervals.reset(count);
- memcpy(fIntervals.get(), intervals, count * sizeof(SkScalar));
- SkDashPath::CalcDashParameters(phase, intervals, count, &fInitialDashLength,
- &fInitialDashIndex, &fIntervalLength, &fPhase);
-}
-
- bool TestDashPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
- const SkRect* cullRect) const {
- return SkDashPath::InternalFilter(dst, src, rec, cullRect, fIntervals.get(), fCount,
- fInitialDashLength, fInitialDashIndex, fIntervalLength);
+ dashInfo.fPhase = random->nextRangeScalar(0, sum);
+ strokeInfo.setDashInfo(dashInfo);
+ delete[] dashInfo.fIntervals;
+ return strokeInfo;
}
-SkPathEffect::DashType TestDashPathEffect::asADash(DashInfo* info) const {
- if (info) {
- if (info->fCount >= fCount && info->fIntervals) {
- memcpy(info->fIntervals, fIntervals.get(), fCount * sizeof(SkScalar));
- }
- info->fCount = fCount;
- info->fPhase = fPhase;
- }
- return kDash_DashType;
-}
-
-
-} // namespace GrTest
+};
#endif