Index: src/gpu/effects/GrDashingEffect.h |
diff --git a/src/gpu/effects/GrDashingEffect.h b/src/gpu/effects/GrDashingEffect.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..129c78491d64aeb4d21c662014eb0d79738dce29 |
--- /dev/null |
+++ b/src/gpu/effects/GrDashingEffect.h |
@@ -0,0 +1,75 @@ |
+ |
+/* |
+ * Copyright 2014 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#ifndef GrDashingEffect_DEFINED |
+#define GrDashingEffect_DEFINED |
+ |
+#include "GrCoordTransform.h" |
+#include "GrDrawTargetCaps.h" |
+#include "GrEffect.h" |
+#include "GrTypesPriv.h" |
+#include "SkPathEffect.h" |
+ |
+class GrGLDashingEffect; |
+class SkPath; |
+ |
+/** |
+ * An effect that renders a dashed line. It is intended to be used as a coverage effect. |
+ * The effect is meant for dashed lines that only have a single on/off interval pair. |
+ * Bounding geometry is rendered and the effect computes coverage based on the fragment's |
+ * position relative to the dashed line. |
+ */ |
+ |
+class GrDashingEffect : public GrEffect { |
+public: |
+ typedef SkPathEffect::DashInfo DashInfo; |
+ |
+ /** |
+ * The effect calculates the coverage for the case of a horizontal line in device space. |
+ * The matrix that is passed in should be able to convert a line in source space to a |
+ * horizontal line in device space. Additionally, the coord transform matrix should translate |
+ * the the start of line to origin, and the shift it along the positive x-axis by the phase |
+ * and half the off interval. |
+ */ |
+ static GrEffectRef* Create(GrEffectEdgeType edgeType, const DashInfo& info, |
+ const SkMatrix& matrix, SkScalar strokeWidth); |
+ |
+ virtual ~GrDashingEffect(); |
+ |
+ static const char* Name() { return "DashingEffect"; } |
+ |
+ GrEffectEdgeType getEdgeType() const { return fEdgeType; } |
+ |
+ const SkRect& getRect() const { return fRect; } |
+ |
+ const SkScalar& getIntervalLength() const { return fIntervalLength; } |
+ |
+ typedef GrGLDashingEffect GLEffect; |
+ |
+ virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; |
+ |
+ virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
+ |
+private: |
+ GrDashingEffect(GrEffectEdgeType edgeType, const DashInfo& info, const SkMatrix& matrix, |
+ SkScalar strokeWidth); |
+ |
+ virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
+ |
+ GrEffectEdgeType fEdgeType; |
+ GrCoordTransform fCoordTransform; |
+ SkRect fRect; |
+ SkScalar fIntervalLength; |
+ |
+ GR_DECLARE_EFFECT_TEST; |
+ |
+ typedef GrEffect INHERITED; |
+}; |
+ |
+ |
+#endif |