| 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) { | 52 float lum, uint32_t flags, bool usesLocal
Coords) { |
| 53 return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex,
params, lum, | 53 return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex,
params, lum, |
| 54 flags)); | 54 flags, usesLocalCoords)
); |
| 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) { | 59 uint32_t flags, bool usesLocalCoords) { |
| 60 return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex,
params, flags)); | 60 return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex,
params, flags, |
| 61 usesLocalCoords)); |
| 61 } | 62 } |
| 62 #endif | 63 #endif |
| 63 | 64 |
| 64 virtual ~GrDistanceFieldA8TextGeoProc() {} | 65 virtual ~GrDistanceFieldA8TextGeoProc() {} |
| 65 | 66 |
| 66 const char* name() const override { return "DistanceFieldTexture"; } | 67 const char* name() const override { return "DistanceFieldTexture"; } |
| 67 | 68 |
| 68 const Attribute* inPosition() const { return fInPosition; } | 69 const Attribute* inPosition() const { return fInPosition; } |
| 69 const Attribute* inColor() const { return fInColor; } | 70 const Attribute* inColor() const { return fInColor; } |
| 70 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 71 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
| 71 GrColor color() const { return fColor; } | 72 GrColor color() const { return fColor; } |
| 73 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
| 74 bool hasVertexColor() const { return SkToBool(fInColor); } |
| 72 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 75 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 76 bool usesLocalCoords() const { return fUsesLocalCoords; } |
| 73 #ifdef SK_GAMMA_APPLY_TO_A8 | 77 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 74 float getDistanceAdjust() const { return fDistanceAdjust; } | 78 float getDistanceAdjust() const { return fDistanceAdjust; } |
| 75 #endif | 79 #endif |
| 76 uint32_t getFlags() const { return fFlags; } | 80 uint32_t getFlags() const { return fFlags; } |
| 77 | 81 |
| 78 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 82 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 79 const GrGLSLCaps& caps, | 83 const GrGLSLCaps& caps, |
| 80 GrProcessorKeyBuilder* b) const override; | 84 GrProcessorKeyBuilder* b) const override; |
| 81 | 85 |
| 82 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 86 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 83 const GrGLSLCaps&) const ov
erride; | 87 const GrGLSLCaps&) const ov
erride; |
| 84 | 88 |
| 85 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; | |
| 86 | |
| 87 private: | 89 private: |
| 88 GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix, | 90 GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix, |
| 89 GrTexture* texture, const GrTextureParams& para
ms, | 91 GrTexture* texture, const GrTextureParams& para
ms, |
| 90 #ifdef SK_GAMMA_APPLY_TO_A8 | 92 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 91 float distanceAdjust, | 93 float distanceAdjust, |
| 92 #endif | 94 #endif |
| 93 uint32_t flags); | 95 uint32_t flags, bool usesLocalCoords); |
| 94 | 96 |
| 95 GrColor fColor; | 97 GrColor fColor; |
| 96 SkMatrix fViewMatrix; | 98 SkMatrix fViewMatrix; |
| 97 GrTextureAccess fTextureAccess; | 99 GrTextureAccess fTextureAccess; |
| 98 #ifdef SK_GAMMA_APPLY_TO_A8 | 100 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 99 float fDistanceAdjust; | 101 float fDistanceAdjust; |
| 100 #endif | 102 #endif |
| 101 uint32_t fFlags; | 103 uint32_t fFlags; |
| 102 const Attribute* fInPosition; | 104 const Attribute* fInPosition; |
| 103 const Attribute* fInColor; | 105 const Attribute* fInColor; |
| 104 const Attribute* fInTextureCoords; | 106 const Attribute* fInTextureCoords; |
| 107 bool fUsesLocalCoords; |
| 105 | 108 |
| 106 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 109 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 107 | 110 |
| 108 typedef GrGeometryProcessor INHERITED; | 111 typedef GrGeometryProcessor INHERITED; |
| 109 }; | 112 }; |
| 110 | 113 |
| 111 | 114 |
| 112 /** | 115 /** |
| 113 * The output color of this effect is a modulation of the input color and a sampl
e from a | 116 * 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). | 117 * 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 | 118 * 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. | 119 * coords are a custom attribute. No gamma correct blending is applied. Used for
paths only. |
| 117 */ | 120 */ |
| 118 class GrDistanceFieldPathGeoProc : public GrGeometryProcessor { | 121 class GrDistanceFieldPathGeoProc : public GrGeometryProcessor { |
| 119 public: | 122 public: |
| 120 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, GrTexture* tex, | 123 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, GrTexture* tex, |
| 121 const GrTextureParams& params, | 124 const GrTextureParams& params, |
| 122 uint32_t flags) { | 125 uint32_t flags, bool usesLocalCoords) { |
| 123 return SkNEW_ARGS(GrDistanceFieldPathGeoProc, (color, viewMatrix, tex, p
arams, flags)); | 126 return SkNEW_ARGS(GrDistanceFieldPathGeoProc, (color, viewMatrix, tex, p
arams, flags, |
| 127 usesLocalCoords)); |
| 124 } | 128 } |
| 125 | 129 |
| 126 virtual ~GrDistanceFieldPathGeoProc() {} | 130 virtual ~GrDistanceFieldPathGeoProc() {} |
| 127 | 131 |
| 128 const char* name() const override { return "DistanceFieldTexture"; } | 132 const char* name() const override { return "DistanceFieldTexture"; } |
| 129 | 133 |
| 130 const Attribute* inPosition() const { return fInPosition; } | 134 const Attribute* inPosition() const { return fInPosition; } |
| 131 const Attribute* inColor() const { return fInColor; } | 135 const Attribute* inColor() const { return fInColor; } |
| 132 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 136 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
| 133 GrColor color() const { return fColor; } | 137 GrColor color() const { return fColor; } |
| 138 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
| 139 bool hasVertexColor() const { return SkToBool(fInColor); } |
| 134 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 140 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 135 uint32_t getFlags() const { return fFlags; } | 141 uint32_t getFlags() const { return fFlags; } |
| 142 bool usesLocalCoords() const { return fUsesLocalCoords; } |
| 136 | 143 |
| 137 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 144 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 138 const GrGLSLCaps& caps, | 145 const GrGLSLCaps& caps, |
| 139 GrProcessorKeyBuilder* b) const override; | 146 GrProcessorKeyBuilder* b) const override; |
| 140 | 147 |
| 141 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 148 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 142 const GrGLSLCaps&) const ov
erride; | 149 const GrGLSLCaps&) const ov
erride; |
| 143 | 150 |
| 144 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; | |
| 145 | |
| 146 private: | 151 private: |
| 147 GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, GrTexture* t
exture, | 152 GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, GrTexture* t
exture, |
| 148 const GrTextureParams& params, uint32_t flags); | 153 const GrTextureParams& params, uint32_t flags, |
| 154 bool usesLocalCoords); |
| 149 | 155 |
| 150 GrColor fColor; | 156 GrColor fColor; |
| 151 SkMatrix fViewMatrix; | 157 SkMatrix fViewMatrix; |
| 152 GrTextureAccess fTextureAccess; | 158 GrTextureAccess fTextureAccess; |
| 153 uint32_t fFlags; | 159 uint32_t fFlags; |
| 154 const Attribute* fInPosition; | 160 const Attribute* fInPosition; |
| 155 const Attribute* fInColor; | 161 const Attribute* fInColor; |
| 156 const Attribute* fInTextureCoords; | 162 const Attribute* fInTextureCoords; |
| 163 bool fUsesLocalCoords; |
| 157 | 164 |
| 158 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 165 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 159 | 166 |
| 160 typedef GrGeometryProcessor INHERITED; | 167 typedef GrGeometryProcessor INHERITED; |
| 161 }; | 168 }; |
| 162 | 169 |
| 163 /** | 170 /** |
| 164 * The output color of this effect is a modulation of the input color and sample
s from a | 171 * The output color of this effect is a modulation of the input color and sample
s from a |
| 165 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. | 172 * distance field texture (using a smoothed step function near 0.5), adjusted fo
r LCD displays. |
| 166 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input | 173 * It allows explicit specification of the filtering and wrap modes (GrTexturePa
rams). The input |
| (...skipping 11 matching lines...) Expand all Loading... |
| 178 bool operator==(const DistanceAdjust& wa) const { | 185 bool operator==(const DistanceAdjust& wa) const { |
| 179 return (fR == wa.fR && fG == wa.fG && fB == wa.fB); | 186 return (fR == wa.fR && fG == wa.fG && fB == wa.fB); |
| 180 } | 187 } |
| 181 bool operator!=(const DistanceAdjust& wa) const { | 188 bool operator!=(const DistanceAdjust& wa) const { |
| 182 return !(*this == wa); | 189 return !(*this == wa); |
| 183 } | 190 } |
| 184 }; | 191 }; |
| 185 | 192 |
| 186 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, | 193 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix
, |
| 187 GrTexture* tex, const GrTextureParams& pa
rams, | 194 GrTexture* tex, const GrTextureParams& pa
rams, |
| 188 DistanceAdjust distanceAdjust, uint32_t f
lags) { | 195 DistanceAdjust distanceAdjust, uint32_t f
lags, |
| 196 bool usesLocalCoords) { |
| 189 return SkNEW_ARGS(GrDistanceFieldLCDTextGeoProc, | 197 return SkNEW_ARGS(GrDistanceFieldLCDTextGeoProc, |
| 190 (color, viewMatrix, tex, params, distanceAdjust, flags
)); | 198 (color, viewMatrix, tex, params, distanceAdjust, flags
, usesLocalCoords)); |
| 191 } | 199 } |
| 192 | 200 |
| 193 virtual ~GrDistanceFieldLCDTextGeoProc() {} | 201 virtual ~GrDistanceFieldLCDTextGeoProc() {} |
| 194 | 202 |
| 195 const char* name() const override { return "DistanceFieldLCDTexture"; } | 203 const char* name() const override { return "DistanceFieldLCDTexture"; } |
| 196 | 204 |
| 197 const Attribute* inPosition() const { return fInPosition; } | 205 const Attribute* inPosition() const { return fInPosition; } |
| 198 const Attribute* inTextureCoords() const { return fInTextureCoords; } | 206 const Attribute* inTextureCoords() const { return fInTextureCoords; } |
| 199 DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; } | 207 DistanceAdjust getDistanceAdjust() const { return fDistanceAdjust; } |
| 200 GrColor color() const { return fColor; } | 208 GrColor color() const { return fColor; } |
| 209 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
| 201 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 210 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 202 uint32_t getFlags() const { return fFlags; } | 211 uint32_t getFlags() const { return fFlags; } |
| 212 bool usesLocalCoords() const { return fUsesLocalCoords; } |
| 203 | 213 |
| 204 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 214 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 205 const GrGLSLCaps& caps, | 215 const GrGLSLCaps& caps, |
| 206 GrProcessorKeyBuilder* b) const override; | 216 GrProcessorKeyBuilder* b) const override; |
| 207 | 217 |
| 208 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 218 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 209 const GrGLSLCaps&) const ov
erride; | 219 const GrGLSLCaps&) const ov
erride; |
| 210 | 220 |
| 211 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override; | |
| 212 | |
| 213 private: | 221 private: |
| 214 GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix, | 222 GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix, |
| 215 GrTexture* texture, const GrTextureParams& par
ams, | 223 GrTexture* texture, const GrTextureParams& par
ams, |
| 216 DistanceAdjust wa, uint32_t flags); | 224 DistanceAdjust wa, uint32_t flags, |
| 225 bool usesLocalCoords); |
| 217 | 226 |
| 218 GrColor fColor; | 227 GrColor fColor; |
| 219 SkMatrix fViewMatrix; | 228 SkMatrix fViewMatrix; |
| 220 GrTextureAccess fTextureAccess; | 229 GrTextureAccess fTextureAccess; |
| 221 DistanceAdjust fDistanceAdjust; | 230 DistanceAdjust fDistanceAdjust; |
| 222 uint32_t fFlags; | 231 uint32_t fFlags; |
| 223 const Attribute* fInPosition; | 232 const Attribute* fInPosition; |
| 224 const Attribute* fInTextureCoords; | 233 const Attribute* fInTextureCoords; |
| 234 bool fUsesLocalCoords; |
| 225 | 235 |
| 226 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 236 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 227 | 237 |
| 228 typedef GrGeometryProcessor INHERITED; | 238 typedef GrGeometryProcessor INHERITED; |
| 229 }; | 239 }; |
| 230 | 240 |
| 231 #endif | 241 #endif |
| OLD | NEW |