Chromium Code Reviews| Index: src/gpu/GrTextContext.cpp |
| diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp |
| index 804165b75c8b164311925eabeee4146c879a98e5..ad6fe8905ce396faec11794c1bfd5110b2ce3e82 100644 |
| --- a/src/gpu/GrTextContext.cpp |
| +++ b/src/gpu/GrTextContext.cpp |
| @@ -27,7 +27,10 @@ void GrTextContext::flushGlyphs() { |
| if (NULL == fDrawTarget) { |
| return; |
| } |
| + GrDrawTarget::AutoStateRestore asr(fDrawTarget, GrDrawTarget::kPreserve_ASRInit); |
|
bsalomon
2013/06/13 14:20:53
This will be replaced by a lighter weight auto-res
|
| GrDrawState* drawState = fDrawTarget->drawState(); |
| + drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); |
| + |
| if (fCurrVertex > 0) { |
| // setup our sampler state for our text texture/atlas |
| GrAssert(GrIsALIGN4(fCurrVertex)); |
| @@ -68,8 +71,6 @@ void GrTextContext::flushGlyphs() { |
| fCurrVertex = 0; |
| GrSafeSetNull(fCurrTexture); |
| } |
| - drawState->disableStages(); |
| - fDrawTarget = NULL; |
| } |
| GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint) : fPaint(paint) { |
| @@ -93,7 +94,7 @@ GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint) : fPaint( |
| fAutoMatrix.setIdentity(fContext, &fPaint); |
| - fDrawTarget = NULL; |
| + fDrawTarget = fContext->getTextTarget(); |
| fVertices = NULL; |
| fMaxVertices = 0; |
| @@ -101,9 +102,6 @@ GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint) : fPaint( |
| GrTextContext::~GrTextContext() { |
| this->flushGlyphs(); |
| - if (fDrawTarget) { |
| - fDrawTarget->drawState()->disableStages(); |
| - } |
| } |
| void GrTextContext::flush() { |
| @@ -123,6 +121,9 @@ extern const GrVertexAttrib gTextVertexAttribs[] = { |
| void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed, |
| GrFixed vx, GrFixed vy, |
| GrFontScaler* scaler) { |
| + if (NULL == fDrawTarget) { |
| + return; |
| + } |
| if (NULL == fStrike) { |
| fStrike = fContext->getFontCache()->getStrike(scaler); |
| } |
| @@ -205,17 +206,11 @@ 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; |
|
robertphillips
2013/06/13 16:26:08
overlength
|
| - bool flush = false; |
| - fDrawTarget = fContext->getTextTarget(fPaint); |
| - if (NULL != fDrawTarget) { |
| - fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(SK_ARRAY_COUNT(gTextVertexAttribs)); |
| - flush = fDrawTarget->geometryHints(&fMaxVertices, NULL); |
| - } |
| + fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(SK_ARRAY_COUNT(gTextVertexAttribs)); |
| + bool flush = fDrawTarget->geometryHints(&fMaxVertices, NULL); |
| if (flush) { |
| this->flushGlyphs(); |
| fContext->flush(); |
| - // flushGlyphs() will reset fDrawTarget to NULL. |
| - fDrawTarget = fContext->getTextTarget(fPaint); |
| fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(SK_ARRAY_COUNT(gTextVertexAttribs)); |
| } |
| fMaxVertices = kDefaultRequestedVerts; |
| @@ -229,11 +224,10 @@ HAS_ATLAS: |
| // don't exceed the limit of the index buffer |
| fMaxVertices = maxQuadVertices; |
| } |
| - bool success = fDrawTarget->reserveVertexAndIndexSpace( |
| - fMaxVertices, |
| - 0, |
| - GrTCast<void**>(&fVertices), |
| - NULL); |
| + bool success = fDrawTarget->reserveVertexAndIndexSpace(fMaxVertices, |
| + 0, |
| + GrTCast<void**>(&fVertices), |
| + NULL); |
| GrAlwaysAssert(success); |
| GrAssert(2*sizeof(GrPoint) == fDrawTarget->getDrawState().getVertexSize()); |
| } |