Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Unified Diff: src/gpu/GrTextContext.cpp

Issue 16928010: Make text context responsible for setting GrPaint on GrDrawState. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698