diff options
author | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 14:41:19 +0000 |
---|---|---|
committer | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 14:41:19 +0000 |
commit | cb325ceda16fab97fd3281785e6ae10fcb8dcf83 (patch) | |
tree | 02b2b3ca690ce52f7b8a6577fd6ddc23e6ce29b6 /src/gpu/GrTextContext.cpp | |
parent | 96dde455188311973b7a9d2beabe9c38a87b3623 (diff) |
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
Diffstat (limited to 'src/gpu/GrTextContext.cpp')
-rw-r--r-- | src/gpu/GrTextContext.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
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) { |