aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-23 19:09:06 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-23 19:09:06 +0000
commit58f9ae1c7aa6e0a04c48ae907ad78f849ae14836 (patch)
treedca719958abd5927ba668313fe45a4bf2ad97cff
parent4dcc624ee0f546d6ff4077694892e9a294985f68 (diff)
Revert 7342 to investigate failures.
git-svn-id: http://skia.googlecode.com/svn/trunk@7345 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/gpu/GrEffect.h39
-rw-r--r--include/gpu/GrEffectStage.h58
-rw-r--r--src/gpu/GrDrawState.h294
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp21
-rw-r--r--src/gpu/GrInOrderDrawBuffer.h12
5 files changed, 158 insertions, 266 deletions
diff --git a/include/gpu/GrEffect.h b/include/gpu/GrEffect.h
index aad577f568..4d9202fe3e 100644
--- a/include/gpu/GrEffect.h
+++ b/include/gpu/GrEffect.h
@@ -120,7 +120,19 @@ public:
effectA.getFactory().glEffectKey(effectA) == effectB.getFactory().glEffectKey(effectB).
*/
bool isEqual(const GrEffectRef& other) const {
- return this->isEqual(*other.get());
+ if (&this->getFactory() != &other->getFactory()) {
+ return false;
+ }
+ bool result = this->onIsEqual(*other.get());
+#if GR_DEBUG
+ if (result) {
+ GrAssert(this->numTextures() == other->numTextures());
+ for (int i = 0; i < this->numTextures(); ++i) {
+ GrAssert(*fTextureAccesses[i] == *other->fTextureAccesses[i]);
+ }
+ }
+#endif
+ return result;
}
/** Human-meaningful string to identify this effect; may be embedded
@@ -150,8 +162,8 @@ public:
/** These use non-standard names because GrEffects should only be ref'ed an unref'ed deep in
the bowels. Rendering code should use GrEffectRef. */
- void addRef() const { this->ref(); }
- void subRef() const { this->unref(); }
+ void addRef() { this->ref(); }
+ void subRef() { this->unref(); }
protected:
/**
@@ -175,10 +187,6 @@ protected:
return effect->fEffectRef;
}
- static const GrEffectRef* CreateEffectRef(const GrEffect* effect) {
- return CreateEffectRef(const_cast<GrEffect*>(effect));
- }
-
/** Helper used in subclass factory functions to unref the effect after it has been wrapped in a
GrEffectRef. E.g.:
@@ -206,21 +214,6 @@ protected:
}
private:
- bool isEqual(const GrEffect& other) const {
- if (&this->getFactory() != &other.getFactory()) {
- return false;
- }
- bool result = this->onIsEqual(other);
-#if GR_DEBUG
- if (result) {
- GrAssert(this->numTextures() == other.numTextures());
- for (int i = 0; i < this->numTextures(); ++i) {
- GrAssert(*fTextureAccesses[i] == *other.fTextureAccesses[i]);
- }
- }
-#endif
- return result;
- }
/** Subclass implements this to support isEqual(). It will only be called if it is known that
the two effects are of the same subclass (i.e. they return the same object from
@@ -230,8 +223,6 @@ private:
void EffectRefDestroyed() { fEffectRef = NULL; }
friend class GrEffectRef; // to call GrEffectRef destroyed
- friend class GrEffectStage; // to rewrap GrEffect in GrEffectRef when restoring an effect-stage
- // from deferred state. And to call isEqual on naked GrEffects.
SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
GrEffectRef* fEffectRef;
diff --git a/include/gpu/GrEffectStage.h b/include/gpu/GrEffectStage.h
index b561aaac25..c09cd450a7 100644
--- a/include/gpu/GrEffectStage.h
+++ b/include/gpu/GrEffectStage.h
@@ -20,6 +20,7 @@
class GrEffectStage {
public:
+
GrEffectStage()
: fEffectRef (NULL) {
GR_DEBUGCODE(fSavedCoordChangeCnt = 0;)
@@ -95,63 +96,6 @@ public:
}
/**
- * Used when storing a deferred GrDrawState. The DeferredStage allows resources owned by its
- * GrEffect to be recycled through the cache.
- */
- class DeferredStage {
- public:
- DeferredStage() : fEffect(NULL) {
- SkDEBUGCODE(fInitialized = false;)
- }
-
- void saveFrom(const GrEffectStage& stage) {
- GrAssert(!fInitialized);
- if (NULL != stage.fEffectRef) {
- stage.fEffectRef->get()->addRef();
- fEffect = stage.fEffectRef->get();
- fCoordChangeMatrix = stage.fCoordChangeMatrix;
- }
- SkDEBUGCODE(fInitialized = true;)
- }
-
- void restoreTo(GrEffectStage* stage) {
- GrAssert(fInitialized);
- const GrEffectRef* oldEffectRef = stage->fEffectRef;
- if (NULL != fEffect) {
- stage->fEffectRef = GrEffect::CreateEffectRef(fEffect);
- stage->fCoordChangeMatrix = fCoordChangeMatrix;
- } else {
- stage->fEffectRef = NULL;
- }
- SkSafeUnref(oldEffectRef);
- }
-
- bool isEqual(const GrEffectStage& stage) const {
- if (NULL == stage.fEffectRef) {
- return NULL == fEffect;
- } else if (NULL == fEffect) {
- return false;
- }
-
- if (!(*stage.getEffect())->isEqual(*fEffect)) {
- return false;
- }
-
- return fCoordChangeMatrix == stage.fCoordChangeMatrix;
- }
-
- ~DeferredStage() {
- if (NULL != fEffect) {
- fEffect->subRef();
- }
- }
- private:
- const GrEffect* fEffect;
- SkMatrix fCoordChangeMatrix;
- SkDEBUGCODE(bool fInitialized;)
- };
-
- /**
* Gets the matrix representing all changes of coordinate system since the GrEffect was
* installed in the stage.
*/
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 820f79a6de..4a99ecb942 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -57,16 +57,21 @@ public:
kMaxTexCoords = kNumStages
};
- GrDrawState() {
+ GrDrawState()
+ : fRenderTarget(NULL) {
+
this->reset();
}
- GrDrawState(const GrDrawState& state) {
+ GrDrawState(const GrDrawState& state)
+ : fRenderTarget(NULL) {
+
*this = state;
}
virtual ~GrDrawState() {
this->disableStages();
+ GrSafeSetNull(fRenderTarget);
}
/**
@@ -77,21 +82,20 @@ public:
this->disableStages();
- fRenderTarget.reset(NULL);
-
- fCommon.fColor = 0xffffffff;
- fCommon.fViewMatrix.reset();
- fCommon.fSrcBlend = kOne_GrBlendCoeff;
- fCommon.fDstBlend = kZero_GrBlendCoeff;
- fCommon.fBlendConstant = 0x0;
- fCommon.fFlagBits = 0x0;
- fCommon.fVertexEdgeType = kHairLine_EdgeType;
- fCommon.fStencilSettings.setDisabled();
- fCommon.fFirstCoverageStage = kNumStages;
- fCommon.fCoverage = 0xffffffff;
- fCommon.fColorFilterMode = SkXfermode::kDst_Mode;
- fCommon.fColorFilterColor = 0x0;
- fCommon.fDrawFace = kBoth_DrawFace;
+ fColor = 0xffffffff;
+ fViewMatrix.reset();
+ GrSafeSetNull(fRenderTarget);
+ fSrcBlend = kOne_GrBlendCoeff;
+ fDstBlend = kZero_GrBlendCoeff;
+ fBlendConstant = 0x0;
+ fFlagBits = 0x0;
+ fVertexEdgeType = kHairLine_EdgeType;
+ fStencilSettings.setDisabled();
+ fFirstCoverageStage = kNumStages;
+ fCoverage = 0xffffffff;
+ fColorFilterMode = SkXfermode::kDst_Mode;
+ fColorFilterColor = 0x0;
+ fDrawFace = kBoth_DrawFace;
}
/**
@@ -111,9 +115,9 @@ public:
*
* @param color the color to set.
*/
- void setColor(GrColor color) { fCommon.fColor = color; }
+ void setColor(GrColor color) { fColor = color; }
- GrColor getColor() const { return fCommon.fColor; }
+ GrColor getColor() const { return fColor; }
/**
* Sets the color to be used for the next draw to be
@@ -130,12 +134,12 @@ public:
* after color-computing texture stages.
*/
void setColorFilter(GrColor c, SkXfermode::Mode mode) {
- fCommon.fColorFilterColor = c;
- fCommon.fColorFilterMode = mode;
+ fColorFilterColor = c;
+ fColorFilterMode = mode;
}
- GrColor getColorFilterColor() const { return fCommon.fColorFilterColor; }
- SkXfermode::Mode getColorFilterMode() const { return fCommon.fColorFilterMode; }
+ GrColor getColorFilterColor() const { return fColorFilterColor; }
+ SkXfermode::Mode getColorFilterMode() const { return fColorFilterMode; }
/**
* Constructor sets the color to be 'color' which is undone by the destructor.
@@ -167,7 +171,7 @@ public:
* coverage is ignored when per-vertex coverage is provided.
*/
void setCoverage(uint8_t coverage) {
- fCommon.fCoverage = GrColorPackRGBA(coverage, coverage, coverage, coverage);
+ fCoverage = GrColorPackRGBA(coverage, coverage, coverage, coverage);
}
/**
@@ -175,11 +179,11 @@ public:
* should be premultiplied.
*/
void setCoverage4(GrColor coverage) {
- fCommon.fCoverage = coverage;
+ fCoverage = coverage;
}
GrColor getCoverage() const {
- return fCommon.fCoverage;
+ return fCoverage;
}
/// @}
@@ -311,14 +315,14 @@ public:
*/
void setFirstCoverageStage(int firstCoverageStage) {
GrAssert((unsigned)firstCoverageStage <= kNumStages);
- fCommon.fFirstCoverageStage = firstCoverageStage;
+ fFirstCoverageStage = firstCoverageStage;
}
/**
* Gets the index of the first coverage-computing stage.
*/
int getFirstCoverageStage() const {
- return fCommon.fFirstCoverageStage;
+ return fFirstCoverageStage;
}
///@}
@@ -341,8 +345,8 @@ public:
* @param dstCoef coefficient applied to the dst color.
*/
void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
- fCommon.fSrcBlend = srcCoeff;
- fCommon.fDstBlend = dstCoeff;
+ fSrcBlend = srcCoeff;
+ fDstBlend = dstCoeff;
#if GR_DEBUG
switch (dstCoeff) {
case kDC_GrBlendCoeff:
@@ -369,13 +373,13 @@ public:
#endif
}
- GrBlendCoeff getSrcBlendCoeff() const { return fCommon.fSrcBlend; }
- GrBlendCoeff getDstBlendCoeff() const { return fCommon.fDstBlend; }
+ GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; }
+ GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; }
void getDstBlendCoeff(GrBlendCoeff* srcBlendCoeff,
GrBlendCoeff* dstBlendCoeff) const {
- *srcBlendCoeff = fCommon.fSrcBlend;
- *dstBlendCoeff = fCommon.fDstBlend;
+ *srcBlendCoeff = fSrcBlend;
+ *dstBlendCoeff = fDstBlend;
}
/**
@@ -388,13 +392,13 @@ public:
*
* @param constant the constant to set
*/
- void setBlendConstant(GrColor constant) { fCommon.fBlendConstant = constant; }
+ void setBlendConstant(GrColor constant) { fBlendConstant = constant; }
/**
* Retrieves the last value set by setBlendConstant()
* @return the blending constant value
*/
- GrColor getBlendConstant() const { return fCommon.fBlendConstant; }
+ GrColor getBlendConstant() const { return fBlendConstant; }
/// @}
@@ -407,14 +411,14 @@ public:
*
* In the post-view-matrix space the rectangle [0,w]x[0,h]
* fully covers the render target. (w and h are the width and height of the
- * the render-target.)
+ * the rendertarget.)
*/
- void setViewMatrix(const SkMatrix& m) { fCommon.fViewMatrix = m; }
+ void setViewMatrix(const SkMatrix& m) { fViewMatrix = m; }
/**
* Gets a writable pointer to the view matrix.
*/
- SkMatrix* viewMatrix() { return &fCommon.fViewMatrix; }
+ SkMatrix* viewMatrix() { return &fViewMatrix; }
/**
* Multiplies the current view matrix by a matrix
@@ -426,7 +430,7 @@ public:
*
* @param m the matrix used to modify the view matrix.
*/
- void preConcatViewMatrix(const SkMatrix& m) { fCommon.fViewMatrix.preConcat(m); }
+ void preConcatViewMatrix(const SkMatrix& m) { fViewMatrix.preConcat(m); }
/**
* Multiplies the current view matrix by a matrix
@@ -438,13 +442,13 @@ public:
*
* @param m the matrix used to modify the view matrix.
*/
- void postConcatViewMatrix(const SkMatrix& m) { fCommon.fViewMatrix.postConcat(m); }
+ void postConcatViewMatrix(const SkMatrix& m) { fViewMatrix.postConcat(m); }
/**
* Retrieves the current view matrix
* @return the current view matrix.
*/
- const SkMatrix& getViewMatrix() const { return fCommon.fViewMatrix; }
+ const SkMatrix& getViewMatrix() const { return fViewMatrix; }
/**
* Retrieves the inverse of the current view matrix.
@@ -459,7 +463,7 @@ public:
// TODO: determine whether we really need to leave matrix unmodified
// at call sites when inversion fails.
SkMatrix inverse;
- if (fCommon.fViewMatrix.invert(&inverse)) {
+ if (fViewMatrix.invert(&inverse)) {
if (matrix) {
*matrix = inverse;
}
@@ -566,21 +570,21 @@ public:
////
/**
- * Sets the render-target used at the next drawing call
+ * Sets the rendertarget used at the next drawing call
*
* @param target The render target to set.
*/
void setRenderTarget(GrRenderTarget* target) {
- fRenderTarget.reset(SkSafeRef(target));
+ GrSafeAssign(fRenderTarget, target);
}
/**
- * Retrieves the currently set render-target.
+ * Retrieves the currently set rendertarget.
*
* @return The currently set render target.
*/
- const GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); }
- GrRenderTarget* getRenderTarget() { return fRenderTarget.get(); }
+ const GrRenderTarget* getRenderTarget() const { return fRenderTarget; }
+ GrRenderTarget* getRenderTarget() { return fRenderTarget; }
class AutoRenderTargetRestore : public ::GrNoncopyable {
public:
@@ -630,19 +634,19 @@ public:
* @param settings the stencil settings to use.
*/
void setStencil(const GrStencilSettings& settings) {
- fCommon.fStencilSettings = settings;
+ fStencilSettings = settings;
}
/**
* Shortcut to disable stencil testing and ops.
*/
void disableStencil() {
- fCommon.fStencilSettings.setDisabled();
+ fStencilSettings.setDisabled();
}
- const GrStencilSettings& getStencil() const { return fCommon.fStencilSettings; }
+ const GrStencilSettings& getStencil() const { return fStencilSettings; }
- GrStencilSettings* stencil() { return &fCommon.fStencilSettings; }
+ GrStencilSettings* stencil() { return &fStencilSettings; }
/// @}
@@ -691,10 +695,10 @@ public:
*/
void setVertexEdgeType(VertexEdgeType type) {
GrAssert(type >=0 && type < kVertexEdgeTypeCnt);
- fCommon.fVertexEdgeType = type;
+ fVertexEdgeType = type;
}
- VertexEdgeType getVertexEdgeType() const { return fCommon.fVertexEdgeType; }
+ VertexEdgeType getVertexEdgeType() const { return fVertexEdgeType; }
/// @}
@@ -743,7 +747,7 @@ public:
};
void resetStateFlags() {
- fCommon.fFlagBits = 0;
+ fFlagBits = 0;
}
/**
@@ -752,7 +756,7 @@ public:
* @param stateBits bitfield of StateBits specifying the states to enable
*/
void enableState(uint32_t stateBits) {
- fCommon.fFlagBits |= stateBits;
+ fFlagBits |= stateBits;
}
/**
@@ -761,7 +765,7 @@ public:
* @param stateBits bitfield of StateBits specifying the states to disable
*/
void disableState(uint32_t stateBits) {
- fCommon.fFlagBits &= ~(stateBits);
+ fFlagBits &= ~(stateBits);
}
/**
@@ -779,27 +783,27 @@ public:
}
bool isDitherState() const {
- return 0 != (fCommon.fFlagBits & kDither_StateBit);
+ return 0 != (fFlagBits & kDither_StateBit);
}
bool isHWAntialiasState() const {
- return 0 != (fCommon.fFlagBits & kHWAntialias_StateBit);
+ return 0 != (fFlagBits & kHWAntialias_StateBit);
}
bool isClipState() const {
- return 0 != (fCommon.fFlagBits & kClip_StateBit);
+ return 0 != (fFlagBits & kClip_StateBit);
}
bool isColorWriteDisabled() const {
- return 0 != (fCommon.fFlagBits & kNoColorWrites_StateBit);
+ return 0 != (fFlagBits & kNoColorWrites_StateBit);
}
bool isCoverageDrawing() const {
- return 0 != (fCommon.fFlagBits & kCoverageDrawing_StateBit);
+ return 0 != (fFlagBits & kCoverageDrawing_StateBit);
}
bool isStateFlagEnabled(uint32_t stateBit) const {
- return 0 != (stateBit & fCommon.fFlagBits);
+ return 0 != (stateBit & fFlagBits);
}
/// @}
@@ -822,7 +826,7 @@ public:
*/
void setDrawFace(DrawFace face) {
GrAssert(kInvalid_DrawFace != face);
- fCommon.fDrawFace = face;
+ fDrawFace = face;
}
/**
@@ -830,7 +834,7 @@ public:
* or both faces.
* @return the current draw face(s).
*/
- DrawFace getDrawFace() const { return fCommon.fDrawFace; }
+ DrawFace getDrawFace() const { return fDrawFace; }
/// @}
@@ -844,7 +848,20 @@ public:
// Most stages are usually not used, so conditionals here
// reduce the expected number of bytes touched by 50%.
bool operator ==(const GrDrawState& s) const {
- if (fRenderTarget.get() != s.fRenderTarget.get() || fCommon != s.fCommon) {
+ if (fColor != s.fColor ||
+ !s.fViewMatrix.cheapEqualTo(fViewMatrix) ||
+ fRenderTarget != s.fRenderTarget ||
+ fSrcBlend != s.fSrcBlend ||
+ fDstBlend != s.fDstBlend ||
+ fBlendConstant != s.fBlendConstant ||
+ fFlagBits != s.fFlagBits ||
+ fVertexEdgeType != s.fVertexEdgeType ||
+ fStencilSettings != s.fStencilSettings ||
+ fFirstCoverageStage != s.fFirstCoverageStage ||
+ fCoverage != s.fCoverage ||
+ fColorFilterMode != s.fColorFilterMode ||
+ fColorFilterColor != s.fColorFilterColor ||
+ fDrawFace != s.fDrawFace) {
return false;
}
@@ -861,123 +878,54 @@ public:
}
bool operator !=(const GrDrawState& s) const { return !(*this == s); }
- GrDrawState& operator= (const GrDrawState& s) {
- this->setRenderTarget(s.fRenderTarget.get());
- fCommon = s.fCommon;
+ // Most stages are usually not used, so conditionals here
+ // reduce the expected number of bytes touched by 50%.
+ GrDrawState& operator =(const GrDrawState& s) {
+ fColor = s.fColor;
+ fViewMatrix = s.fViewMatrix;
+ SkRefCnt_SafeAssign(fRenderTarget, s.fRenderTarget);
+ fSrcBlend = s.fSrcBlend;
+ fDstBlend = s.fDstBlend;
+ fBlendConstant = s.fBlendConstant;
+ fFlagBits = s.fFlagBits;
+ fVertexEdgeType = s.fVertexEdgeType;
+ fStencilSettings = s.fStencilSettings;
+ fFirstCoverageStage = s.fFirstCoverageStage;
+ fCoverage = s.fCoverage;
+ fColorFilterMode = s.fColorFilterMode;
+ fColorFilterColor = s.fColorFilterColor;
+ fDrawFace = s.fDrawFace;
+
for (int i = 0; i < kNumStages; i++) {
if (s.isStageEnabled(i)) {
this->fStages[i] = s.fStages[i];
}
}
+
return *this;
}
private:
- /** Fields that are identical in GrDrawState and GrDrawState::DeferredState. */
- struct CommonState {
- // These fields are roughly sorted by decreasing likelihood of being different in op==
- GrColor fColor;
- SkMatrix fViewMatrix;
- GrBlendCoeff fSrcBlend;
- GrBlendCoeff fDstBlend;
- GrColor fBlendConstant;
- uint32_t fFlagBits;
- VertexEdgeType fVertexEdgeType;
- GrStencilSettings fStencilSettings;
- int fFirstCoverageStage;
- GrColor fCoverage;
- SkXfermode::Mode fColorFilterMode;
- GrColor fColorFilterColor;
- DrawFace fDrawFace;
- bool operator== (const CommonState& other) const {
- return fColor == other.fColor &&
- fViewMatrix.cheapEqualTo(other.fViewMatrix) &&
- fSrcBlend == other.fSrcBlend &&
- fDstBlend == other.fDstBlend &&
- fBlendConstant == other.fBlendConstant &&
- fFlagBits == other.fFlagBits &&
- fVertexEdgeType == other.fVertexEdgeType &&
- fStencilSettings == other.fStencilSettings &&
- fFirstCoverageStage == other.fFirstCoverageStage &&
- fCoverage == other.fCoverage &&
- fColorFilterMode == other.fColorFilterMode &&
- fColorFilterColor == other.fColorFilterColor &&
- fDrawFace == other.fDrawFace;
- }
- bool operator!= (const CommonState& other) const { return !(*this == other); }
- };
-
- /** GrDrawState uses GrEffectStages to hold stage state which holds a ref on GrEffectRef.
- DeferredState must directly reference GrEffects, however. */
- struct SavedEffectStage {
- SavedEffectStage() : fEffect(NULL) {}
- const GrEffect* fEffect;
- GrEffectStage::SavedCoordChange fCoordChange;
- };
-
-public:
- /**
- * DeferredState contains all of the data of a GrDrawState but does not hold refs on GrResource
- * objects. Resources are allowed to hit zero ref count while in DeferredStates. Their internal
- * dispose mechanism returns them to the cache. This allows recycling resources through the
- * the cache while they are in a deferred draw queue.
- */
- class DeferredState {
- public:
- DeferredState() : fRenderTarget(NULL) {
- GR_DEBUGCODE(fInitialized = false;)
- }
- // TODO: Remove this when DeferredState no longer holds a ref to the RT
- ~DeferredState() { SkSafeUnref(fRenderTarget); }
-
- void saveFrom(const GrDrawState& drawState) {
- fCommon = drawState.fCommon;
- // TODO: Here we will copy the GrRenderTarget pointer without taking a ref.
- fRenderTarget = drawState.fRenderTarget.get();
- SkSafeRef(fRenderTarget);
- // Here we ref the effects directly rather than the effect-refs. TODO: When the effect-
- // ref gets fully unref'ed it will cause the underlying effect to unref its resources
- // and recycle them to the cache (if no one else is holding a ref to the resources).
- for (int i = 0; i < kNumStages; ++i) {
- fStages[i].saveFrom(drawState.fStages[i]);
- }
- GR_DEBUGCODE(fInitialized = true;)
- }
-
- void restoreTo(GrDrawState* drawState) {
- GrAssert(fInitialized);
- drawState->fCommon = fCommon;
- drawState->setRenderTarget(fRenderTarget);
- for (int i = 0; i < kNumStages; ++i) {
- fStages[i].restoreTo(&drawState->fStages[i]);
- }
- }
-
- bool isEqual(const GrDrawState& state) const {
- if (fRenderTarget != state.fRenderTarget.get() || fCommon != state.fCommon) {
- return false;
- }
- for (int i = 0; i < kNumStages; ++i) {
- if (fStages[i].isEqual(state.fStages[i])) {
- return false;
- }
- }
- return true;
- }
-
- private:
- GrRenderTarget* fRenderTarget;
- CommonState fCommon;
- GrEffectStage::DeferredStage fStages[kNumStages];
-
- GR_DEBUGCODE(bool fInitialized;)
- };
-
-private:
- SkAutoTUnref<GrRenderTarget> fRenderTarget;
- CommonState fCommon;
- GrEffectStage fStages[kNumStages];
+ // These fields are roughly sorted by decreasing likelihood of being different in op==
+ GrColor fColor;
+ SkMatrix fViewMatrix;
+ GrRenderTarget* fRenderTarget;
+ GrBlendCoeff fSrcBlend;
+ GrBlendCoeff fDstBlend;
+ GrColor fBlendConstant;
+ uint32_t fFlagBits;
+ VertexEdgeType fVertexEdgeType;
+ GrStencilSettings fStencilSettings;
+ int fFirstCoverageStage;
+ GrColor fCoverage;
+ SkXfermode::Mode fColorFilterMode;
+ GrColor fColorFilterColor;
+ DrawFace fDrawFace;
+
+ // This field must be last; it will not be copied or compared
+ // if the corresponding fTexture[] is NULL.
+ GrEffectStage fStages[kNumStages];
typedef GrRefCnt INHERITED;
};
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 233682ffb2..e327413226 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -570,11 +570,8 @@ bool GrInOrderDrawBuffer::flushTo(GrDrawTarget* target) {
GrDrawTarget::AutoClipRestore acr(target);
AutoGeometryPush agp(target);
-
- GrDrawState playbackState;
GrDrawState* prevDrawState = target->drawState();
prevDrawState->ref();
- target->setDrawState(&playbackState);
GrClipData clipData;
@@ -584,7 +581,6 @@ bool GrInOrderDrawBuffer::flushTo(GrDrawTarget* target) {
int currDraw = 0;
int currStencilPath = 0;
-
for (int c = 0; c < numCmds; ++c) {
switch (fCmds[c]) {
case kDraw_Cmd: {
@@ -615,7 +611,7 @@ bool GrInOrderDrawBuffer::flushTo(GrDrawTarget* target) {
break;
}
case kSetState_Cmd:
- fStates[currState].restoreTo(&playbackState);
+ target->setDrawState(&fStates[currState]);
++currState;
break;
case kSetClip_Cmd:
@@ -864,7 +860,7 @@ void GrInOrderDrawBuffer::geometrySourceWillPop(
}
bool GrInOrderDrawBuffer::needsNewState() const {
- return fStates.empty() || fStates.back().isEqual(this->getDrawState());
+ return fStates.empty() || fStates.back() != this->getDrawState();
}
bool GrInOrderDrawBuffer::needsNewClip() const {
@@ -887,8 +883,19 @@ void GrInOrderDrawBuffer::recordClip() {
fCmds.push_back(kSetClip_Cmd);
}
+void GrInOrderDrawBuffer::recordDefaultClip() {
+ fClips.push_back() = SkClipStack();
+ fClipOrigins.push_back() = SkIPoint::Make(0, 0);
+ fCmds.push_back(kSetClip_Cmd);
+}
+
void GrInOrderDrawBuffer::recordState() {
- fStates.push_back().saveFrom(this->getDrawState());
+ fStates.push_back(this->getDrawState());
+ fCmds.push_back(kSetState_Cmd);
+}
+
+void GrInOrderDrawBuffer::recordDefaultState() {
+ fStates.push_back(GrDrawState());
fCmds.push_back(kSetState_Cmd);
}
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index 35cccbd48c..1b893accd9 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -184,7 +184,9 @@ private:
// these functions record a command
void recordState();
+ void recordDefaultState();
void recordClip();
+ void recordDefaultClip();
Draw* recordDraw();
StencilPath* recordStencilPath();
Clear* recordClear();
@@ -203,11 +205,11 @@ private:
kGeoPoolStatePreAllocCnt = 4,
};
- SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds;
- GrSTAllocator<kDrawPreallocCnt, Draw> fDraws;
- GrSTAllocator<kStatePreallocCnt, StencilPath> fStencilPaths;
- GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates;
- GrSTAllocator<kClearPreallocCnt, Clear> fClears;
+ SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds;
+ GrSTAllocator<kDrawPreallocCnt, Draw> fDraws;
+ GrSTAllocator<kStatePreallocCnt, StencilPath> fStencilPaths;
+ GrSTAllocator<kStatePreallocCnt, GrDrawState> fStates;
+ GrSTAllocator<kClearPreallocCnt, Clear> fClears;
GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips;
GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrigins;