| 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 GrDistanceFieldGeoProc_DEFINED | 8 #ifndef GrDistanceFieldGeoProc_DEFINED |
| 9 #define GrDistanceFieldGeoProc_DEFINED | 9 #define GrDistanceFieldGeoProc_DEFINED |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 * The output color of this effect is a modulation of the input color and a samp
le from a | 42 * The output color of this effect is a modulation of the input color and a samp
le from a |
| 43 * distance field texture (using a smoothed step function near 0.5). | 43 * distance field texture (using a smoothed step function near 0.5). |
| 44 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input | 44 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input |
| 45 * coords are a custom attribute. Gamma correction is handled via a texture LUT. | 45 * coords are a custom attribute. Gamma correction is handled via a texture LUT. |
| 46 */ | 46 */ |
| 47 class GrDistanceFieldA8TextGeoProc : public GrGeometryProcessor { | 47 class GrDistanceFieldA8TextGeoProc : public GrGeometryProcessor { |
| 48 public: | 48 public: |
| 49 #ifdef SK_GAMMA_APPLY_TO_A8 | 49 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 50 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, | 50 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, |
| 51 GrTexture* tex, const GrTextureParams& pa
rams, | 51 GrTexture* tex, const GrTextureParams& pa
rams, |
| 52 float lum, uint32_t flags, bool usesLocal
Coords) { | 52 float lum, uint32_t flags, bool usesLocal
Coords, GrRenderTarget* dst) { |
| 53 return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params,
lum, flags, | 53 return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params,
lum, flags, |
| 54 usesLocalCoords); | 54 usesLocalCoords, dst); |
| 55 } | 55 } |
| 56 #else | 56 #else |
| 57 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, | 57 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, |
| 58 GrTexture* tex, const GrTextureParams& pa
rams, | 58 GrTexture* tex, const GrTextureParams& pa
rams, |
| 59 uint32_t flags, bool usesLocalCoords) { | 59 uint32_t flags, bool usesLocalCoords) { |
| 60 return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params,
flags, | 60 return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params,
flags, |
| 61 usesLocalCoords); | 61 usesLocalCoords); |
| 62 } | 62 } |
| 63 #endif | 63 #endif |
| 64 | 64 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 82 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override; | 82 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override; |
| 83 | 83 |
| 84 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override; | 84 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override; |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix, | 87 GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix, |
| 88 GrTexture* texture, const GrTextureParams& para
ms, | 88 GrTexture* texture, const GrTextureParams& para
ms, |
| 89 #ifdef SK_GAMMA_APPLY_TO_A8 | 89 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 90 float distanceAdjust, | 90 float distanceAdjust, |
| 91 #endif | 91 #endif |
| 92 uint32_t flags, bool usesLocalCoords); | 92 uint32_t flags, bool usesLocalCoords, GrRenderT
arget* dst); |
| 93 | 93 |
| 94 GrColor fColor; | 94 GrColor fColor; |
| 95 SkMatrix fViewMatrix; | 95 SkMatrix fViewMatrix; |
| 96 GrTextureAccess fTextureAccess; | 96 GrTextureAccess fTextureAccess; |
| 97 #ifdef SK_GAMMA_APPLY_TO_A8 | 97 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 98 float fDistanceAdjust; | 98 float fDistanceAdjust; |
| 99 #endif | 99 #endif |
| 100 uint32_t fFlags; | 100 uint32_t fFlags; |
| 101 const Attribute* fInPosition; | 101 const Attribute* fInPosition; |
| 102 const Attribute* fInColor; | 102 const Attribute* fInColor; |
| 103 const Attribute* fInTextureCoords; | 103 const Attribute* fInTextureCoords; |
| 104 bool fUsesLocalCoords; | 104 bool fUsesLocalCoords; |
| 105 | 105 |
| 106 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 106 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 107 | 107 |
| 108 typedef GrGeometryProcessor INHERITED; | 108 typedef GrGeometryProcessor INHERITED; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 | 111 |
| 112 /** | 112 /** |
| 113 * The output color of this effect is a modulation of the input color and a sampl
e from a | 113 * The output color of this effect is a modulation of the input color and a sampl
e from a |
| 114 * distance field texture (using a smoothed step function near 0.5). | 114 * distance field texture (using a smoothed step function near 0.5). |
| 115 * It allows explicit specification of the filtering and wrap modes (GrTexturePar
ams). The input | 115 * It allows explicit specification of the filtering and wrap modes (GrTexturePar
ams). The input |
| 116 * coords are a custom attribute. No gamma correct blending is applied. Used for
paths only. | 116 * coords are a custom attribute. No gamma correct blending is applied. Used for
paths only. |
| 117 */ | 117 */ |
| 118 class GrDistanceFieldPathGeoProc : public GrGeometryProcessor { | 118 class GrDistanceFieldPathGeoProc : public GrGeometryProcessor { |
| 119 public: | 119 public: |
| 120 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, GrTexture* tex, | 120 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, GrTexture* tex, |
| 121 const GrTextureParams& params, | 121 const GrTextureParams& params, |
| 122 uint32_t flags, bool usesLocalCoords) { | 122 uint32_t flags, bool usesLocalCoords, GrR
enderTarget* dst) { |
| 123 return new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, fl
ags, | 123 return new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, fl
ags, |
| 124 usesLocalCoords); | 124 usesLocalCoords, dst); |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual ~GrDistanceFieldPathGeoProc() {} | 127 virtual ~GrDistanceFieldPathGeoProc() {} |
| 128 | 128 |
| 129 const char* name() const override { return "DistanceFieldTexture"; } | 129 const char* name() const override { return "DistanceFieldTexture"; } |
| 130 | 130 |
| 131 const Attribute* inPosition() const { return fInPosition; } | 131 const Attribute* inPosition() const { return fInPosition; } |
| 132 const Attribute* inColor() const { return fInColor; } | 132 const Attribute* inColor() const { return fInColor; } |
| 133 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 133 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
| 134 GrColor color() const { return fColor; } | 134 GrColor color() const { return fColor; } |
| 135 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 135 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
| 136 bool hasVertexColor() const { return SkToBool(fInColor); } | 136 bool hasVertexColor() const { return SkToBool(fInColor); } |
| 137 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 137 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 138 uint32_t getFlags() const { return fFlags; } | 138 uint32_t getFlags() const { return fFlags; } |
| 139 bool usesLocalCoords() const { return fUsesLocalCoords; } | 139 bool usesLocalCoords() const { return fUsesLocalCoords; } |
| 140 | 140 |
| 141 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override; | 141 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override; |
| 142 | 142 |
| 143 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override; | 143 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override; |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, GrTexture* t
exture, | 146 GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, GrTexture* t
exture, |
| 147 const GrTextureParams& params, uint32_t flags, | 147 const GrTextureParams& params, uint32_t flags, |
| 148 bool usesLocalCoords); | 148 bool usesLocalCoords, GrRenderTarget* dst); |
| 149 | 149 |
| 150 GrColor fColor; | 150 GrColor fColor; |
| 151 SkMatrix fViewMatrix; | 151 SkMatrix fViewMatrix; |
| 152 GrTextureAccess fTextureAccess; | 152 GrTextureAccess fTextureAccess; |
| 153 uint32_t fFlags; | 153 uint32_t fFlags; |
| 154 const Attribute* fInPosition; | 154 const Attribute* fInPosition; |
| 155 const Attribute* fInColor; | 155 const Attribute* fInColor; |
| 156 const Attribute* fInTextureCoords; | 156 const Attribute* fInTextureCoords; |
| 157 bool fUsesLocalCoords; | 157 bool fUsesLocalCoords; |
| 158 | 158 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 180 return (fR == wa.fR && fG == wa.fG && fB == wa.fB); | 180 return (fR == wa.fR && fG == wa.fG && fB == wa.fB); |
| 181 } | 181 } |
| 182 bool operator!=(const DistanceAdjust& wa) const { | 182 bool operator!=(const DistanceAdjust& wa) const { |
| 183 return !(*this == wa); | 183 return !(*this == wa); |
| 184 } | 184 } |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, | 187 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, |
| 188 GrTexture* tex, const GrTextureParams& pa
rams, | 188 GrTexture* tex, const GrTextureParams& pa
rams, |
| 189 DistanceAdjust distanceAdjust, uint32_t f
lags, | 189 DistanceAdjust distanceAdjust, uint32_t f
lags, |
| 190 bool usesLocalCoords) { | 190 bool usesLocalCoords, GrRenderTarget* dst
) { |
| 191 return new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params,
distanceAdjust, | 191 return new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params,
distanceAdjust, |
| 192 flags, usesLocalCoords); | 192 flags, usesLocalCoords, dst); |
| 193 } | 193 } |
| 194 | 194 |
| 195 virtual ~GrDistanceFieldLCDTextGeoProc() {} | 195 virtual ~GrDistanceFieldLCDTextGeoProc() {} |
| 196 | 196 |
| 197 const char* name() const override { return "DistanceFieldLCDTexture"; } | 197 const char* name() const override { return "DistanceFieldLCDTexture"; } |
| 198 | 198 |
| 199 const Attribute* inPosition() const { return fInPosition; } | 199 const Attribute* inPosition() const { return fInPosition; } |
| 200 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 200 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
| 201 DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; } | 201 DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; } |
| 202 GrColor color() const { return fColor; } | 202 GrColor color() const { return fColor; } |
| 203 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 203 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
| 204 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 204 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 205 uint32_t getFlags() const { return fFlags; } | 205 uint32_t getFlags() const { return fFlags; } |
| 206 bool usesLocalCoords() const { return fUsesLocalCoords; } | 206 bool usesLocalCoords() const { return fUsesLocalCoords; } |
| 207 | 207 |
| 208 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override; | 208 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override; |
| 209 | 209 |
| 210 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override; | 210 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override; |
| 211 | 211 |
| 212 private: | 212 private: |
| 213 GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix, | 213 GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix, |
| 214 GrTexture* texture, const GrTextureParams& par
ams, | 214 GrTexture* texture, const GrTextureParams& par
ams, |
| 215 DistanceAdjust wa, uint32_t flags, | 215 DistanceAdjust wa, uint32_t flags, |
| 216 bool usesLocalCoords); | 216 bool usesLocalCoords, GrRenderTarget* dst); |
| 217 | 217 |
| 218 GrColor fColor; | 218 GrColor fColor; |
| 219 SkMatrix fViewMatrix; | 219 SkMatrix fViewMatrix; |
| 220 GrTextureAccess fTextureAccess; | 220 GrTextureAccess fTextureAccess; |
| 221 DistanceAdjust fDistanceAdjust; | 221 DistanceAdjust fDistanceAdjust; |
| 222 uint32_t fFlags; | 222 uint32_t fFlags; |
| 223 const Attribute* fInPosition; | 223 const Attribute* fInPosition; |
| 224 const Attribute* fInTextureCoords; | 224 const Attribute* fInTextureCoords; |
| 225 bool fUsesLocalCoords; | 225 bool fUsesLocalCoords; |
| 226 | 226 |
| 227 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 227 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 228 | 228 |
| 229 typedef GrGeometryProcessor INHERITED; | 229 typedef GrGeometryProcessor INHERITED; |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 #endif | 232 #endif |
| OLD | NEW |