OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrXferProcessor_DEFINED | 8 #ifndef GrXferProcessor_DEFINED |
9 #define GrXferProcessor_DEFINED | 9 #define GrXferProcessor_DEFINED |
10 | 10 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 * its state to reflected the given blend optimizations. If the XP needs to
see a specific input | 138 * its state to reflected the given blend optimizations. If the XP needs to
see a specific input |
139 * color to blend correctly, it will set the OverrideColor flag and the outp
ut parameter | 139 * color to blend correctly, it will set the OverrideColor flag and the outp
ut parameter |
140 * overrideColor will be the required value that should be passed into the X
P. | 140 * overrideColor will be the required value that should be passed into the X
P. |
141 * A caller who calls this function on a XP is required to honor the returne
d OptFlags | 141 * A caller who calls this function on a XP is required to honor the returne
d OptFlags |
142 * and color values for its draw. | 142 * and color values for its draw. |
143 */ | 143 */ |
144 OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 144 OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
145 const GrProcOptInfo& coveragePOI, | 145 const GrProcOptInfo& coveragePOI, |
146 bool doesStencilWrite, | 146 bool doesStencilWrite, |
147 GrColor* overrideColor, | 147 GrColor* overrideColor, |
148 const GrCaps& caps); | 148 const GrCaps& caps) const; |
149 | 149 |
150 /** | 150 /** |
151 * Returns whether this XP will require an Xfer barrier on the given rt. If
true, outBarrierType | 151 * Returns whether this XP will require an Xfer barrier on the given rt. If
true, outBarrierType |
152 * is updated to contain the type of barrier needed. | 152 * is updated to contain the type of barrier needed. |
153 */ | 153 */ |
154 GrXferBarrierType xferBarrierType(const GrRenderTarget* rt, const GrCaps& ca
ps) const; | 154 GrXferBarrierType xferBarrierType(const GrRenderTarget* rt, const GrCaps& ca
ps) const; |
155 | 155 |
156 struct BlendInfo { | 156 struct BlendInfo { |
157 void reset() { | 157 void reset() { |
158 fEquation = kAdd_GrBlendEquation; | 158 fEquation = kAdd_GrBlendEquation; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 192 } |
193 | 193 |
194 /** | 194 /** |
195 * If we are performing a dst read, returns whether the base class will use
mixed samples to | 195 * If we are performing a dst read, returns whether the base class will use
mixed samples to |
196 * antialias the shader's final output. If not doing a dst read, the subclas
s is responsible | 196 * antialias the shader's final output. If not doing a dst read, the subclas
s is responsible |
197 * for antialiasing and this returns false. | 197 * for antialiasing and this returns false. |
198 */ | 198 */ |
199 bool dstReadUsesMixedSamples() const { return fDstReadUsesMixedSamples; } | 199 bool dstReadUsesMixedSamples() const { return fDstReadUsesMixedSamples; } |
200 | 200 |
201 /** | 201 /** |
202 * Returns whether or not the XP will look at coverage when doing its blendi
ng. | |
203 */ | |
204 bool readsCoverage() const { return fReadsCoverage; } | |
205 | |
206 /** | |
207 * Returns whether or not this xferProcossor will set a secondary output to
be used with dual | 202 * Returns whether or not this xferProcossor will set a secondary output to
be used with dual |
208 * source blending. | 203 * source blending. |
209 */ | 204 */ |
210 bool hasSecondaryOutput() const; | 205 bool hasSecondaryOutput() const; |
211 | 206 |
212 /** Returns true if this and other processor conservatively draw identically
. It can only return | 207 /** Returns true if this and other processor conservatively draw identically
. It can only return |
213 true when the two processor are of the same subclass (i.e. they return t
he same object from | 208 true when the two processor are of the same subclass (i.e. they return t
he same object from |
214 from getFactory()). | 209 from getFactory()). |
215 | 210 |
216 A return value of true from isEqual() should not be used to test whether
the processor would | 211 A return value of true from isEqual() should not be used to test whether
the processor would |
217 generate the same shader code. To test for identical code generation use
getGLSLProcessorKey | 212 generate the same shader code. To test for identical code generation use
getGLSLProcessorKey |
218 */ | 213 */ |
219 | 214 |
220 bool isEqual(const GrXferProcessor& that) const { | 215 bool isEqual(const GrXferProcessor& that) const { |
221 if (this->classID() != that.classID()) { | 216 if (this->classID() != that.classID()) { |
222 return false; | 217 return false; |
223 } | 218 } |
224 if (this->fWillReadDstColor != that.fWillReadDstColor) { | 219 if (this->fWillReadDstColor != that.fWillReadDstColor) { |
225 return false; | 220 return false; |
226 } | 221 } |
227 if (this->fReadsCoverage != that.fReadsCoverage) { | |
228 return false; | |
229 } | |
230 if (this->fDstTexture.getTexture() != that.fDstTexture.getTexture()) { | 222 if (this->fDstTexture.getTexture() != that.fDstTexture.getTexture()) { |
231 return false; | 223 return false; |
232 } | 224 } |
233 if (this->fDstTextureOffset != that.fDstTextureOffset) { | 225 if (this->fDstTextureOffset != that.fDstTextureOffset) { |
234 return false; | 226 return false; |
235 } | 227 } |
236 if (this->fDstReadUsesMixedSamples != that.fDstReadUsesMixedSamples) { | 228 if (this->fDstReadUsesMixedSamples != that.fDstReadUsesMixedSamples) { |
237 return false; | 229 return false; |
238 } | 230 } |
239 return this->onIsEqual(that); | 231 return this->onIsEqual(that); |
240 } | 232 } |
241 | 233 |
242 protected: | 234 protected: |
243 GrXferProcessor(); | 235 GrXferProcessor(); |
244 GrXferProcessor(const DstTexture*, bool willReadDstColor, bool hasMixedSampl
es); | 236 GrXferProcessor(const DstTexture*, bool willReadDstColor, bool hasMixedSampl
es); |
245 | 237 |
246 private: | 238 private: |
247 void notifyRefCntIsZero() const final {} | 239 void notifyRefCntIsZero() const final {} |
248 | 240 |
249 virtual OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 241 virtual OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
250 const GrProcOptInfo& coveragePOI, | 242 const GrProcOptInfo& coveragePOI, |
251 bool doesStencilWrite, | 243 bool doesStencilWrite, |
252 GrColor* overrideColor, | 244 GrColor* overrideColor, |
253 const GrCaps& caps) = 0; | 245 const GrCaps& caps) const = 0; |
254 | 246 |
255 /** | 247 /** |
256 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate
d with this xfer | 248 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate
d with this xfer |
257 * processor's GL backend implementation. | 249 * processor's GL backend implementation. |
258 */ | 250 */ |
259 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 251 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
260 GrProcessorKeyBuilder* b) const = 0; | 252 GrProcessorKeyBuilder* b) const = 0; |
261 | 253 |
262 /** | 254 /** |
263 * Determines the type of barrier (if any) required by the subclass. Note th
at the possibility | 255 * Determines the type of barrier (if any) required by the subclass. Note th
at the possibility |
(...skipping 15 matching lines...) Expand all Loading... |
279 * If we are not performing a dst read, retrieves the fixed-function blend s
tate required by the | 271 * If we are not performing a dst read, retrieves the fixed-function blend s
tate required by the |
280 * subclass. When using dst reads, the base class controls the fixed-functio
n blend state and | 272 * subclass. When using dst reads, the base class controls the fixed-functio
n blend state and |
281 * this method will not be called. The BlendInfo struct comes initialized to
"no blending". | 273 * this method will not be called. The BlendInfo struct comes initialized to
"no blending". |
282 */ | 274 */ |
283 virtual void onGetBlendInfo(BlendInfo*) const {} | 275 virtual void onGetBlendInfo(BlendInfo*) const {} |
284 | 276 |
285 virtual bool onIsEqual(const GrXferProcessor&) const = 0; | 277 virtual bool onIsEqual(const GrXferProcessor&) const = 0; |
286 | 278 |
287 bool fWillReadDstColor; | 279 bool fWillReadDstColor; |
288 bool fDstReadUsesMixedSamples; | 280 bool fDstReadUsesMixedSamples; |
289 bool fReadsCoverage; | |
290 SkIPoint fDstTextureOffset; | 281 SkIPoint fDstTextureOffset; |
291 GrTextureAccess fDstTexture; | 282 GrTextureAccess fDstTexture; |
292 | 283 |
293 typedef GrFragmentProcessor INHERITED; | 284 typedef GrFragmentProcessor INHERITED; |
294 }; | 285 }; |
295 | 286 |
296 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); | 287 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); |
297 | 288 |
298 /////////////////////////////////////////////////////////////////////////////// | 289 /////////////////////////////////////////////////////////////////////////////// |
299 | 290 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 enum { | 384 enum { |
394 kIllegalXPFClassID = 0, | 385 kIllegalXPFClassID = 0, |
395 }; | 386 }; |
396 static int32_t gCurrXPFClassID; | 387 static int32_t gCurrXPFClassID; |
397 | 388 |
398 typedef GrProgramElement INHERITED; | 389 typedef GrProgramElement INHERITED; |
399 }; | 390 }; |
400 | 391 |
401 #endif | 392 #endif |
402 | 393 |
OLD | NEW |