diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 26 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.h | 25 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.cpp | 10 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 6 |
4 files changed, 15 insertions, 52 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 5cce435916..6d52c2a0da 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -474,9 +474,6 @@ GrDrawTarget::GrDrawTarget() { #if GR_DEBUG VertexLayoutUnitTest(); #endif - fDrawState = &fDefaultDrawState; - // We assume that fDrawState always owns a ref to the object it points at. - fDefaultDrawState.ref(); GeometrySrcState& geoSrc = fGeoSrcStateStack.push_back(); #if GR_DEBUG geoSrc.fVertexCount = DEBUG_INVAL_START_IDX; @@ -493,7 +490,6 @@ GrDrawTarget::~GrDrawTarget() { GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); GrAssert(kNone_GeometrySrcType == geoSrc.fIndexSrc); GrAssert(kNone_GeometrySrcType == geoSrc.fVertexSrc); - fDrawState->unref(); } void GrDrawTarget::releaseGeometry() { @@ -515,28 +511,16 @@ const GrClip& GrDrawTarget::getClip() const { return fClip; } -void GrDrawTarget::setDrawState(GrDrawState* drawState) { - GrAssert(NULL != fDrawState); - if (NULL == drawState) { - drawState = &fDefaultDrawState; - } - if (fDrawState != drawState) { - fDrawState->unref(); - drawState->ref(); - fDrawState = drawState; - } -} - void GrDrawTarget::saveCurrentDrawState(SavedDrawState* state) const { - state->fState.set(this->getDrawState()); + state->fState.set(fCurrDrawState); } void GrDrawTarget::restoreDrawState(const SavedDrawState& state) { - *fDrawState = *state.fState.get(); + fCurrDrawState = *state.fState.get(); } void GrDrawTarget::copyDrawState(const GrDrawTarget& srcTarget) { - *fDrawState = srcTarget.getDrawState(); + fCurrDrawState = srcTarget.fCurrDrawState; } bool GrDrawTarget::reserveVertexSpace(GrVertexLayout vertexLayout, @@ -871,7 +855,7 @@ bool GrDrawTarget::srcAlphaWillBeOne() const { } // Check if a color stage could create a partial alpha for (int s = 0; s < drawState.getFirstCoverageStage(); ++s) { - if (StageWillBeUsed(s, layout, this->getDrawState())) { + if (StageWillBeUsed(s, layout, fCurrDrawState)) { GrAssert(NULL != drawState.getTexture(s)); GrPixelConfig config = drawState.getTexture(s)->config(); if (!GrPixelConfigIsOpaque(config)) { @@ -948,7 +932,7 @@ GrDrawTarget::getBlendOpts(bool forceCoverage, for (int s = drawState.getFirstCoverageStage(); !hasCoverage && s < GrDrawState::kNumStages; ++s) { - if (StageWillBeUsed(s, layout, this->getDrawState())) { + if (StageWillBeUsed(s, layout, fCurrDrawState)) { hasCoverage = true; } } diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 731cae5d25..3a85767038 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -86,24 +86,8 @@ public: */ const GrClip& getClip() const; - /** - * Sets the draw state object for the draw target. Note that this does not - * make a copy. The GrDrawTarget will take a reference to passed object. - * Passing NULL will cause the GrDrawTarget to use its own internal draw - * state object rather than an externally provided one. - */ - void setDrawState(GrDrawState* drawState); - - /** - * Read-only access to the GrDrawTarget's current draw state. - */ - const GrDrawState& getDrawState() const { return *fDrawState; } - - /** - * Read-write access to the GrDrawTarget's current draw state. Note that - * this doesn't ref. - */ - GrDrawState* drawState() { return fDrawState; } + const GrDrawState& getDrawState() const { return fCurrDrawState; } + GrDrawState* drawState() { return &fCurrDrawState; } /** * Shortcut for drawState()->preConcatSamplerMatrices() on all enabled @@ -978,7 +962,7 @@ protected: bool isStageEnabled(int stage) const { return StageWillBeUsed(stage, this->getGeomSrc().fVertexLayout, - this->getDrawState()); + fCurrDrawState); } StageMask enabledStages() const { @@ -1057,8 +1041,7 @@ protected: GrClip fClip; - GrDrawState* fDrawState; - GrDrawState fDefaultDrawState; + GrDrawState fCurrDrawState; Caps fCaps; diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 37cac0fa65..05f9a3f878 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -509,10 +509,9 @@ void GrInOrderDrawBuffer::playback(GrDrawTarget* target) { fVertexPool.unlock(); fIndexPool.unlock(); + GrDrawTarget::AutoStateRestore asr(target); GrDrawTarget::AutoClipRestore acr(target); AutoGeometryPush agp(target); - GrDrawState* prevDrawState = target->drawState(); - prevDrawState->ref(); int currState = ~0; int currClip = ~0; @@ -528,8 +527,7 @@ void GrInOrderDrawBuffer::playback(GrDrawTarget* target) { const Draw& draw = fDraws[i]; if (draw.fStateChanged) { ++currState; - GrDrawState* ds = &GrDrawTarget::accessSavedDrawState(fStates[currState]); - target->setDrawState(ds); + target->restoreDrawState(fStates[currState]); } if (draw.fClipChanged) { ++currClip; @@ -559,8 +557,6 @@ void GrInOrderDrawBuffer::playback(GrDrawTarget* target) { target->clear(&fClears[currClear].fRect, fClears[currClear].fColor); ++currClear; } - target->setDrawState(prevDrawState); - prevDrawState->unref(); } void GrInOrderDrawBuffer::setAutoFlushTarget(GrDrawTarget* target) { @@ -780,7 +776,7 @@ bool GrInOrderDrawBuffer::needsNewState() const { return true; } else { const GrDrawState& old = this->accessSavedDrawState(fStates.back()); - return old != this->getDrawState(); + return old != fCurrDrawState; } } diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 8754ac3d90..10b42c06e4 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -1911,7 +1911,7 @@ void GrGpuGL::flushBlend(GrPrimitiveType type, gXfermodeCoeff2Blend[dstCoeff])); fHWDrawState.setBlendFunc(srcCoeff, dstCoeff); } - GrColor blendConst = this->getDrawState().getBlendConstant(); + GrColor blendConst = fCurrDrawState.getBlendConstant(); if ((BlendCoeffReferencesConstant(srcCoeff) || BlendCoeffReferencesConstant(dstCoeff)) && fHWDrawState.getBlendConstant() != blendConst) { @@ -2099,7 +2099,7 @@ bool GrGpuGL::flushGLStateCommon(GrPrimitiveType type) { } if (fHWDrawState.getDrawFace() != drawState->getDrawFace()) { - switch (this->getDrawState().getDrawFace()) { + switch (fCurrDrawState.getDrawFace()) { case GrDrawState::kCCW_DrawFace: GL_CALL(Enable(GR_GL_CULL_FACE)); GL_CALL(CullFace(GR_GL_BACK)); @@ -2178,7 +2178,7 @@ void GrGpuGL::notifyTextureDelete(GrGLTexture* texture) { for (int s = 0; s < GrDrawState::kNumStages; ++s) { GrDrawState* drawState = this->drawState(); if (drawState->getTexture(s) == texture) { - this->drawState()->setTexture(s, NULL); + fCurrDrawState.setTexture(s, NULL); } if (fHWDrawState.getTexture(s) == texture) { // deleting bound texture does implied bind to 0 |