diff options
author | 2015-06-17 05:43:33 -0700 | |
---|---|---|
committer | 2015-06-17 05:43:33 -0700 | |
commit | 2334fb655f8d4ef5915770d32bf845c88d3627f4 (patch) | |
tree | a4bc1ef4636671f40201f6d4139ef092432d9810 /src/gpu/GrTextContext.cpp | |
parent | 48fc0ea272916a04f947bcd5bfce44fdab1f16b4 (diff) |
Make GrTextContext be owned by the GrDrawContext
This CL makes the GrTextContext be owned (and hidden) by the GrDrawContext. This funnels all the drawText* calls through the GrDrawContext and hides the (dispreferred) GrPipelineBuilder drawText variant.
Some consequences of this are:
GrDrawContext now has to get the text drawing settings (i.e., SkDeviceProperties & useDFT). This means that we need a separate GrDrawContext for each combination of pixel geometry and DFT-use.
All the GrTextContext-derived classes now get a back pointer to the originating GrDrawContext so their method calls no longer take one.
Committed: https://skia.googlesource.com/skia/+/5b16e740fe6ab6d679083d06f07651602265081b
Review URL: https://codereview.chromium.org/1175553002
Diffstat (limited to 'src/gpu/GrTextContext.cpp')
-rw-r--r-- | src/gpu/GrTextContext.cpp | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp index 91c8e85178..5559b2da6d 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -20,10 +20,12 @@ #include "SkTextMapStateProc.h" #include "SkTextToPathIter.h" -GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& properties) +GrTextContext::GrTextContext(GrContext* context, GrDrawContext* drawContext, + const SkDeviceProperties& properties) : fFallbackTextContext(NULL) , fContext(context) - , fDeviceProperties(properties) { + , fDeviceProperties(properties) + , fDrawContext(drawContext) { } GrTextContext::~GrTextContext() { @@ -47,19 +49,14 @@ void GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai const SkPaint& skPaint, const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkIRect& clipBounds) { - if (fContext->abandoned()) { - return; - } - - GrDrawContext* drawContext = fContext->drawContext(); - if (!drawContext) { + if (fContext->abandoned() || !fDrawContext) { return; } GrTextContext* textContext = this; do { if (textContext->canDraw(rt, clip, paint, skPaint, viewMatrix)) { - textContext->onDrawText(drawContext, rt, clip, paint, skPaint, viewMatrix, + textContext->onDrawText(rt, clip, paint, skPaint, viewMatrix, text, byteLength, x, y, clipBounds); return; } @@ -67,7 +64,7 @@ void GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai } while (textContext); // fall back to drawing as a path - this->drawTextAsPath(drawContext, rt, clip, skPaint, viewMatrix, + this->drawTextAsPath(rt, clip, skPaint, viewMatrix, text, byteLength, x, y, clipBounds); } @@ -76,19 +73,14 @@ void GrTextContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const Gr const char text[], size_t byteLength, const SkScalar pos[], int scalarsPerPosition, const SkPoint& offset, const SkIRect& clipBounds) { - if (fContext->abandoned()) { - return; - } - - GrDrawContext* drawContext = fContext->drawContext(); - if (!drawContext) { + if (fContext->abandoned() || !fDrawContext) { return; } GrTextContext* textContext = this; do { if (textContext->canDraw(rt, clip, paint, skPaint, viewMatrix)) { - textContext->onDrawPosText(drawContext, rt, clip, paint, skPaint, viewMatrix, + textContext->onDrawPosText(rt, clip, paint, skPaint, viewMatrix, text, byteLength, pos, scalarsPerPosition, offset, clipBounds); return; @@ -97,7 +89,7 @@ void GrTextContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const Gr } while (textContext); // fall back to drawing as a path - this->drawPosTextAsPath(drawContext, rt, clip, skPaint, viewMatrix, text, byteLength, pos, + this->drawPosTextAsPath(rt, clip, skPaint, viewMatrix, text, byteLength, pos, scalarsPerPosition, offset, clipBounds); } @@ -183,7 +175,7 @@ void GrTextContext::drawTextBlob(GrRenderTarget* rt, } } -void GrTextContext::drawTextAsPath(GrDrawContext* drawContext, GrRenderTarget* rt, +void GrTextContext::drawTextAsPath(GrRenderTarget* rt, const GrClip& clip, const SkPaint& skPaint, const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x, SkScalar y, @@ -201,14 +193,14 @@ void GrTextContext::drawTextAsPath(GrDrawContext* drawContext, GrRenderTarget* r matrix.postTranslate(xpos - prevXPos, 0); if (iterPath) { const SkPaint& pnt = iter.getPaint(); - GrBlurUtils::drawPathWithMaskFilter(fContext, drawContext, rt, clip, *iterPath, + GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, rt, clip, *iterPath, pnt, viewMatrix, &matrix, clipBounds, false); } prevXPos = xpos; } } -void GrTextContext::drawPosTextAsPath(GrDrawContext* drawContext, GrRenderTarget* rt, +void GrTextContext::drawPosTextAsPath(GrRenderTarget* rt, const GrClip& clip, const SkPaint& origPaint, const SkMatrix& viewMatrix, const char text[], size_t byteLength, @@ -249,7 +241,7 @@ void GrTextContext::drawPosTextAsPath(GrDrawContext* drawContext, GrRenderTarget matrix[SkMatrix::kMTransX] = loc.fX; matrix[SkMatrix::kMTransY] = loc.fY; - GrBlurUtils::drawPathWithMaskFilter(fContext, drawContext, rt, clip, *path, paint, + GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, rt, clip, *path, paint, viewMatrix, &matrix, clipBounds, false); } } |