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

Unified Diff: src/gpu/GrDrawState.cpp

Issue 427713005: Move functions from GrDrawState.h to GrDrawState.cpp and delete unused functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@colorcheck
Patch Set: rebase Created 6 years, 4 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.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawState.cpp
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 1b40642251e87219f321d6a3e6aeeb836db6e84c..3189a0a079353a7be315dde3994394c166247db2 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -8,6 +8,124 @@
#include "GrDrawState.h"
#include "GrPaint.h"
+//////////////////////////////////////////////////////////////////////////////s
+
+GrDrawState::CombinedState GrDrawState::CombineIfPossible(
+ const GrDrawState& a, const GrDrawState& b) {
+
+ bool usingVertexColors = a.hasColorVertexAttribute();
+ if (!usingVertexColors && a.fColor != b.fColor) {
+ return kIncompatible_CombinedState;
+ }
+
+ if (a.fRenderTarget.get() != b.fRenderTarget.get() ||
+ a.fColorStages.count() != b.fColorStages.count() ||
+ a.fCoverageStages.count() != b.fCoverageStages.count() ||
+ !a.fViewMatrix.cheapEqualTo(b.fViewMatrix) ||
+ a.fSrcBlend != b.fSrcBlend ||
+ a.fDstBlend != b.fDstBlend ||
+ a.fBlendConstant != b.fBlendConstant ||
+ a.fFlagBits != b.fFlagBits ||
+ a.fVACount != b.fVACount ||
+ memcmp(a.fVAPtr, b.fVAPtr, a.fVACount * sizeof(GrVertexAttrib)) ||
+ a.fStencilSettings != b.fStencilSettings ||
+ a.fDrawFace != b.fDrawFace) {
+ return kIncompatible_CombinedState;
+ }
+
+ bool usingVertexCoverage = a.hasCoverageVertexAttribute();
+ if (!usingVertexCoverage && a.fCoverage != b.fCoverage) {
+ return kIncompatible_CombinedState;
+ }
+
+ bool explicitLocalCoords = a.hasLocalCoordAttribute();
+ for (int i = 0; i < a.fColorStages.count(); i++) {
+ if (!GrEffectStage::AreCompatible(a.fColorStages[i], b.fColorStages[i],
+ explicitLocalCoords)) {
+ return kIncompatible_CombinedState;
+ }
+ }
+ for (int i = 0; i < a.fCoverageStages.count(); i++) {
+ if (!GrEffectStage::AreCompatible(a.fCoverageStages[i], b.fCoverageStages[i],
+ explicitLocalCoords)) {
+ return kIncompatible_CombinedState;
+ }
+ }
+ SkASSERT(0 == memcmp(a.fFixedFunctionVertexAttribIndices,
+ b.fFixedFunctionVertexAttribIndices,
+ sizeof(a.fFixedFunctionVertexAttribIndices)));
+ return kAOrB_CombinedState;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////s
+
+GrDrawState::GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix) {
+ SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
+ *this = state;
+ if (!preConcatMatrix.isIdentity()) {
+ for (int i = 0; i < fColorStages.count(); ++i) {
+ fColorStages[i].localCoordChange(preConcatMatrix);
+ }
+ for (int i = 0; i < fCoverageStages.count(); ++i) {
+ fCoverageStages[i].localCoordChange(preConcatMatrix);
+ }
+ this->invalidateBlendOptFlags();
+ }
+}
+
+GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
+ SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages());
+ this->setRenderTarget(that.fRenderTarget.get());
+ fColor = that.fColor;
+ fViewMatrix = that.fViewMatrix;
+ fSrcBlend = that.fSrcBlend;
+ fDstBlend = that.fDstBlend;
+ fBlendConstant = that.fBlendConstant;
+ fFlagBits = that.fFlagBits;
+ fVACount = that.fVACount;
+ fVAPtr = that.fVAPtr;
+ fStencilSettings = that.fStencilSettings;
+ fCoverage = that.fCoverage;
+ fDrawFace = that.fDrawFace;
+ fColorStages = that.fColorStages;
+ fCoverageStages = that.fCoverageStages;
+ fOptSrcBlend = that.fOptSrcBlend;
+ fOptDstBlend = that.fOptDstBlend;
+ fBlendOptFlags = that.fBlendOptFlags;
+
+ memcpy(fFixedFunctionVertexAttribIndices,
+ that.fFixedFunctionVertexAttribIndices,
+ sizeof(fFixedFunctionVertexAttribIndices));
+ return *this;
+}
+
+void GrDrawState::onReset(const SkMatrix* initialViewMatrix) {
+ SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numTotalStages());
+ fColorStages.reset();
+ fCoverageStages.reset();
+
+ fRenderTarget.reset(NULL);
+
+ this->setDefaultVertexAttribs();
+
+ fColor = 0xffffffff;
+ if (NULL == initialViewMatrix) {
+ fViewMatrix.reset();
+ } else {
+ fViewMatrix = *initialViewMatrix;
+ }
+ fSrcBlend = kOne_GrBlendCoeff;
+ fDstBlend = kZero_GrBlendCoeff;
+ fBlendConstant = 0x0;
+ fFlagBits = 0x0;
+ fStencilSettings.setDisabled();
+ fCoverage = 0xffffffff;
+ fDrawFace = kBoth_DrawFace;
+
+ this->invalidateBlendOptFlags();
+}
+
bool GrDrawState::setIdentityViewMatrix() {
if (fColorStages.count() || fCoverageStages.count()) {
SkMatrix invVM;
@@ -411,6 +529,40 @@ bool GrDrawState::canIgnoreColorAttribute() const {
GrDrawState::kEmitCoverage_BlendOptFlag));
}
+//////////////////////////////////////////////////////////////////////////////
+
+GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(
+ GrDrawState* drawState) {
+ SkASSERT(NULL != drawState);
+ fDrawState = drawState;
+ fVAPtr = drawState->fVAPtr;
+ fVACount = drawState->fVACount;
+ fDrawState->setDefaultVertexAttribs();
+}
+
+//////////////////////////////////////////////////////////////////////////////s
+
+void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
+ if (NULL != fDrawState) {
+ int m = fDrawState->fColorStages.count() - fColorEffectCnt;
+ SkASSERT(m >= 0);
+ fDrawState->fColorStages.pop_back_n(m);
+
+ int n = fDrawState->fCoverageStages.count() - fCoverageEffectCnt;
+ SkASSERT(n >= 0);
+ fDrawState->fCoverageStages.pop_back_n(n);
+ if (m + n > 0) {
+ fDrawState->invalidateBlendOptFlags();
+ }
+ SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;)
+ }
+ fDrawState = ds;
+ if (NULL != ds) {
+ fColorEffectCnt = ds->fColorStages.count();
+ fCoverageEffectCnt = ds->fCoverageStages.count();
+ SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;)
+ }
+}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698