From 13449ce2439044c06847c5f9487352d98931d11d Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Fri, 27 Jul 2018 16:23:27 -0400 Subject: Make SkInternalAtlasTextTarget use glyph runs Change-Id: I14f296c9d394288d2c28ab7f09b17c1a4d1ef49d Reviewed-on: https://skia-review.googlesource.com/144125 Commit-Queue: Brian Salomon Reviewed-by: Brian Salomon Auto-Submit: Herb Derby --- src/atlastext/SkAtlasTextTarget.cpp | 12 ++++++++---- src/core/SkGlyphRun.cpp | 10 ++++++++++ src/core/SkGlyphRun.h | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/atlastext/SkAtlasTextTarget.cpp b/src/atlastext/SkAtlasTextTarget.cpp index c70e47995a..4d7d65d746 100644 --- a/src/atlastext/SkAtlasTextTarget.cpp +++ b/src/atlastext/SkAtlasTextTarget.cpp @@ -14,6 +14,7 @@ #include "SkAtlasTextContext.h" #include "SkAtlasTextFont.h" #include "SkAtlasTextRenderer.h" +#include "SkGlyphRun.h" #include "SkGr.h" #include "SkInternalAtlasTextContext.h" #include "ops/GrAtlasTextOp.h" @@ -152,10 +153,13 @@ void SkInternalAtlasTextTarget::drawText(const SkGlyphID glyphs[], const SkPoint auto* grContext = this->context()->internal().grContext(); auto bounds = SkIRect::MakeWH(fWidth, fHeight); auto atlasTextContext = grContext->contextPriv().drawingManager()->getTextContext(); - size_t byteLength = sizeof(SkGlyphID) * glyphCnt; - const SkScalar* pos = &positions->fX; - atlasTextContext->drawPosText(grContext, this, GrNoClip(), paint, this->ctm(), props, - (const char*)glyphs, byteLength, pos, 2, {0, 0}, bounds); + SkGlyphRunBuilder builder; + builder.drawGlyphPos(paint, SkSpan{glyphs, SkTo(glyphCnt)}, positions); + auto glyphRunList = builder.useGlyphRunList(); + if (!glyphRunList.empty()) { + atlasTextContext->drawGlyphRunList(grContext, this, GrNoClip(), this->ctm(), props, + glyphRunList, bounds); + } } void SkInternalAtlasTextTarget::addDrawOp(const GrClip& clip, std::unique_ptr op) { diff --git a/src/core/SkGlyphRun.cpp b/src/core/SkGlyphRun.cpp index 006a4ba067..f53f90986e 100644 --- a/src/core/SkGlyphRun.cpp +++ b/src/core/SkGlyphRun.cpp @@ -534,6 +534,16 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo this->makeGlyphRunList(paint, &blob, origin); } +void SkGlyphRunBuilder::drawGlyphPos( + const SkPaint& paint, SkSpan glyphIDs, const SkPoint* pos) { + if (!glyphIDs.empty()) { + this->initialize(glyphIDs.size()); + this->simplifyDrawPosText(paint, glyphIDs, pos, + fUniqueGlyphIDIndices, fUniqueGlyphIDs); + this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0)); + } +} + const SkGlyphRunList& SkGlyphRunBuilder::useGlyphRunList() { return fGlyphRunList; } diff --git a/src/core/SkGlyphRun.h b/src/core/SkGlyphRun.h index 003c13c91c..26590c1251 100644 --- a/src/core/SkGlyphRun.h +++ b/src/core/SkGlyphRun.h @@ -240,6 +240,8 @@ public: void drawPosText( const SkPaint& paint, const void* bytes, size_t byteLength, const SkPoint* pos); void drawTextBlob(const SkPaint& paint, const SkTextBlob& blob, SkPoint origin); + void drawGlyphPos( + const SkPaint& paint, SkSpan glyphIDs, const SkPoint* pos); const SkGlyphRunList& useGlyphRunList(); -- cgit v1.2.3