Skia
2DGraphicsLibrary
|
GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst color, and for applying any coverage. More...
#include <GrXferProcessor.h>
Classes | |
struct | BlendInfo |
class | DstTexture |
A texture that contains the dst pixel values and an integer coord offset from device space to the space of the texture. More... | |
Public Types | |
enum | OptFlags { kSkipDraw_OptFlag = 0x1, kIgnoreColor_OptFlag = 0x2, kIgnoreCoverage_OptFlag = 0x4, kOverrideColor_OptFlag = 0x8, kCanTweakAlphaForCoverage_OptFlag = 0x20 } |
Optimizations for blending / coverage that an OptDrawState should apply to itself. More... | |
Public Types inherited from GrProcessor | |
enum | RequiredFeatures { kNone_RequiredFeatures = 0, kFragmentPosition_RequiredFeature = 1 << 0, kSampleLocations_RequiredFeature = 1 << 1 } |
Platform specific built-in features that a processor can request for the fragment shader. | |
Public Member Functions | |
void | getGLSLProcessorKey (const GrGLSLCaps &caps, GrProcessorKeyBuilder *b) const |
Sets a unique key on the GrProcessorKeyBuilder calls onGetGLSLProcessorKey(...) to get the specific subclass's key. | |
virtual GrGLSLXferProcessor * | createGLSLInstance () const =0 |
Returns a new instance of the appropriate GL implementation class for the given GrXferProcessor; caller is responsible for deleting the object. More... | |
GR_DECL_BITFIELD_OPS_FRIENDS (OptFlags) | |
OptFlags | getOptimizations (const GrPipelineOptimizations &optimizations, bool doesStencilWrite, GrColor *overrideColor, const GrCaps &caps) const |
Determines which optimizations (as described by the ptFlags above) can be performed by the draw with this xfer processor. More... | |
GrXferBarrierType | xferBarrierType (const GrRenderTarget *rt, const GrCaps &caps) const |
Returns whether this XP will require an Xfer barrier on the given rt. More... | |
void | getBlendInfo (BlendInfo *blendInfo) const |
bool | willReadDstColor () const |
const GrTexture * | getDstTexture () const |
Returns the texture to be used as the destination when reading the dst in the fragment shader. More... | |
const SkIPoint & | dstTextureOffset () const |
Returns the offset in device coords to use when accessing the dst texture to get the dst pixel color in the shader. More... | |
bool | dstReadUsesMixedSamples () const |
If we are performing a dst read, returns whether the base class will use mixed samples to antialias the shader's final output. More... | |
bool | hasSecondaryOutput () const |
Returns whether or not this xferProcossor will set a secondary output to be used with dual source blending. | |
bool | isEqual (const GrXferProcessor &that) const |
Returns true if this and other processor conservatively draw identically. More... | |
Public Member Functions inherited from GrProcessor | |
virtual const char * | name () const =0 |
Human-meaningful string to identify this prcoessor; may be embedded in generated shader code. More... | |
virtual SkString | dumpInfo () const |
int | numTextures () const |
const GrTextureAccess & | textureAccess (int index) const |
Returns the access pattern for the texture at index. More... | |
GrTexture * | texture (int index) const |
Shortcut for textureAccess(index).texture();. | |
int | numBuffers () const |
const GrBufferAccess & | bufferAccess (int index) const |
Returns the access pattern for the buffer at index. More... | |
GR_DECL_BITFIELD_OPS_FRIENDS (RequiredFeatures) | |
RequiredFeatures | requiredFeatures () const |
void * | operator new (size_t size) |
void | operator delete (void *target) |
void * | operator new (size_t size, void *placement) |
void | operator delete (void *target, void *placement) |
template<typename T > | |
const T & | cast () const |
Helper for down-casting to a GrProcessor subclass. | |
uint32_t | classID () const |
Public Member Functions inherited from GrProgramElement | |
void | ref () const |
void | unref () const |
uint32_t | getUniqueID () const |
Gets an id that is unique for this GrProgramElement object. More... | |
void | validate () const |
Static Public Attributes | |
static const OptFlags | kNone_OptFlags = (OptFlags)0 |
Protected Member Functions | |
GrXferProcessor (const DstTexture *, bool willReadDstColor, bool hasMixedSamples) | |
Protected Member Functions inherited from GrProcessor | |
virtual void | addTextureAccess (const GrTextureAccess *textureAccess) |
Subclasses call these from their constructor to register sampler sources. More... | |
virtual void | addBufferAccess (const GrBufferAccess *bufferAccess) |
bool | hasSameSamplers (const GrProcessor &) const |
void | setWillReadFragmentPosition () |
If the prcoessor will generate code that uses platform specific built-in features, then it must call these methods from its constructor. More... | |
void | setWillUseSampleLocations () |
void | combineRequiredFeatures (const GrProcessor &other) |
template<typename PROC_SUBCLASS > | |
void | initClassID () |
Protected Member Functions inherited from GrProgramElement | |
void | addGpuResource (const GrGpuResourceRef *res) |
Subclasses registers their resources using this function. More... | |
void | addPendingExecution () const |
void | completedExecution () const |
Private Types | |
typedef GrFragmentProcessor | INHERITED |
Private Member Functions | |
void | notifyRefCntIsZero () const final |
This will be called when the ref cnt is zero. More... | |
virtual OptFlags | onGetOptimizations (const GrPipelineOptimizations &optimizations, bool doesStencilWrite, GrColor *overrideColor, const GrCaps &caps) const =0 |
virtual void | onGetGLSLProcessorKey (const GrGLSLCaps &caps, GrProcessorKeyBuilder *b) const =0 |
Sets a unique key on the GrProcessorKeyBuilder that is directly associated with this xfer processor's GL backend implementation. | |
virtual GrXferBarrierType | onXferBarrier (const GrRenderTarget *, const GrCaps &) const |
Determines the type of barrier (if any) required by the subclass. More... | |
virtual bool | onHasSecondaryOutput () const |
If we are not performing a dst read, returns whether the subclass will set a secondary output. More... | |
virtual void | onGetBlendInfo (BlendInfo *) const |
If we are not performing a dst read, retrieves the fixed-function blend state required by the subclass. More... | |
virtual bool | onIsEqual (const GrXferProcessor &) const =0 |
Private Attributes | |
bool | fWillReadDstColor |
bool | fDstReadUsesMixedSamples |
SkIPoint | fDstTextureOffset |
GrTextureAccess | fDstTexture |
Additional Inherited Members | |
Protected Attributes inherited from GrProcessor | |
uint32_t | fClassID |
SkSTArray< 4, const GrTextureAccess *, true > | fTextureAccesses |
SkSTArray< 2, const GrBufferAccess *, true > | fBufferAccesses |
GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst color, and for applying any coverage.
It does this by emitting fragment shader code and controlling the fixed-function blend state. When dual-source blending is available, it may also write a seconday fragment shader output color. GrXferProcessor has two modes of operation:
Dst read: When allowed by the backend API, or when supplied a texture of the destination, the GrXferProcessor may read the destination color. While operating in this mode, the subclass only provides shader code that blends the src and dst colors, and the base class applies coverage.
No dst read: When not performing a dst read, the subclass is given full control of the fixed- function blend state and/or secondary output, and is responsible to apply coverage on its own.
A GrXferProcessor is never installed directly into our draw state, but instead is created from a GrXPFactory once we have finalized the state of our draw.
Optimizations for blending / coverage that an OptDrawState should apply to itself.
Enumerator | |
---|---|
kSkipDraw_OptFlag |
The draw can be skipped completely. |
kIgnoreColor_OptFlag |
GrXferProcessor will ignore color, thus no need to provide. |
kIgnoreCoverage_OptFlag |
GrXferProcessor will ignore coverage, thus no need to provide. |
kOverrideColor_OptFlag |
Clear color stages and override input color to that returned by getOptimizations. |
kCanTweakAlphaForCoverage_OptFlag |
Can tweak alpha for coverage. Currently this flag should only be used by a batch |
|
pure virtual |
Returns a new instance of the appropriate GL implementation class for the given GrXferProcessor; caller is responsible for deleting the object.
|
inline |
If we are performing a dst read, returns whether the base class will use mixed samples to antialias the shader's final output.
If not doing a dst read, the subclass is responsible for antialiasing and this returns false.
|
inline |
Returns the offset in device coords to use when accessing the dst texture to get the dst pixel color in the shader.
This value is only valid if getDstTexture() != NULL.
|
inline |
Returns the texture to be used as the destination when reading the dst in the fragment shader.
If the returned texture is NULL then the XP is either not reading the dst or we have extentions that support framebuffer fetching and thus don't need a copy of the dst texture.
OptFlags GrXferProcessor::getOptimizations | ( | const GrPipelineOptimizations & | optimizations, |
bool | doesStencilWrite, | ||
GrColor * | overrideColor, | ||
const GrCaps & | caps | ||
) | const |
Determines which optimizations (as described by the ptFlags above) can be performed by the draw with this xfer processor.
If this function is called, the xfer processor may change its state to reflected the given blend optimizations. If the XP needs to see a specific input color to blend correctly, it will set the OverrideColor flag and the output parameter overrideColor will be the required value that should be passed into the XP. A caller who calls this function on a XP is required to honor the returned OptFlags and color values for its draw.
|
inline |
Returns true if this and other processor conservatively draw identically.
It can only return true when the two processor are of the same subclass (i.e. they return the same object from from getFactory()).
A return value of true from isEqual() should not be used to test whether the processor would generate the same shader code. To test for identical code generation use getGLSLProcessorKey
|
inlinefinalprivatevirtual |
This will be called when the ref cnt is zero.
The object may or may not have pending executions.
Implements GrProgramElement.
|
inlineprivatevirtual |
If we are not performing a dst read, retrieves the fixed-function blend state required by the subclass.
When using dst reads, the base class controls the fixed-function blend state and this method will not be called. The BlendInfo struct comes initialized to "no blending".
|
inlineprivatevirtual |
If we are not performing a dst read, returns whether the subclass will set a secondary output.
When using dst reads, the base class controls the secondary output and this method will not be called.
|
inlineprivatevirtual |
Determines the type of barrier (if any) required by the subclass.
Note that the possibility that a kTexture type barrier is required is handled by the base class and need not be considered by subclass overrides of this function.
GrXferBarrierType GrXferProcessor::xferBarrierType | ( | const GrRenderTarget * | rt, |
const GrCaps & | caps | ||
) | const |
Returns whether this XP will require an Xfer barrier on the given rt.
If true, outBarrierType is updated to contain the type of barrier needed.