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