diff options
author | 2017-04-04 21:36:06 +0000 | |
---|---|---|
committer | 2017-04-04 21:36:10 +0000 | |
commit | 9d64a418bb03f111089eed4969d6379a59508f12 (patch) | |
tree | 1d064e897d3f46516f19f9cd7ee88d793ca559ed /libs/hwui/SkiaCanvas.cpp | |
parent | f4628d92e0fed4bf63d630a3bf92eae09c64afe3 (diff) | |
parent | 0b58d9928309e2c64c7cafad287e55a8151ab19a (diff) |
Merge "Optimize Canvas::drawGlyphs"
Diffstat (limited to 'libs/hwui/SkiaCanvas.cpp')
-rw-r--r-- | libs/hwui/SkiaCanvas.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp index f91ea769ffc8..d344528c01ef 100644 --- a/libs/hwui/SkiaCanvas.cpp +++ b/libs/hwui/SkiaCanvas.cpp @@ -679,11 +679,10 @@ void SkiaCanvas::drawVectorDrawable(VectorDrawableRoot* vectorDrawable) { // Canvas draw operations: Text // ---------------------------------------------------------------------------- -void SkiaCanvas::drawGlyphs(const uint16_t* text, const float* positions, int count, - const SkPaint& paint, float x, float y, - float boundsLeft, float boundsTop, float boundsRight, float boundsBottom, +void SkiaCanvas::drawGlyphs(ReadGlyphFunc glyphFunc, int count, const SkPaint& paint, float x, + float y, float boundsLeft, float boundsTop, float boundsRight, float boundsBottom, float totalAdvance) { - if (!text || !positions || count <= 0 || paint.nothingToDraw()) return; + if (count <= 0 || paint.nothingToDraw()) return; // Set align to left for drawing, as we don't want individual // glyphs centered or right-aligned; the offset above takes // care of all alignment. @@ -695,10 +694,7 @@ void SkiaCanvas::drawGlyphs(const uint16_t* text, const float* positions, int co SkTextBlobBuilder builder; const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPos(paintCopy, count, &bounds); - // TODO: we could reduce the number of memcpy's if the this were exposed further up - // in the architecture. - memcpy(buffer.glyphs, text, count * sizeof(uint16_t)); - memcpy(buffer.pos, positions, (count << 1) * sizeof(float)); + glyphFunc(buffer.glyphs, buffer.pos); sk_sp<SkTextBlob> textBlob(builder.make()); mCanvas->drawTextBlob(textBlob, 0, 0, paintCopy); |