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

Unified Diff: src/gpu/GrDrawState.h

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 | « no previous file | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawState.h
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 90bdc64507dc544356d9cb2d8860f1fe8142a953..6ed04eded99f287551e9625f2b2f798ff7518506 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -49,19 +49,7 @@ public:
/**
* Copies another draw state with a preconcat to the view matrix.
**/
- 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(const GrDrawState& state, const SkMatrix& preConcatMatrix);
virtual ~GrDrawState() { SkASSERT(0 == fBlockEffectRemovalCnt); }
@@ -151,17 +139,9 @@ public:
*/
class AutoVertexAttribRestore {
public:
- AutoVertexAttribRestore(GrDrawState* drawState) {
- SkASSERT(NULL != drawState);
- fDrawState = drawState;
- fVAPtr = drawState->fVAPtr;
- fVACount = drawState->fVACount;
- fDrawState->setDefaultVertexAttribs();
- }
-
- ~AutoVertexAttribRestore(){
- fDrawState->setVertexAttribs(fVAPtr, fVACount);
- }
+ AutoVertexAttribRestore(GrDrawState* drawState);
+
+ ~AutoVertexAttribRestore() { fDrawState->setVertexAttribs(fVAPtr, fVACount); }
private:
GrDrawState* fDrawState;
@@ -169,64 +149,6 @@ public:
int fVACount;
};
- /**
- * Accessing positions, local coords, or colors, of a vertex within an array is a hassle
- * involving casts and simple math. These helpers exist to keep GrDrawTarget clients' code a bit
- * nicer looking.
- */
-
- /**
- * Gets a pointer to a GrPoint of a vertex's position or texture
- * coordinate.
- * @param vertices the vertex array
- * @param vertexIndex the index of the vertex in the array
- * @param vertexSize the size of each vertex in the array
- * @param offset the offset in bytes of the vertex component.
- * Defaults to zero (corresponding to vertex position)
- * @return pointer to the vertex component as a GrPoint
- */
- static SkPoint* GetVertexPoint(void* vertices,
- int vertexIndex,
- int vertexSize,
- int offset = 0) {
- intptr_t start = GrTCast<intptr_t>(vertices);
- return GrTCast<SkPoint*>(start + offset +
- vertexIndex * vertexSize);
- }
- static const SkPoint* GetVertexPoint(const void* vertices,
- int vertexIndex,
- int vertexSize,
- int offset = 0) {
- intptr_t start = GrTCast<intptr_t>(vertices);
- return GrTCast<const SkPoint*>(start + offset +
- vertexIndex * vertexSize);
- }
-
- /**
- * Gets a pointer to a GrColor inside a vertex within a vertex array.
- * @param vertices the vetex array
- * @param vertexIndex the index of the vertex in the array
- * @param vertexSize the size of each vertex in the array
- * @param offset the offset in bytes of the vertex color
- * @return pointer to the vertex component as a GrColor
- */
- static GrColor* GetVertexColor(void* vertices,
- int vertexIndex,
- int vertexSize,
- int offset) {
- intptr_t start = GrTCast<intptr_t>(vertices);
- return GrTCast<GrColor*>(start + offset +
- vertexIndex * vertexSize);
- }
- static const GrColor* GetVertexColor(const void* vertices,
- int vertexIndex,
- int vertexSize,
- int offset) {
- const intptr_t start = GrTCast<intptr_t>(vertices);
- return GrTCast<const GrColor*>(start + offset +
- vertexIndex * vertexSize);
- }
-
/// @}
/**
@@ -364,27 +286,7 @@ public:
~AutoRestoreEffects() { this->set(NULL); }
- void 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;)
- }
- }
+ void set(GrDrawState* ds);
bool isSet() const { return NULL != fDrawState; }
@@ -860,104 +762,13 @@ public:
a single GrDrawState. This is used to avoid storing redundant GrDrawStates and to determine
if draws can be batched. The return value indicates whether combining is possible and, if
so, which of the two inputs should be used. */
- static CombinedState 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;
- }
+ static CombinedState CombineIfPossible(const GrDrawState& a, const GrDrawState& b);
- 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;
- }
-
- 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;
- }
+ GrDrawState& operator= (const GrDrawState& that);
private:
- void 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();
- }
+ void onReset(const SkMatrix* initialViewMatrix);
BlendOptFlags calcBlendOpts(bool forceCoverage = false,
GrBlendCoeff* srcCoeff = NULL,
« no previous file with comments | « no previous file | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698