Index: include/gpu/GrTestUtils.h |
diff --git a/include/gpu/GrTestUtils.h b/include/gpu/GrTestUtils.h |
index 475e38a6a11d50034aebaf1145973dbfd16726df..caaf5d978560ebfb9c67143f6078fc827435ed8b 100644 |
--- a/include/gpu/GrTestUtils.h |
+++ b/include/gpu/GrTestUtils.h |
@@ -13,10 +13,12 @@ |
#ifdef GR_TEST_UTILS |
#include "GrColor.h" |
+#include "SkPathEffect.h" |
#include "SkRandom.h" |
#include "SkStrokeRec.h" |
+#include "../private/SkTemplates.h" |
-class GrStrokeInfo; |
+class GrStyle; |
class SkMatrix; |
class SkPath; |
class SkRRect; |
@@ -24,7 +26,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 +38,34 @@ 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*); |
-} |
+// 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&, SkStrokeRec* , const SkRect*) const override; |
+ DashType asADash(DashInfo* info) const override; |
+ Factory getFactory() const override { return nullptr; } |
+ void toString(SkString*) const override {} |
+ |
+private: |
+ TestDashPathEffect(const SkScalar* intervals, int count, SkScalar phase); |
+ |
+ 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 |