Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: src/gpu/GrRODrawState.h

Issue 508663002: Create an optimized draw state but not hooked in yet to gpu pipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@drawBase
Patch Set: Nits Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrRODrawState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrRODrawState.h
diff --git a/src/gpu/GrRODrawState.h b/src/gpu/GrRODrawState.h
index 718f017de3896e224b4b6e42e9fba78827f16de5..d748e7d83aac72e6ee5afe9dff65e34eb8ebca19 100644
--- a/src/gpu/GrRODrawState.h
+++ b/src/gpu/GrRODrawState.h
@@ -13,6 +13,7 @@
#include "GrStencil.h"
#include "SkMatrix.h"
+class GrDrawState;
class GrDrawTargetCaps;
class GrPaint;
class GrTexture;
@@ -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 {
+ return fFixedFunctionVertexAttribIndices;
+ }
+
bool validateVertexAttribs() const;
/// @}
@@ -158,6 +167,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.
@@ -198,6 +213,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;
/// @}
///////////////////////////////////////////////////////////////////////////
@@ -301,6 +332,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); }
@@ -333,6 +366,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 {
@@ -359,6 +403,8 @@ protected:
friend class GrDrawTarget;
+ explicit GrRODrawState(const GrRODrawState& drawState);
+
bool isEqual(const GrRODrawState& that) const;
// These fields are roughly sorted by decreasing likelihood of being different in op==
@@ -381,6 +427,8 @@ protected:
EffectStageArray fColorStages;
EffectStageArray fCoverageStages;
+ uint32_t fHints;
+
mutable GrBlendCoeff fOptSrcBlend;
mutable GrBlendCoeff fOptDstBlend;
mutable BlendOptFlags fBlendOptFlags;
@@ -390,6 +438,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;
};
« no previous file with comments | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrRODrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698