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

Unified Diff: src/gpu/GrOptDrawState.cpp

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/GrOptDrawState.h ('k') | src/gpu/gl/GrGLProgram.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrOptDrawState.cpp
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index cb03d2d683005dfe063bbedf49cf0cd53b8e933a..ac30311455ac062c8d96322504b43992cf8a5649 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -8,11 +8,14 @@
#include "GrOptDrawState.h"
#include "GrDrawState.h"
+#include "GrDrawTargetCaps.h"
+#include "GrGpu.h"
GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
BlendOptFlags blendOptFlags,
GrBlendCoeff optSrcCoeff,
- GrBlendCoeff optDstCoeff) : INHERITED(drawState) {
+ GrBlendCoeff optDstCoeff,
+ const GrDrawTargetCaps& caps) : INHERITED(drawState) {
fColor = drawState.getColor();
fCoverage = drawState.getCoverage();
fViewMatrix = drawState.getViewMatrix();
@@ -45,8 +48,56 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
this->copyEffectiveCoverageStages(drawState);
this->adjustFromBlendOpts();
this->getStageStats();
+ this->setOutputStateInfo(caps);
};
+void GrOptDrawState::setOutputStateInfo(const GrDrawTargetCaps& caps) {
+ // Set this default and then possibly change our mind if there is coverage.
+ fPrimaryOutputType = kModulate_PrimaryOutputType;
+ fSecondaryOutputType = kNone_SecondaryOutputType;
+
+ // If we do have coverage determine whether it matters.
+ bool separateCoverageFromColor = this->hasGeometryProcessor();
+ if (!this->isCoverageDrawing() &&
+ (this->numCoverageStages() > 0 ||
+ this->hasGeometryProcessor() ||
+ this->hasCoverageVertexAttribute())) {
+
+ if (caps.dualSourceBlendingSupport()) {
+ if (kZero_GrBlendCoeff == fDstBlend) {
+ // write the coverage value to second color
+ fSecondaryOutputType = kCoverage_SecondaryOutputType;
+ separateCoverageFromColor = true;
+ fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
+ } else if (kSA_GrBlendCoeff == fDstBlend) {
+ // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
+ fSecondaryOutputType = kCoverageISA_SecondaryOutputType;
+ separateCoverageFromColor = true;
+ fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
+ } else if (kSC_GrBlendCoeff == fDstBlend) {
+ // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
+ fSecondaryOutputType = kCoverageISC_SecondaryOutputType;
+ separateCoverageFromColor = true;
+ fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
+ }
+ } else if (fReadsDst &&
+ kOne_GrBlendCoeff == fSrcBlend &&
+ kZero_GrBlendCoeff == fDstBlend) {
+ fPrimaryOutputType = kCombineWithDst_PrimaryOutputType;
+ separateCoverageFromColor = true;
+ }
+ }
+
+ // TODO: Once we have flag to know if we only multiply on stages, only push coverage into color
+ // stages if everything is multipy
+ if (!separateCoverageFromColor) {
+ for (int s = 0; s < this->numCoverageStages(); ++s) {
+ fColorStages.push_back(this->getCoverageStage(s));
+ }
+ fCoverageStages.reset();
+ }
+}
+
void GrOptDrawState::adjustFromBlendOpts() {
switch (fBlendOptFlags) {
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/gl/GrGLProgram.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698