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

Unified Diff: src/gpu/GrOptDrawState.h

Issue 554833002: Calculate Primary and Secondary output types in the GrOptDrawState (Closed) Base URL: https://skia.googlesource.com/skia.git@optReadDst
Patch Set: Rebase 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/GrDrawState.cpp ('k') | src/gpu/GrOptDrawState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrOptDrawState.h
diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h
index 9c9bf94597ef712d3d0b8f6735f5f5601cc9616e..9445d334a2785ac82445324735456de25794c010 100644
--- a/src/gpu/GrOptDrawState.h
+++ b/src/gpu/GrOptDrawState.h
@@ -28,12 +28,48 @@ public:
bool requiresVertexShader() const { return fRequiresVertexShader; }
bool requiresLocalCoordAttrib() const { return fRequiresLocalCoordAttrib; }
+ ///////////////////////////////////////////////////////////////////////////
+ /// @name Stage Output Types
+ ////
+
+ enum PrimaryOutputType {
+ // Modulate color and coverage, write result as the color output.
+ kModulate_PrimaryOutputType,
+ // Combines the coverage, dst, and color as coverage * color + (1 - coverage) * dst. This
+ // can only be set if fDstReadKey is non-zero.
+ kCombineWithDst_PrimaryOutputType,
+
+ kPrimaryOutputTypeCnt,
+ };
+
+ enum SecondaryOutputType {
+ // There is no secondary output
+ kNone_SecondaryOutputType,
+ // Writes coverage as the secondary output. Only set if dual source blending is supported
+ // and primary output is kModulate.
+ kCoverage_SecondaryOutputType,
+ // Writes coverage * (1 - colorA) as the secondary output. Only set if dual source blending
+ // is supported and primary output is kModulate.
+ kCoverageISA_SecondaryOutputType,
+ // Writes coverage * (1 - colorRGBA) as the secondary output. Only set if dual source
+ // blending is supported and primary output is kModulate.
+ kCoverageISC_SecondaryOutputType,
+
+ kSecondaryOutputTypeCnt,
+ };
+
+ PrimaryOutputType getPrimaryOutputType() const { return fPrimaryOutputType; }
+ SecondaryOutputType getSecondaryOutputType() const { return fSecondaryOutputType; }
+
+ /// @}
+
private:
/**
* Constructs and optimized drawState out of a GrRODrawState.
*/
GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags,
- GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff);
+ GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff,
+ const GrDrawTargetCaps& caps);
/**
* Loops through all the color stage effects to check if the stage will ignore color input or
@@ -72,6 +108,13 @@ private:
*/
void getStageStats();
+ /**
+ * Calculates the primary and secondary output types of the shader. For certain output types
+ * the function may adjust the blend coefficients. After this function is called the src and dst
+ * blend coeffs will represent those used by backend API.
+ */
+ void setOutputStateInfo(const GrDrawTargetCaps&);
+
// These flags are needed to protect the code from creating an unused uniform color/coverage
// which will cause shader compiler errors.
bool fInputColorIsUsed;
@@ -87,7 +130,11 @@ private:
BlendOptFlags fBlendOptFlags;
- friend GrOptDrawState* GrDrawState::createOptState() const;
+ // Fragment shader color outputs
+ PrimaryOutputType fPrimaryOutputType : 8;
+ SecondaryOutputType fSecondaryOutputType : 8;
+
+ friend GrOptDrawState* GrDrawState::createOptState(const GrDrawTargetCaps&) const;
typedef GrRODrawState INHERITED;
};
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrOptDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698