| Index: src/gpu/GrAtlasTextContext.cpp
|
| diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
|
| index 163601e836358bc482e97c1f4f9750e531450cf2..c72080529aac97784a19128f79128e0d2aaed942 100644
|
| --- a/src/gpu/GrAtlasTextContext.cpp
|
| +++ b/src/gpu/GrAtlasTextContext.cpp
|
| @@ -149,11 +149,7 @@ GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context,
|
| return new GrAtlasTextContext(context, surfaceProps);
|
| }
|
|
|
| -bool GrAtlasTextContext::canDraw(const GrRenderTarget*,
|
| - const GrClip&,
|
| - const GrPaint&,
|
| - const SkPaint& skPaint,
|
| - const SkMatrix& viewMatrix) {
|
| +bool GrAtlasTextContext::canDraw(const SkPaint& skPaint, const SkMatrix& viewMatrix) {
|
| return this->canDrawAsDistanceFields(skPaint, viewMatrix) ||
|
| !SkDraw::ShouldDrawTextAsPaths(skPaint, viewMatrix);
|
| }
|
| @@ -521,7 +517,7 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
|
| }
|
| }
|
| if (fallbackTxt.count()) {
|
| - this->fallbackDrawPosText(cacheBlob, run, rt, clip, color, runPaint, viewMatrix,
|
| + this->fallbackDrawPosText(cacheBlob, run, clip, color, runPaint, viewMatrix,
|
| fallbackTxt, fallbackPos, scalarsPerPosition, dfOffset,
|
| clipRect);
|
| }
|
| @@ -614,7 +610,7 @@ inline void GrAtlasTextContext::initDistanceFieldPaint(GrAtlasTextBlob* blob,
|
|
|
| inline void GrAtlasTextContext::fallbackDrawPosText(GrAtlasTextBlob* blob,
|
| int runIndex,
|
| - GrRenderTarget* rt, const GrClip& clip,
|
| + const GrClip& clip,
|
| GrColor color,
|
| const SkPaint& skPaint,
|
| const SkMatrix& viewMatrix,
|
| @@ -657,14 +653,14 @@ GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint,
|
| }
|
|
|
| inline GrAtlasTextBlob*
|
| -GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip,
|
| +GrAtlasTextContext::createDrawTextBlob(GrDrawContext* dc, const GrClip& clip,
|
| const GrPaint& paint, const SkPaint& skPaint,
|
| const SkMatrix& viewMatrix,
|
| const char text[], size_t byteLength,
|
| SkScalar x, SkScalar y, const SkIRect& regionClipBounds) {
|
| int glyphCount = skPaint.countText(text, byteLength);
|
| SkIRect clipRect;
|
| - clip.getConservativeBounds(rt->width(), rt->height(), &clipRect);
|
| + clip.getConservativeBounds(dc->width(), dc->height(), &clipRect);
|
|
|
| GrAtlasTextBlob* blob;
|
| if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) {
|
| @@ -679,7 +675,7 @@ GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip,
|
| byteLength, x, y, clipRect, textRatio, &fallbackTxt, &fallbackPos,
|
| &offset, skPaint);
|
| if (fallbackTxt.count()) {
|
| - this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
|
| + this->fallbackDrawPosText(blob, 0, clip, paint.getColor(), skPaint, viewMatrix,
|
| fallbackTxt, fallbackPos, 2, offset, clipRect);
|
| }
|
| } else {
|
| @@ -695,7 +691,7 @@ GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip,
|
| }
|
|
|
| inline GrAtlasTextBlob*
|
| -GrAtlasTextContext::createDrawPosTextBlob(GrRenderTarget* rt, const GrClip& clip,
|
| +GrAtlasTextContext::createDrawPosTextBlob(GrDrawContext* dc, const GrClip& clip,
|
| const GrPaint& paint, const SkPaint& skPaint,
|
| const SkMatrix& viewMatrix,
|
| const char text[], size_t byteLength,
|
| @@ -704,7 +700,7 @@ GrAtlasTextContext::createDrawPosTextBlob(GrRenderTarget* rt, const GrClip& clip
|
| int glyphCount = skPaint.countText(text, byteLength);
|
|
|
| SkIRect clipRect;
|
| - clip.getConservativeBounds(rt->width(), rt->height(), &clipRect);
|
| + clip.getConservativeBounds(dc->width(), dc->height(), &clipRect);
|
|
|
| GrAtlasTextBlob* blob;
|
| if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) {
|
| @@ -718,7 +714,7 @@ GrAtlasTextContext::createDrawPosTextBlob(GrRenderTarget* rt, const GrClip& clip
|
| byteLength, pos, scalarsPerPosition, offset, clipRect,
|
| textRatio, &fallbackTxt, &fallbackPos);
|
| if (fallbackTxt.count()) {
|
| - this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
|
| + this->fallbackDrawPosText(blob, 0, clip, paint.getColor(), skPaint, viewMatrix,
|
| fallbackTxt, fallbackPos, scalarsPerPosition, offset,
|
| clipRect);
|
| }
|
| @@ -740,7 +736,7 @@ void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt,
|
| const char text[], size_t byteLength,
|
| SkScalar x, SkScalar y, const SkIRect& regionClipBounds) {
|
| SkAutoTUnref<GrAtlasTextBlob> blob(
|
| - this->createDrawTextBlob(rt, clip, paint, skPaint, viewMatrix,
|
| + this->createDrawTextBlob(dc, clip, paint, skPaint, viewMatrix,
|
| text, byteLength, x, y, regionClipBounds));
|
| this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds);
|
| }
|
| @@ -753,7 +749,7 @@ void GrAtlasTextContext::onDrawPosText(GrDrawContext* dc, GrRenderTarget* rt,
|
| const SkScalar pos[], int scalarsPerPosition,
|
| const SkPoint& offset, const SkIRect& regionClipBounds) {
|
| SkAutoTUnref<GrAtlasTextBlob> blob(
|
| - this->createDrawPosTextBlob(rt, clip, paint, skPaint, viewMatrix,
|
| + this->createDrawPosTextBlob(dc, clip, paint, skPaint, viewMatrix,
|
| text, byteLength,
|
| pos, scalarsPerPosition,
|
| offset, regionClipBounds));
|
| @@ -1416,6 +1412,8 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
|
| SkASSERT(nullptr != texture->asRenderTarget());
|
| GrRenderTarget* rt = texture->asRenderTarget();
|
|
|
| + SkAutoTUnref<GrDrawContext> dc(context->drawContext(rt));
|
| +
|
| // Setup dummy SkPaint / GrPaint
|
| GrColor color = GrRandomColor(random);
|
| SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
|
| @@ -1440,7 +1438,7 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
|
| // right now we don't handle textblobs, nor do we handle drawPosText. Since we only
|
| // intend to test the batch with this unit test, that is okay.
|
| SkAutoTUnref<GrAtlasTextBlob> blob(
|
| - gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMatrix, text,
|
| + gTextContext->createDrawTextBlob(dc, clip, grPaint, skPaint, viewMatrix, text,
|
| static_cast<size_t>(textLen), 0, 0, noClip));
|
|
|
| SkScalar transX = static_cast<SkScalar>(random->nextU());
|
|
|