| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrBezierEffect_DEFINED | 8 #ifndef GrBezierEffect_DEFINED |
| 9 #define GrBezierEffect_DEFINED | 9 #define GrBezierEffect_DEFINED |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 * chopping to tighten the clipping. Another side effect of the overestimating i
s | 51 * chopping to tighten the clipping. Another side effect of the overestimating i
s |
| 52 * that the curves become much thinner and "ropey". If all that was ever rendere
d | 52 * that the curves become much thinner and "ropey". If all that was ever rendere
d |
| 53 * were "not too thin" curves and ellipses then 2nd order may have an advantage
since | 53 * were "not too thin" curves and ellipses then 2nd order may have an advantage
since |
| 54 * only one geometry would need to be rendered. However no benches were run comp
aring | 54 * only one geometry would need to be rendered. However no benches were run comp
aring |
| 55 * chopped first order and non chopped 2nd order. | 55 * chopped first order and non chopped 2nd order. |
| 56 */ | 56 */ |
| 57 class GrGLConicEffect; | 57 class GrGLConicEffect; |
| 58 | 58 |
| 59 class GrConicEffect : public GrGeometryProcessor { | 59 class GrConicEffect : public GrGeometryProcessor { |
| 60 public: | 60 public: |
| 61 static GrGeometryProcessor* Create(const GrPrimitiveEdgeType edgeType, | 61 static GrGeometryProcessor* Create(GrColor color, |
| 62 const GrDrawTargetCaps& caps) { | 62 const GrPrimitiveEdgeType edgeType, |
| 63 const GrDrawTargetCaps& caps, |
| 64 uint8_t coverage = 0xff) { |
| 63 switch (edgeType) { | 65 switch (edgeType) { |
| 64 case kFillAA_GrProcessorEdgeType: | 66 case kFillAA_GrProcessorEdgeType: |
| 65 if (!caps.shaderDerivativeSupport()) { | 67 if (!caps.shaderDerivativeSupport()) { |
| 66 return NULL; | 68 return NULL; |
| 67 } | 69 } |
| 68 return SkNEW_ARGS(GrConicEffect, (kFillAA_GrProcessorEdgeType)); | 70 return SkNEW_ARGS(GrConicEffect, (color, coverage, kFillAA_GrPro
cessorEdgeType)); |
| 69 case kHairlineAA_GrProcessorEdgeType: | 71 case kHairlineAA_GrProcessorEdgeType: |
| 70 if (!caps.shaderDerivativeSupport()) { | 72 if (!caps.shaderDerivativeSupport()) { |
| 71 return NULL; | 73 return NULL; |
| 72 } | 74 } |
| 73 return SkNEW_ARGS(GrConicEffect, (kHairlineAA_GrProcessorEdgeTyp
e)); | 75 return SkNEW_ARGS(GrConicEffect, (color, coverage, |
| 76 kHairlineAA_GrProcessorEdgeTyp
e)); |
| 74 case kFillBW_GrProcessorEdgeType: | 77 case kFillBW_GrProcessorEdgeType: |
| 75 return SkNEW_ARGS(GrConicEffect, (kFillBW_GrProcessorEdgeType));
; | 78 return SkNEW_ARGS(GrConicEffect, (color, coverage, kFillBW_GrPro
cessorEdgeType));; |
| 76 default: | 79 default: |
| 77 return NULL; | 80 return NULL; |
| 78 } | 81 } |
| 79 } | 82 } |
| 80 | 83 |
| 81 virtual ~GrConicEffect(); | 84 virtual ~GrConicEffect(); |
| 82 | 85 |
| 83 virtual const char* name() const SK_OVERRIDE { return "Conic"; } | 86 virtual const char* name() const SK_OVERRIDE { return "Conic"; } |
| 84 | 87 |
| 85 inline const GrAttribute* inPosition() const { return fInPosition; } | 88 inline const GrAttribute* inPosition() const { return fInPosition; } |
| 86 inline const GrAttribute* inConicCoeffs() const { return fInConicCoeffs; } | 89 inline const GrAttribute* inConicCoeffs() const { return fInConicCoeffs; } |
| 87 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 90 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
| 88 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 91 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
| 89 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 92 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 90 | 93 |
| 91 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 94 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 92 const GrGLCaps& caps, | 95 const GrGLCaps& caps, |
| 93 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 96 GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
| 94 | 97 |
| 95 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; | 98 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 GrConicEffect(GrPrimitiveEdgeType); | 101 GrConicEffect(GrColor, uint8_t coverage, GrPrimitiveEdgeType); |
| 99 | 102 |
| 100 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 103 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
| 101 | 104 |
| 102 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { | 105 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { |
| 103 inout->mulByUnknownAlpha(); | 106 inout->mulByUnknownAlpha(); |
| 104 } | 107 } |
| 105 | 108 |
| 106 GrPrimitiveEdgeType fEdgeType; | 109 GrPrimitiveEdgeType fEdgeType; |
| 107 const GrAttribute* fInPosition; | 110 const GrAttribute* fInPosition; |
| 108 const GrAttribute* fInConicCoeffs; | 111 const GrAttribute* fInConicCoeffs; |
| 109 | 112 |
| 110 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 113 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 111 | 114 |
| 112 typedef GrGeometryProcessor INHERITED; | 115 typedef GrGeometryProcessor INHERITED; |
| 113 }; | 116 }; |
| 114 | 117 |
| 115 /////////////////////////////////////////////////////////////////////////////// | 118 /////////////////////////////////////////////////////////////////////////////// |
| 116 /** | 119 /** |
| 117 * The output of this effect is a hairline edge for quadratics. | 120 * The output of this effect is a hairline edge for quadratics. |
| 118 * Quadratic specified by 0=u^2-v canonical coords. u and v are the first | 121 * Quadratic specified by 0=u^2-v canonical coords. u and v are the first |
| 119 * two components of the vertex attribute. At the three control points that defi
ne | 122 * two components of the vertex attribute. At the three control points that defi
ne |
| 120 * the Quadratic, u, v have the values {0,0}, {1/2, 0}, and {1, 1} respectively. | 123 * the Quadratic, u, v have the values {0,0}, {1/2, 0}, and {1, 1} respectively. |
| 121 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. | 124 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. |
| 122 * Requires shader derivative instruction support. | 125 * Requires shader derivative instruction support. |
| 123 */ | 126 */ |
| 124 class GrGLQuadEffect; | 127 class GrGLQuadEffect; |
| 125 | 128 |
| 126 class GrQuadEffect : public GrGeometryProcessor { | 129 class GrQuadEffect : public GrGeometryProcessor { |
| 127 public: | 130 public: |
| 128 static GrGeometryProcessor* Create(const GrPrimitiveEdgeType edgeType, | 131 static GrGeometryProcessor* Create(GrColor color, |
| 129 const GrDrawTargetCaps& caps) { | 132 const GrPrimitiveEdgeType edgeType, |
| 133 const GrDrawTargetCaps& caps, |
| 134 uint8_t coverage = 0xff) { |
| 130 switch (edgeType) { | 135 switch (edgeType) { |
| 131 case kFillAA_GrProcessorEdgeType: | 136 case kFillAA_GrProcessorEdgeType: |
| 132 if (!caps.shaderDerivativeSupport()) { | 137 if (!caps.shaderDerivativeSupport()) { |
| 133 return NULL; | 138 return NULL; |
| 134 } | 139 } |
| 135 return SkNEW_ARGS(GrQuadEffect, (kFillAA_GrProcessorEdgeType)); | 140 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kFillAA_GrProc
essorEdgeType)); |
| 136 case kHairlineAA_GrProcessorEdgeType: | 141 case kHairlineAA_GrProcessorEdgeType: |
| 137 if (!caps.shaderDerivativeSupport()) { | 142 if (!caps.shaderDerivativeSupport()) { |
| 138 return NULL; | 143 return NULL; |
| 139 } | 144 } |
| 140 return SkNEW_ARGS(GrQuadEffect, (kHairlineAA_GrProcessorEdgeType
)); | 145 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kHairlineAA_Gr
ProcessorEdgeType)); |
| 141 case kFillBW_GrProcessorEdgeType: | 146 case kFillBW_GrProcessorEdgeType: |
| 142 return SkNEW_ARGS(GrQuadEffect, (kFillBW_GrProcessorEdgeType)); | 147 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kFillBW_GrProc
essorEdgeType)); |
| 143 default: | 148 default: |
| 144 return NULL; | 149 return NULL; |
| 145 } | 150 } |
| 146 } | 151 } |
| 147 | 152 |
| 148 virtual ~GrQuadEffect(); | 153 virtual ~GrQuadEffect(); |
| 149 | 154 |
| 150 virtual const char* name() const SK_OVERRIDE { return "Quad"; } | 155 virtual const char* name() const SK_OVERRIDE { return "Quad"; } |
| 151 | 156 |
| 152 inline const GrAttribute* inPosition() const { return fInPosition; } | 157 inline const GrAttribute* inPosition() const { return fInPosition; } |
| 153 inline const GrAttribute* inHairQuadEdge() const { return fInHairQuadEdge; } | 158 inline const GrAttribute* inHairQuadEdge() const { return fInHairQuadEdge; } |
| 154 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 159 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
| 155 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 160 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
| 156 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 161 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 157 | 162 |
| 158 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 163 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 159 const GrGLCaps& caps, | 164 const GrGLCaps& caps, |
| 160 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 165 GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
| 161 | 166 |
| 162 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; | 167 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; |
| 163 | 168 |
| 164 private: | 169 private: |
| 165 GrQuadEffect(GrPrimitiveEdgeType); | 170 GrQuadEffect(GrColor, uint8_t coverage, GrPrimitiveEdgeType); |
| 166 | 171 |
| 167 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 172 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
| 168 | 173 |
| 169 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { | 174 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { |
| 170 inout->mulByUnknownAlpha(); | 175 inout->mulByUnknownAlpha(); |
| 171 } | 176 } |
| 172 | 177 |
| 173 GrPrimitiveEdgeType fEdgeType; | 178 GrPrimitiveEdgeType fEdgeType; |
| 174 const GrAttribute* fInPosition; | 179 const GrAttribute* fInPosition; |
| 175 const GrAttribute* fInHairQuadEdge; | 180 const GrAttribute* fInHairQuadEdge; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 187 * Cubics are specified by implicit equation K^3 - LM. | 192 * Cubics are specified by implicit equation K^3 - LM. |
| 188 * K, L, and M, are the first three values of the vertex attribute, | 193 * K, L, and M, are the first three values of the vertex attribute, |
| 189 * the fourth value is not used. Distance is calculated using a | 194 * the fourth value is not used. Distance is calculated using a |
| 190 * first order approximation from the taylor series. | 195 * first order approximation from the taylor series. |
| 191 * Coverage for AA is max(0, 1-distance). | 196 * Coverage for AA is max(0, 1-distance). |
| 192 */ | 197 */ |
| 193 class GrGLCubicEffect; | 198 class GrGLCubicEffect; |
| 194 | 199 |
| 195 class GrCubicEffect : public GrGeometryProcessor { | 200 class GrCubicEffect : public GrGeometryProcessor { |
| 196 public: | 201 public: |
| 197 static GrGeometryProcessor* Create(const GrPrimitiveEdgeType edgeType, | 202 static GrGeometryProcessor* Create(GrColor color, |
| 203 const GrPrimitiveEdgeType edgeType, |
| 198 const GrDrawTargetCaps& caps) { | 204 const GrDrawTargetCaps& caps) { |
| 199 switch (edgeType) { | 205 switch (edgeType) { |
| 200 case kFillAA_GrProcessorEdgeType: | 206 case kFillAA_GrProcessorEdgeType: |
| 201 if (!caps.shaderDerivativeSupport()) { | 207 if (!caps.shaderDerivativeSupport()) { |
| 202 return NULL; | 208 return NULL; |
| 203 } | 209 } |
| 204 return SkNEW_ARGS(GrCubicEffect, (kFillAA_GrProcessorEdgeType)); | 210 return SkNEW_ARGS(GrCubicEffect, (color, kFillAA_GrProcessorEdge
Type)); |
| 205 case kHairlineAA_GrProcessorEdgeType: | 211 case kHairlineAA_GrProcessorEdgeType: |
| 206 if (!caps.shaderDerivativeSupport()) { | 212 if (!caps.shaderDerivativeSupport()) { |
| 207 return NULL; | 213 return NULL; |
| 208 } | 214 } |
| 209 return SkNEW_ARGS(GrCubicEffect, (kHairlineAA_GrProcessorEdgeTyp
e)); | 215 return SkNEW_ARGS(GrCubicEffect, (color, kHairlineAA_GrProcessor
EdgeType)); |
| 210 case kFillBW_GrProcessorEdgeType: | 216 case kFillBW_GrProcessorEdgeType: |
| 211 return SkNEW_ARGS(GrCubicEffect, (kFillBW_GrProcessorEdgeType)); | 217 return SkNEW_ARGS(GrCubicEffect, (color, kFillBW_GrProcessorEdge
Type)); |
| 212 default: | 218 default: |
| 213 return NULL; | 219 return NULL; |
| 214 } | 220 } |
| 215 } | 221 } |
| 216 | 222 |
| 217 virtual ~GrCubicEffect(); | 223 virtual ~GrCubicEffect(); |
| 218 | 224 |
| 219 virtual const char* name() const SK_OVERRIDE { return "Cubic"; } | 225 virtual const char* name() const SK_OVERRIDE { return "Cubic"; } |
| 220 | 226 |
| 221 inline const GrAttribute* inPosition() const { return fInPosition; } | 227 inline const GrAttribute* inPosition() const { return fInPosition; } |
| 222 inline const GrAttribute* inCubicCoeffs() const { return fInCubicCoeffs; } | 228 inline const GrAttribute* inCubicCoeffs() const { return fInCubicCoeffs; } |
| 223 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 229 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
| 224 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 230 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
| 225 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 231 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 226 | 232 |
| 227 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 233 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 228 const GrGLCaps& caps, | 234 const GrGLCaps& caps, |
| 229 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 235 GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
| 230 | 236 |
| 231 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; | 237 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; |
| 232 | 238 |
| 233 private: | 239 private: |
| 234 GrCubicEffect(GrPrimitiveEdgeType); | 240 GrCubicEffect(GrColor, GrPrimitiveEdgeType); |
| 235 | 241 |
| 236 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 242 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
| 237 | 243 |
| 238 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { | 244 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE { |
| 239 inout->mulByUnknownAlpha(); | 245 inout->mulByUnknownAlpha(); |
| 240 } | 246 } |
| 241 | 247 |
| 242 GrPrimitiveEdgeType fEdgeType; | 248 GrPrimitiveEdgeType fEdgeType; |
| 243 const GrAttribute* fInPosition; | 249 const GrAttribute* fInPosition; |
| 244 const GrAttribute* fInCubicCoeffs; | 250 const GrAttribute* fInCubicCoeffs; |
| 245 | 251 |
| 246 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 252 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 247 | 253 |
| 248 typedef GrGeometryProcessor INHERITED; | 254 typedef GrGeometryProcessor INHERITED; |
| 249 }; | 255 }; |
| 250 | 256 |
| 251 #endif | 257 #endif |
| OLD | NEW |