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

Unified Diff: src/gpu/effects/GrDashingEffect.h

Issue 274673004: Add Dashing gpu effect for simple dashed lines (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add missing files Created 6 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/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

Powered by Google App Engine
This is Rietveld 408576698