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

Unified Diff: include/gpu/GrTestUtils.h

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: include/gpu/GrTestUtils.h
diff --git a/include/gpu/GrTestUtils.h b/include/gpu/GrTestUtils.h
index 475e38a6a11d50034aebaf1145973dbfd16726df..eb595db96f4679229f20818521112c2a48eded8b 100644
--- a/include/gpu/GrTestUtils.h
+++ b/include/gpu/GrTestUtils.h
@@ -13,10 +13,13 @@
#ifdef GR_TEST_UTILS
#include "GrColor.h"
+#include "SkDashPathPriv.h"
+#include "SkPathEffect.h"
#include "SkRandom.h"
#include "SkStrokeRec.h"
+#include "SkTemplates.h"
-class GrStrokeInfo;
+class GrStyle;
class SkMatrix;
class SkPath;
class SkRRect;
@@ -24,7 +27,7 @@ struct SkRect;
namespace GrTest {
/**
- * A helper for use in Test functions.
+ * Helpers for use in Test functions.
*/
const SkMatrix& TestMatrix(SkRandom*);
const SkMatrix& TestMatrixPreservesRightAngles(SkRandom*);
@@ -36,9 +39,55 @@ const SkRRect& TestRRectSimple(SkRandom*);
const SkPath& TestPath(SkRandom*);
const SkPath& TestPathConvex(SkRandom*);
SkStrokeRec TestStrokeRec(SkRandom*);
-GrStrokeInfo TestStrokeInfo(SkRandom*);
+/** Creates styles with dash path effects and null path effects */
+void TestStyle(SkRandom*, GrStyle*);
robertphillips 2016/05/09 20:05:28 Can this class go in the .cpp file ?
bsalomon 2016/05/09 20:38:55 It's also used by GrDashingEffect's test function.
-}
+// We have a simplified dash path effect here to avoid relying on SkDashPathEffect which
+// is in the optional build target effects.
+class TestDashPathEffect : public SkPathEffect {
+public:
+ static sk_sp<SkPathEffect> Make(const SkScalar* intervals, int count, SkScalar phase) {
+ return sk_sp<SkPathEffect>(new TestDashPathEffect(intervals, count, phase));
+ }
+
+ bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+ const SkRect* cullRect) const override {
+ return SkDashPath::InternalFilter(dst, src, rec, cullRect, fIntervals.get(), fCount,
+ fInitialDashLength, fInitialDashIndex, fIntervalLength);
+ }
+
+ DashType asADash(DashInfo* info) const override {
+ 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;
+ }
+
+ Factory getFactory() const override { return nullptr; }
+ void toString(SkString*) const override {}
+
+private:
+ 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);
+ }
+
+ int fCount;
+ SkAutoTArray<SkScalar> fIntervals;
+ SkScalar fPhase;
+ SkScalar fInitialDashLength;
+ int fInitialDashIndex;
+ SkScalar fIntervalLength;
+};
+
+} // namespace GrTest
static inline GrColor GrRandomColor(SkRandom* random) {
// There are only a few cases of random colors which interest us
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/GrBlurUtils.h » ('j') | src/gpu/GrBlurUtils.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698