Index: src/gpu/GrRODrawState.h |
diff --git a/src/gpu/GrRODrawState.h b/src/gpu/GrRODrawState.h |
index 0abd4a6aa54cce8169f5f9a16c93983a747a74d3..9c51b3796e125270e34a8c8b93f176b24c30c2e6 100644 |
--- a/src/gpu/GrRODrawState.h |
+++ b/src/gpu/GrRODrawState.h |
@@ -12,6 +12,7 @@ |
#include "GrEffectStage.h" |
#include "SkMatrix.h" |
+class GrDrawState; |
class GrDrawTargetCaps; |
class GrPaint; |
class GrRenderTarget; |
@@ -26,6 +27,10 @@ class GrRODrawState : public SkRefCnt { |
public: |
SK_DECLARE_INST_COUNT(GrRODrawState) |
+ GrRODrawState() {} |
+ |
+ GrRODrawState& operator= (const GrRODrawState& that); |
+ |
/////////////////////////////////////////////////////////////////////////// |
/// @name Vertex Attributes |
//// |
@@ -153,6 +158,12 @@ public: |
GrColor getBlendConstant() const { return fBlendConstant; } |
/** |
+ * We don't use supplied vertex color attributes if our blend mode is EmitCoverage or |
+ * EmitTransBlack |
+ */ |
+ bool canIgnoreColorAttribute() const; |
+ |
+ /** |
* Determines whether multiplying the computed per-pixel color by the pixel's fractional |
* coverage before the blend will give the correct final destination color. In general it |
* will not as coverage is applied after blending. |
@@ -193,6 +204,22 @@ public: |
}; |
GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags); |
+ /** |
+ * Determines what optimizations can be applied based on the blend. The coefficients may have |
+ * to be tweaked in order for the optimization to work. srcCoeff and dstCoeff are optional |
+ * params that receive the tweaked coefficients. Normally the function looks at the current |
+ * state to see if coverage is enabled. By setting forceCoverage the caller can speculatively |
+ * determine the blend optimizations that would be used if there was partial pixel coverage. |
+ * |
+ * Subclasses of GrDrawTarget that actually draw (as opposed to those that just buffer for |
+ * playback) must call this function and respect the flags that replace the output color. |
+ * |
+ * If the cached BlendOptFlags does not have the invalidate bit set, then getBlendOpts will |
+ * simply returned the cached flags and coefficients. Otherwise it will calculate the values. |
+ */ |
+ BlendOptFlags getBlendOpts(bool forceCoverage = false, |
+ GrBlendCoeff* srcCoeff = NULL, |
+ GrBlendCoeff* dstCoeff = NULL) const; |
/// @} |
/////////////////////////////////////////////////////////////////////////// |
@@ -295,6 +322,8 @@ public: |
kLastPublicStateBit = kDummyStateBit-1, |
}; |
+ uint32_t getFlagBits() const { return fFlagBits; } |
+ |
bool isStateFlagEnabled(uint32_t stateBit) const { return 0 != (stateBit & fFlagBits); } |
bool isDitherState() const { return 0 != (fFlagBits & kDither_StateBit); } |
@@ -327,6 +356,17 @@ public: |
/// @} |
/////////////////////////////////////////////////////////////////////////// |
+ /// @name Hints |
+ /// Hints that when provided can enable optimizations. |
+ //// |
+ |
+ enum Hints { kVertexColorsAreOpaque_Hint = 0x1, }; |
+ |
+ bool vertexColorsAreOpaque() const { return kVertexColorsAreOpaque_Hint & fHints; } |
+ |
+ /// @} |
+ |
+ /////////////////////////////////////////////////////////////////////////// |
/** Return type for CombineIfPossible. */ |
enum CombinedState { |
@@ -341,8 +381,17 @@ public: |
}; |
protected: |
+ explicit GrRODrawState(const GrRODrawState& drawState) : INHERITED() { |
+ fRenderTarget.reset(SkSafeRef(drawState.fRenderTarget.get())); |
+ } |
+ |
bool isEqual(const GrRODrawState& that) const; |
+ const int* getFixedFunctionVertexAttribIndices() const { |
bsalomon
2014/08/28 15:05:02
If this is protected and the field it returns is p
egdaniel
2014/08/28 15:24:24
Ugh forgot to hit save when test compiling last ti
bsalomon
2014/08/28 15:47:01
Let's just keep it public for now then.
|
+ return fFixedFunctionVertexAttribIndices; |
+ } |
+ |
+ |
// These fields are roughly sorted by decreasing likelihood of being different in op== |
SkAutoTUnref<GrRenderTarget> fRenderTarget; |
GrColor fColor; |
@@ -362,6 +411,8 @@ protected: |
EffectStageArray fColorStages; |
EffectStageArray fCoverageStages; |
+ uint32_t fHints; |
+ |
mutable GrBlendCoeff fOptSrcBlend; |
mutable GrBlendCoeff fOptDstBlend; |
mutable BlendOptFlags fBlendOptFlags; |
@@ -371,6 +422,18 @@ protected: |
int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt]; |
private: |
+ /** |
+ * Determines whether src alpha is guaranteed to be one for all src pixels |
+ */ |
+ bool srcAlphaWillBeOne() const; |
+ |
+ /** |
+ * Helper function for getBlendOpts. |
+ */ |
+ BlendOptFlags calcBlendOpts(bool forceCoverage = false, |
+ GrBlendCoeff* srcCoeff = NULL, |
+ GrBlendCoeff* dstCoeff = NULL) const; |
+ |
typedef SkRefCnt INHERITED; |
}; |