From cb325ceda16fab97fd3281785e6ae10fcb8dcf83 Mon Sep 17 00:00:00 2001 From: "tomhudson@google.com" Date: Wed, 11 Jul 2012 14:41:19 +0000 Subject: Change TextContext handling of stages and draw targets; this allows us to assert in GrContext::setPaint() that all stages are disabled every time the paint is set. Watch for possible performance implications. http://codereview.appspot.com/6347043/ git-svn-id: http://skia.googlecode.com/svn/trunk@4531 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrContext.cpp | 3 +-- src/gpu/GrTextContext.cpp | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index f756f8a348..b004f28ba0 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -1589,8 +1589,7 @@ void GrContext::internalWriteRenderTargetPixels(GrRenderTarget* target, //////////////////////////////////////////////////////////////////////////////// void GrContext::setPaint(const GrPaint& paint) { - // TODO: reenable this once we've cleaned up text state management - //GrAssert(fDrawState->stagesDisabled()); + GrAssert(fDrawState->stagesDisabled()); for (int i = 0; i < GrPaint::kMaxTextures; ++i) { int s = i + GrPaint::kFirstTextureStage; diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp index daf48bf522..5b61be29fb 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -23,8 +23,11 @@ enum { }; void GrTextContext::flushGlyphs() { + if (NULL == fDrawTarget) { + return; + } + GrDrawState* drawState = fDrawTarget->drawState(); if (fCurrVertex > 0) { - GrDrawState* drawState = fDrawTarget->drawState(); // setup our sampler state for our text texture/atlas GrSamplerState::Filter filter; if (fExtMatrix.isIdentity()) { @@ -68,8 +71,9 @@ void GrTextContext::flushGlyphs() { fMaxVertices = 0; fCurrVertex = 0; GrSafeSetNull(fCurrTexture); - drawState->disableStage(kGlyphMaskStage); } + drawState->disableStages(); + fDrawTarget = NULL; } GrTextContext::GrTextContext(GrContext* context, @@ -134,7 +138,7 @@ GrTextContext::GrTextContext(GrContext* context, } } - fDrawTarget = fContext->getTextTarget(fPaint); + fDrawTarget = NULL; fVertices = NULL; fMaxVertices = 0; @@ -246,19 +250,20 @@ HAS_ATLAS: // If we need to reserve vertices allow the draw target to suggest // a number of verts to reserve and whether to perform a flush. fMaxVertices = kMinRequestedVerts; - bool flush = fDrawTarget->geometryHints(fVertexLayout, + bool flush = (NULL != fDrawTarget) && + fDrawTarget->geometryHints(fVertexLayout, &fMaxVertices, NULL); if (flush) { this->flushGlyphs(); fContext->flush(); - fDrawTarget = fContext->getTextTarget(fPaint); - fMaxVertices = kDefaultRequestedVerts; - // ignore return, no point in flushing again. - fDrawTarget->geometryHints(fVertexLayout, - &fMaxVertices, - NULL); } + fDrawTarget = fContext->getTextTarget(fPaint); + fMaxVertices = kDefaultRequestedVerts; + // ignore return, no point in flushing again. + fDrawTarget->geometryHints(fVertexLayout, + &fMaxVertices, + NULL); int maxQuadVertices = 4 * fContext->getQuadIndexBuffer()->maxQuads(); if (fMaxVertices < kMinRequestedVerts) { -- cgit v1.2.3