| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 /** | 158 /** |
| 159 * Determines which optimizations (as described by the ptFlags above) can be
performed by | 159 * Determines which optimizations (as described by the ptFlags above) can be
performed by |
| 160 * the draw with this xfer processor. If this function is called, the xfer p
rocessor may change | 160 * the draw with this xfer processor. If this function is called, the xfer p
rocessor may change |
| 161 * its state to reflected the given blend optimizations. If the XP needs to
see a specific input | 161 * its state to reflected the given blend optimizations. If the XP needs to
see a specific input |
| 162 * color to blend correctly, it will set the OverrideColor flag and the outp
ut parameter | 162 * color to blend correctly, it will set the OverrideColor flag and the outp
ut parameter |
| 163 * overrideColor will be the required value that should be passed into the X
P. | 163 * overrideColor will be the required value that should be passed into the X
P. |
| 164 * A caller who calls this function on a XP is required to honor the returne
d OptFlags | 164 * A caller who calls this function on a XP is required to honor the returne
d OptFlags |
| 165 * and color values for its draw. | 165 * and color values for its draw. |
| 166 */ | 166 */ |
| 167 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 167 OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
| 168 const GrProcOptInfo& coveragePOI, | 168 const GrProcOptInfo& coveragePOI, |
| 169 bool doesStencilWrite, | 169 bool doesStencilWrite, |
| 170 GrColor* overrideColor, | 170 GrColor* overrideColor, |
| 171 const GrDrawTargetCaps& caps) = 0; | 171 const GrDrawTargetCaps& caps); |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * Returns whether this XP will require an Xfer barrier on the given rt. If
true, outBarrierType | 174 * Returns whether this XP will require an Xfer barrier on the given rt. If
true, outBarrierType |
| 175 * is updated to contain the type of barrier needed. | 175 * is updated to contain the type of barrier needed. |
| 176 */ | 176 */ |
| 177 bool willNeedXferBarrier(const GrRenderTarget* rt, | 177 bool willNeedXferBarrier(const GrRenderTarget* rt, |
| 178 const GrDrawTargetCaps& caps, | 178 const GrDrawTargetCaps& caps, |
| 179 GrXferBarrierType* outBarrierType) const; | 179 GrXferBarrierType* outBarrierType) const; |
| 180 | 180 |
| 181 struct BlendInfo { | 181 struct BlendInfo { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 210 | 210 |
| 211 /** | 211 /** |
| 212 * Returns the offset into the DstCopyTexture to use when reading it in the
shader. This value | 212 * Returns the offset into the DstCopyTexture to use when reading it in the
shader. This value |
| 213 * is only valid if getDstCopyTexture() != NULL. | 213 * is only valid if getDstCopyTexture() != NULL. |
| 214 */ | 214 */ |
| 215 const SkIPoint& dstCopyTextureOffset() const { | 215 const SkIPoint& dstCopyTextureOffset() const { |
| 216 SkASSERT(this->getDstCopyTexture()); | 216 SkASSERT(this->getDstCopyTexture()); |
| 217 return fDstCopyTextureOffset; | 217 return fDstCopyTextureOffset; |
| 218 } | 218 } |
| 219 | 219 |
| 220 /** |
| 221 * Returns whether or not the XP will look at coverage when doing its blendi
ng. |
| 222 */ |
| 223 bool readsCoverage() const { return fReadsCoverage; } |
| 224 |
| 220 /** | 225 /** |
| 221 * Returns whether or not this xferProcossor will set a secondary output to
be used with dual | 226 * Returns whether or not this xferProcossor will set a secondary output to
be used with dual |
| 222 * source blending. | 227 * source blending. |
| 223 */ | 228 */ |
| 224 virtual bool hasSecondaryOutput() const { return false; } | 229 virtual bool hasSecondaryOutput() const { return false; } |
| 225 | 230 |
| 226 /** Returns true if this and other processor conservatively draw identically
. It can only return | 231 /** Returns true if this and other processor conservatively draw identically
. It can only return |
| 227 true when the two processor are of the same subclass (i.e. they return t
he same object from | 232 true when the two processor are of the same subclass (i.e. they return t
he same object from |
| 228 from getFactory()). | 233 from getFactory()). |
| 229 | 234 |
| 230 A return value of true from isEqual() should not be used to test whether
the processor would | 235 A return value of true from isEqual() should not be used to test whether
the processor would |
| 231 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ | 236 generate the same shader code. To test for identical code generation use
getGLProcessorKey*/ |
| 232 | 237 |
| 233 bool isEqual(const GrXferProcessor& that) const { | 238 bool isEqual(const GrXferProcessor& that) const { |
| 234 if (this->classID() != that.classID()) { | 239 if (this->classID() != that.classID()) { |
| 235 return false; | 240 return false; |
| 236 } | 241 } |
| 237 if (this->fWillReadDstColor != that.fWillReadDstColor) { | 242 if (this->fWillReadDstColor != that.fWillReadDstColor) { |
| 238 return false; | 243 return false; |
| 239 } | 244 } |
| 245 if (this->fReadsCoverage != that.fReadsCoverage) { |
| 246 return false; |
| 247 } |
| 240 if (this->fDstCopy.getTexture() != that.fDstCopy.getTexture()) { | 248 if (this->fDstCopy.getTexture() != that.fDstCopy.getTexture()) { |
| 241 return false; | 249 return false; |
| 242 } | 250 } |
| 243 if (this->fDstCopyTextureOffset != that.fDstCopyTextureOffset) { | 251 if (this->fDstCopyTextureOffset != that.fDstCopyTextureOffset) { |
| 244 return false; | 252 return false; |
| 245 } | 253 } |
| 246 return this->onIsEqual(that); | 254 return this->onIsEqual(that); |
| 247 } | 255 } |
| 248 | 256 |
| 249 protected: | 257 protected: |
| 250 GrXferProcessor(); | 258 GrXferProcessor(); |
| 251 GrXferProcessor(const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); | 259 GrXferProcessor(const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); |
| 252 | 260 |
| 253 private: | 261 private: |
| 262 virtual OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
| 263 const GrProcOptInfo& coveragePOI, |
| 264 bool doesStencilWrite, |
| 265 GrColor* overrideColor, |
| 266 const GrDrawTargetCaps& caps) = 0; |
| 267 |
| 254 /** | 268 /** |
| 255 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate
d with this xfer | 269 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate
d with this xfer |
| 256 * processor's GL backend implementation. | 270 * processor's GL backend implementation. |
| 257 */ | 271 */ |
| 258 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 272 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 259 GrProcessorKeyBuilder* b) const = 0; | 273 GrProcessorKeyBuilder* b) const = 0; |
| 260 | 274 |
| 261 /** | 275 /** |
| 262 * If not using a texture barrier, retrieves whether the subclass will requi
re a different type | 276 * If not using a texture barrier, retrieves whether the subclass will requi
re a different type |
| 263 * of barrier. | 277 * of barrier. |
| 264 */ | 278 */ |
| 265 virtual bool onWillNeedXferBarrier(const GrRenderTarget*, | 279 virtual bool onWillNeedXferBarrier(const GrRenderTarget*, |
| 266 const GrDrawTargetCaps&, | 280 const GrDrawTargetCaps&, |
| 267 GrXferBarrierType* outBarrierType SK_UNUS
ED) const { | 281 GrXferBarrierType* outBarrierType SK_UNUS
ED) const { |
| 268 return false; | 282 return false; |
| 269 } | 283 } |
| 270 | 284 |
| 271 /** | 285 /** |
| 272 * Retrieves the hardware blend state required by this Xfer processor. The B
lendInfo struct | 286 * Retrieves the hardware blend state required by this Xfer processor. The B
lendInfo struct |
| 273 * comes initialized to default values, so the Xfer processor only needs to
set the state it | 287 * comes initialized to default values, so the Xfer processor only needs to
set the state it |
| 274 * needs. It may not even need to override this method at all. | 288 * needs. It may not even need to override this method at all. |
| 275 */ | 289 */ |
| 276 virtual void onGetBlendInfo(BlendInfo*) const {} | 290 virtual void onGetBlendInfo(BlendInfo*) const {} |
| 277 | 291 |
| 278 virtual bool onIsEqual(const GrXferProcessor&) const = 0; | 292 virtual bool onIsEqual(const GrXferProcessor&) const = 0; |
| 279 | 293 |
| 280 bool fWillReadDstColor; | 294 bool fWillReadDstColor; |
| 295 bool fReadsCoverage; |
| 281 SkIPoint fDstCopyTextureOffset; | 296 SkIPoint fDstCopyTextureOffset; |
| 282 GrTextureAccess fDstCopy; | 297 GrTextureAccess fDstCopy; |
| 283 | 298 |
| 284 typedef GrFragmentProcessor INHERITED; | 299 typedef GrFragmentProcessor INHERITED; |
| 285 }; | 300 }; |
| 286 | 301 |
| 287 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); | 302 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); |
| 288 | 303 |
| 289 /////////////////////////////////////////////////////////////////////////////// | 304 /////////////////////////////////////////////////////////////////////////////// |
| 290 | 305 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 enum { | 399 enum { |
| 385 kIllegalXPFClassID = 0, | 400 kIllegalXPFClassID = 0, |
| 386 }; | 401 }; |
| 387 static int32_t gCurrXPFClassID; | 402 static int32_t gCurrXPFClassID; |
| 388 | 403 |
| 389 typedef GrProgramElement INHERITED; | 404 typedef GrProgramElement INHERITED; |
| 390 }; | 405 }; |
| 391 | 406 |
| 392 #endif | 407 #endif |
| 393 | 408 |
| OLD | NEW |