diff options
author | Herb Derby <herb@google.com> | 2018-06-07 12:44:09 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-08 19:25:43 +0000 |
commit | 59d997a6e1d32f2d0a3021931aed87984d15a7ee (patch) | |
tree | e5f920dc6f1b33b4fcde0f1058738512e376021b /src/gpu/text/GrTextContext.cpp | |
parent | f0aacafe9e7a74475493c71c4c3679e80a8b2a82 (diff) |
New more efficient run builder
A system for building glyph runs. In the future the builder will
only live in canvas, but it's internal structures facilitate
interacting with the cache a single glyph at a time. When all
the bulk code is in place, only runs will be passed around.
Passing the builder down the text draw stack is temporary.
Change-Id: I6e3ed184b3f3a58b919377f2d31936e971bd8efa
Reviewed-on: https://skia-review.googlesource.com/132928
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/gpu/text/GrTextContext.cpp')
-rw-r--r-- | src/gpu/text/GrTextContext.cpp | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp index 9864d027de..b8fe456b79 100644 --- a/src/gpu/text/GrTextContext.cpp +++ b/src/gpu/text/GrTextContext.cpp @@ -210,15 +210,18 @@ void GrTextContext::regenerateTextBlob(GrTextBlob* cacheBlob, shaderCaps.supportsDistanceFieldText(), fOptions)) { switch (it.positioning()) { case SkTextBlob::kDefault_Positioning: { - SkGlyphSet glyphSet; auto origin = SkPoint::Make(x + offset.x(), y + offset.y()); - auto glyphRun = - SkGlyphRun::MakeFromDrawText(runPaint.skPaint(), - (const char*)it.glyphs(), textLen, origin, &glyphSet); - - this->drawDFPosText(cacheBlob, run, glyphCache, props, runPaint, - scalerContextFlags, viewMatrix, (const char*)it.glyphs(), - textLen, glyphRun.getPositions(), 2, SkPoint::Make(0,0)); + SkGlyphRunBuilder builder; + builder.prepareDrawText(runPaint.skPaint(), + (const char*)it.glyphs(), textLen, origin); + + builder.temporaryShuntToCallback( + [&](size_t runSize, const char* glyphIDs, const SkScalar* pos) { + this->drawDFPosText( + cacheBlob, run, glyphCache, props, runPaint, scalerContextFlags, + viewMatrix, glyphIDs, 2 * runSize, pos, 2, + SkPoint::Make(0,0)); + }); break; } @@ -240,16 +243,18 @@ void GrTextContext::regenerateTextBlob(GrTextBlob* cacheBlob, } else { switch (it.positioning()) { case SkTextBlob::kDefault_Positioning: { - SkGlyphSet glyphSet; auto origin = SkPoint::Make(x + offset.x(), y + offset.y()); - auto glyphRun = - SkGlyphRun::MakeFromDrawText( - runPaint.skPaint(), (const char*) it.glyphs(), textLen, origin, - &glyphSet); - - this->DrawBmpPosText(cacheBlob, run, glyphCache, props, runPaint, - scalerContextFlags, viewMatrix, (const char*) it.glyphs(), - textLen, glyphRun.getPositions(), 2, SkPoint::Make(0, 0)); + SkGlyphRunBuilder builder; + builder.prepareDrawText(runPaint.skPaint(), + (const char*)it.glyphs(), textLen, origin); + + builder.temporaryShuntToCallback( + [&](size_t runSize, const char* glyphIDs, const SkScalar* pos) { + this->DrawBmpPosText( + cacheBlob, run, glyphCache, props, runPaint, scalerContextFlags, + viewMatrix, glyphIDs, 2 * runSize, + pos, 2, SkPoint::Make(0, 0)); + }); break; } case SkTextBlob::kHorizontal_Positioning: @@ -768,15 +773,20 @@ std::unique_ptr<GrDrawOp> GrTextContext::createOp_TestingOnly(GrContext* context // right now we don't handle textblobs, nor do we handle drawPosText. Since we only intend to // test the text op with this unit test, that is okay. - SkGlyphSet glyphSet; auto origin = SkPoint::Make(x, y); - auto glyphRun = SkGlyphRun::MakeFromDrawText(skPaint, text, textLen, origin, &glyphSet); - - sk_sp<GrTextBlob> blob(textContext->makeDrawPosTextBlob( - context->contextPriv().getTextBlobCache(), glyphCache, - *context->contextPriv().caps()->shaderCaps(), utilsPaint, - GrTextContext::kTextBlobOpScalerContextFlags, viewMatrix, surfaceProps, text, - static_cast<size_t>(textLen), glyphRun.getPositions(), 2, origin)); + SkGlyphRunBuilder builder; + builder.prepareDrawText(skPaint, text, textLen, origin); + sk_sp<GrTextBlob> blob; + + // Use the text and textLen below, because we don't want to mess with the paint. + builder.temporaryShuntToCallback( + [&](size_t runSize, const char* glyphIDs, const SkScalar* pos) { + blob = textContext->makeDrawPosTextBlob( + context->contextPriv().getTextBlobCache(), glyphCache, + *context->contextPriv().caps()->shaderCaps(), utilsPaint, + GrTextContext::kTextBlobOpScalerContextFlags, viewMatrix, surfaceProps, text, + textLen, pos, 2, origin); + }); return blob->test_makeOp(textLen, 0, 0, viewMatrix, x, y, utilsPaint, surfaceProps, textContext->dfAdjustTable(), rtc->textTarget()); |