OLD | NEW |
(Empty) | |
| 1 |
| 2 /* |
| 3 * Copyright 2014 Google Inc. |
| 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. |
| 7 */ |
| 8 |
| 9 #ifndef GrDashingEffect_DEFINED |
| 10 #define GrDashingEffect_DEFINED |
| 11 |
| 12 #include "GrCoordTransform.h" |
| 13 #include "GrDrawTargetCaps.h" |
| 14 #include "GrEffect.h" |
| 15 #include "GrTypesPriv.h" |
| 16 #include "SkPathEffect.h" |
| 17 |
| 18 class GrGLDashingEffect; |
| 19 class SkPath; |
| 20 |
| 21 /** |
| 22 * An effect that renders a dashed line. It is intended to be used as a coverage
effect. |
| 23 * The effect is meant for dashed lines that only have a single on/off interval
pair. |
| 24 * Bounding geometry is rendered and the effect computes coverage based on the f
ragment's |
| 25 * position relative to the dashed line. |
| 26 */ |
| 27 |
| 28 class GrDashingEffect : public GrEffect { |
| 29 public: |
| 30 typedef SkPathEffect::DashInfo DashInfo; |
| 31 |
| 32 /** |
| 33 * The effect calculates the coverage for the case of a horizontal line in d
evice space. |
| 34 * The matrix that is passed in should be able to convert a line in source s
pace to a |
| 35 * horizontal line in device space. Additionally, the coord transform matrix
should translate |
| 36 * the the start of line to origin, and the shift it along the positive x-ax
is by the phase |
| 37 * and half the off interval. |
| 38 */ |
| 39 static GrEffectRef* Create(GrEffectEdgeType edgeType, const DashInfo& info, |
| 40 const SkMatrix& matrix, SkScalar strokeWidth); |
| 41 |
| 42 virtual ~GrDashingEffect(); |
| 43 |
| 44 static const char* Name() { return "DashingEffect"; } |
| 45 |
| 46 GrEffectEdgeType getEdgeType() const { return fEdgeType; } |
| 47 |
| 48 const SkRect& getRect() const { return fRect; } |
| 49 |
| 50 const SkScalar& getIntervalLength() const { return fIntervalLength; } |
| 51 |
| 52 typedef GrGLDashingEffect GLEffect; |
| 53 |
| 54 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
| 55 |
| 56 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
| 57 |
| 58 private: |
| 59 GrDashingEffect(GrEffectEdgeType edgeType, const DashInfo& info, const SkMat
rix& matrix, |
| 60 SkScalar strokeWidth); |
| 61 |
| 62 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
| 63 |
| 64 GrEffectEdgeType fEdgeType; |
| 65 GrCoordTransform fCoordTransform; |
| 66 SkRect fRect; |
| 67 SkScalar fIntervalLength; |
| 68 |
| 69 GR_DECLARE_EFFECT_TEST; |
| 70 |
| 71 typedef GrEffect INHERITED; |
| 72 }; |
| 73 |
| 74 |
| 75 #endif |
OLD | NEW |