Index: src/gpu/GrRODrawState.h |
diff --git a/src/gpu/GrRODrawState.h b/src/gpu/GrRODrawState.h |
index 231560854fc1bf91f5f519d161dd1a1bad254e70..e325afd2993e6d710d55adf6bfe43b9113cc8d71 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 |
//// |
@@ -68,6 +73,10 @@ public: |
return -1 != fFixedFunctionVertexAttribIndices[kCoverage_GrVertexAttribBinding]; |
} |
+ const int* getFixedFunctionVertexAttribIndices() const { |
bsalomon
2014/08/28 13:49:27
Does this need to be public? Comment about what it
egdaniel
2014/08/28 14:39:38
moved to protected
|
+ return fFixedFunctionVertexAttribIndices; |
+ } |
+ |
bool validateVertexAttribs() const; |
/// @} |
@@ -153,6 +162,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 +208,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, |
bsalomon
2014/08/28 13:49:27
What was it that is keeping this public now? I kno
egdaniel
2014/08/28 14:39:38
Needed to stay public in this CL since the opt sta
|
+ GrBlendCoeff* srcCoeff = NULL, |
+ GrBlendCoeff* dstCoeff = NULL) const; |
/// @} |
/////////////////////////////////////////////////////////////////////////// |
@@ -295,6 +326,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 +360,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 { |
@@ -340,9 +384,11 @@ public: |
kB_CombinedState, |
}; |
- GrRODrawState& operator= (const GrRODrawState& that); |
- |
protected: |
+ explicit GrRODrawState(const GrRODrawState& drawState) : INHERITED() { |
+ fRenderTarget.reset(SkSafeRef(drawState.fRenderTarget.get())); |
+ } |
+ |
bool isEqual(const GrRODrawState& that) const; |
// These fields are roughly sorted by decreasing likelihood of being different in op== |
@@ -364,6 +410,8 @@ protected: |
EffectStageArray fColorStages; |
EffectStageArray fCoverageStages; |
+ uint32_t fHints; |
+ |
mutable GrBlendCoeff fOptSrcBlend; |
mutable GrBlendCoeff fOptDstBlend; |
mutable BlendOptFlags fBlendOptFlags; |
@@ -373,6 +421,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; |
}; |