| 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 |
| 11 #include "GrDrawTargetCaps.h" |
| 11 #include "GrEffect.h" | 12 #include "GrEffect.h" |
| 12 #include "GrDrawTargetCaps.h" | 13 #include "GrVertexEffect.h" |
| 13 | 14 |
| 14 enum GrBezierEdgeType { | 15 enum GrBezierEdgeType { |
| 15 kFillAA_GrBezierEdgeType, | 16 kFillAA_GrBezierEdgeType, |
| 16 kHairAA_GrBezierEdgeType, | 17 kHairAA_GrBezierEdgeType, |
| 17 kFillNoAA_GrBezierEdgeType, | 18 kFillNoAA_GrBezierEdgeType, |
| 18 }; | 19 }; |
| 19 | 20 |
| 20 static inline bool GrBezierEdgeTypeIsFill(const GrBezierEdgeType edgeType) { | 21 static inline bool GrBezierEdgeTypeIsFill(const GrBezierEdgeType edgeType) { |
| 21 return (kHairAA_GrBezierEdgeType != edgeType); | 22 return (kHairAA_GrBezierEdgeType != edgeType); |
| 22 } | 23 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 * looking for. It is able to render ellipses (even thin ones) without the need
to chop. | 61 * looking for. It is able to render ellipses (even thin ones) without the need
to chop. |
| 61 * However, it can not handle thin hyperbolas well and thus would still rely on | 62 * However, it can not handle thin hyperbolas well and thus would still rely on |
| 62 * chopping to tighten the clipping. Another side effect of the overestimating i
s | 63 * chopping to tighten the clipping. Another side effect of the overestimating i
s |
| 63 * that the curves become much thinner and "ropey". If all that was ever rendere
d | 64 * that the curves become much thinner and "ropey". If all that was ever rendere
d |
| 64 * were "not too thin" curves and ellipses then 2nd order may have an advantage
since | 65 * were "not too thin" curves and ellipses then 2nd order may have an advantage
since |
| 65 * only one geometry would need to be rendered. However no benches were run comp
aring | 66 * only one geometry would need to be rendered. However no benches were run comp
aring |
| 66 * chopped first order and non chopped 2nd order. | 67 * chopped first order and non chopped 2nd order. |
| 67 */ | 68 */ |
| 68 class GrGLConicEffect; | 69 class GrGLConicEffect; |
| 69 | 70 |
| 70 class GrConicEffect : public GrEffect { | 71 class GrConicEffect : public GrVertexEffect { |
| 71 public: | 72 public: |
| 72 static GrEffectRef* Create(const GrBezierEdgeType edgeType, const GrDrawTarg
etCaps& caps) { | 73 static GrEffectRef* Create(const GrBezierEdgeType edgeType, const GrDrawTarg
etCaps& caps) { |
| 73 GR_CREATE_STATIC_EFFECT(gConicFillAA, GrConicEffect, (kFillAA_GrBezierEd
geType)); | 74 GR_CREATE_STATIC_EFFECT(gConicFillAA, GrConicEffect, (kFillAA_GrBezierEd
geType)); |
| 74 GR_CREATE_STATIC_EFFECT(gConicHairAA, GrConicEffect, (kHairAA_GrBezierEd
geType)); | 75 GR_CREATE_STATIC_EFFECT(gConicHairAA, GrConicEffect, (kHairAA_GrBezierEd
geType)); |
| 75 GR_CREATE_STATIC_EFFECT(gConicFillNoAA, GrConicEffect, (kFillNoAA_GrBezi
erEdgeType)); | 76 GR_CREATE_STATIC_EFFECT(gConicFillNoAA, GrConicEffect, (kFillNoAA_GrBezi
erEdgeType)); |
| 76 if (kFillAA_GrBezierEdgeType == edgeType) { | 77 if (kFillAA_GrBezierEdgeType == edgeType) { |
| 77 if (!caps.shaderDerivativeSupport()) { | 78 if (!caps.shaderDerivativeSupport()) { |
| 78 return NULL; | 79 return NULL; |
| 79 } | 80 } |
| 80 gConicFillAA->ref(); | 81 gConicFillAA->ref(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 110 | 111 |
| 111 private: | 112 private: |
| 112 GrConicEffect(GrBezierEdgeType); | 113 GrConicEffect(GrBezierEdgeType); |
| 113 | 114 |
| 114 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; | 115 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
| 115 | 116 |
| 116 GrBezierEdgeType fEdgeType; | 117 GrBezierEdgeType fEdgeType; |
| 117 | 118 |
| 118 GR_DECLARE_EFFECT_TEST; | 119 GR_DECLARE_EFFECT_TEST; |
| 119 | 120 |
| 120 typedef GrEffect INHERITED; | 121 typedef GrVertexEffect INHERITED; |
| 121 }; | 122 }; |
| 122 | 123 |
| 123 /////////////////////////////////////////////////////////////////////////////// | 124 /////////////////////////////////////////////////////////////////////////////// |
| 124 /** | 125 /** |
| 125 * The output of this effect is a hairline edge for quadratics. | 126 * The output of this effect is a hairline edge for quadratics. |
| 126 * Quadratic specified by 0=u^2-v canonical coords. u and v are the first | 127 * Quadratic specified by 0=u^2-v canonical coords. u and v are the first |
| 127 * two components of the vertex attribute. At the three control points that defi
ne | 128 * two components of the vertex attribute. At the three control points that defi
ne |
| 128 * the Quadratic, u, v have the values {0,0}, {1/2, 0}, and {1, 1} respectively. | 129 * the Quadratic, u, v have the values {0,0}, {1/2, 0}, and {1, 1} respectively. |
| 129 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. | 130 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. |
| 130 * Requires shader derivative instruction support. | 131 * Requires shader derivative instruction support. |
| 131 */ | 132 */ |
| 132 class GrGLQuadEffect; | 133 class GrGLQuadEffect; |
| 133 | 134 |
| 134 class GrQuadEffect : public GrEffect { | 135 class GrQuadEffect : public GrVertexEffect { |
| 135 public: | 136 public: |
| 136 static GrEffectRef* Create(const GrBezierEdgeType edgeType, const GrDrawTarg
etCaps& caps) { | 137 static GrEffectRef* Create(const GrBezierEdgeType edgeType, const GrDrawTarg
etCaps& caps) { |
| 137 GR_CREATE_STATIC_EFFECT(gQuadFillAA, GrQuadEffect, (kFillAA_GrBezierEdge
Type)); | 138 GR_CREATE_STATIC_EFFECT(gQuadFillAA, GrQuadEffect, (kFillAA_GrBezierEdge
Type)); |
| 138 GR_CREATE_STATIC_EFFECT(gQuadHairAA, GrQuadEffect, (kHairAA_GrBezierEdge
Type)); | 139 GR_CREATE_STATIC_EFFECT(gQuadHairAA, GrQuadEffect, (kHairAA_GrBezierEdge
Type)); |
| 139 GR_CREATE_STATIC_EFFECT(gQuadFillNoAA, GrQuadEffect, (kFillNoAA_GrBezier
EdgeType)); | 140 GR_CREATE_STATIC_EFFECT(gQuadFillNoAA, GrQuadEffect, (kFillNoAA_GrBezier
EdgeType)); |
| 140 if (kFillAA_GrBezierEdgeType == edgeType) { | 141 if (kFillAA_GrBezierEdgeType == edgeType) { |
| 141 if (!caps.shaderDerivativeSupport()) { | 142 if (!caps.shaderDerivativeSupport()) { |
| 142 return NULL; | 143 return NULL; |
| 143 } | 144 } |
| 144 gQuadFillAA->ref(); | 145 gQuadFillAA->ref(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 174 | 175 |
| 175 private: | 176 private: |
| 176 GrQuadEffect(GrBezierEdgeType); | 177 GrQuadEffect(GrBezierEdgeType); |
| 177 | 178 |
| 178 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; | 179 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
| 179 | 180 |
| 180 GrBezierEdgeType fEdgeType; | 181 GrBezierEdgeType fEdgeType; |
| 181 | 182 |
| 182 GR_DECLARE_EFFECT_TEST; | 183 GR_DECLARE_EFFECT_TEST; |
| 183 | 184 |
| 184 typedef GrEffect INHERITED; | 185 typedef GrVertexEffect INHERITED; |
| 185 }; | 186 }; |
| 186 | 187 |
| 187 ////////////////////////////////////////////////////////////////////////////// | 188 ////////////////////////////////////////////////////////////////////////////// |
| 188 /** | 189 /** |
| 189 * Shader is based off of "Resolution Independent Curve Rendering using | 190 * Shader is based off of "Resolution Independent Curve Rendering using |
| 190 * Programmable Graphics Hardware" by Loop and Blinn. | 191 * Programmable Graphics Hardware" by Loop and Blinn. |
| 191 * The output of this effect is a hairline edge for non rational cubics. | 192 * The output of this effect is a hairline edge for non rational cubics. |
| 192 * Cubics are specified by implicit equation K^3 - LM. | 193 * Cubics are specified by implicit equation K^3 - LM. |
| 193 * K, L, and M, are the first three values of the vertex attribute, | 194 * K, L, and M, are the first three values of the vertex attribute, |
| 194 * the fourth value is not used. Distance is calculated using a | 195 * the fourth value is not used. Distance is calculated using a |
| 195 * first order approximation from the taylor series. | 196 * first order approximation from the taylor series. |
| 196 * Coverage for AA is max(0, 1-distance). | 197 * Coverage for AA is max(0, 1-distance). |
| 197 */ | 198 */ |
| 198 class GrGLCubicEffect; | 199 class GrGLCubicEffect; |
| 199 | 200 |
| 200 class GrCubicEffect : public GrEffect { | 201 class GrCubicEffect : public GrVertexEffect { |
| 201 public: | 202 public: |
| 202 static GrEffectRef* Create(const GrBezierEdgeType edgeType, const GrDrawTarg
etCaps& caps) { | 203 static GrEffectRef* Create(const GrBezierEdgeType edgeType, const GrDrawTarg
etCaps& caps) { |
| 203 GR_CREATE_STATIC_EFFECT(gCubicFillAA, GrCubicEffect, (kFillAA_GrBezierEd
geType)); | 204 GR_CREATE_STATIC_EFFECT(gCubicFillAA, GrCubicEffect, (kFillAA_GrBezierEd
geType)); |
| 204 GR_CREATE_STATIC_EFFECT(gCubicHairAA, GrCubicEffect, (kHairAA_GrBezierEd
geType)); | 205 GR_CREATE_STATIC_EFFECT(gCubicHairAA, GrCubicEffect, (kHairAA_GrBezierEd
geType)); |
| 205 GR_CREATE_STATIC_EFFECT(gCubicFillNoAA, GrCubicEffect, (kFillNoAA_GrBezi
erEdgeType)); | 206 GR_CREATE_STATIC_EFFECT(gCubicFillNoAA, GrCubicEffect, (kFillNoAA_GrBezi
erEdgeType)); |
| 206 if (kFillAA_GrBezierEdgeType == edgeType) { | 207 if (kFillAA_GrBezierEdgeType == edgeType) { |
| 207 if (!caps.shaderDerivativeSupport()) { | 208 if (!caps.shaderDerivativeSupport()) { |
| 208 return NULL; | 209 return NULL; |
| 209 } | 210 } |
| 210 gCubicFillAA->ref(); | 211 gCubicFillAA->ref(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 240 | 241 |
| 241 private: | 242 private: |
| 242 GrCubicEffect(GrBezierEdgeType); | 243 GrCubicEffect(GrBezierEdgeType); |
| 243 | 244 |
| 244 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; | 245 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
| 245 | 246 |
| 246 GrBezierEdgeType fEdgeType; | 247 GrBezierEdgeType fEdgeType; |
| 247 | 248 |
| 248 GR_DECLARE_EFFECT_TEST; | 249 GR_DECLARE_EFFECT_TEST; |
| 249 | 250 |
| 250 typedef GrEffect INHERITED; | 251 typedef GrVertexEffect INHERITED; |
| 251 }; | 252 }; |
| 252 | 253 |
| 253 #endif | 254 #endif |
| OLD | NEW |