diff options
author | 2017-03-30 18:22:27 -0400 | |
---|---|---|
committer | 2017-04-04 15:43:12 -0400 | |
commit | 0b58d9928309e2c64c7cafad287e55a8151ab19a (patch) | |
tree | 9b698e70c4dda4dcdf0c1aabe03deae6774363d3 /libs/hwui/SkiaCanvas.cpp | |
parent | 7ead6c4da9e73a485965070903277dae90210c2d (diff) |
Optimize Canvas::drawGlyphs
Avoid one memcpy in Canvas::drawGlyphs for all pipelines.
Test: CTS passed with exception of SweepTests#testBasicDraws
shadowtext, which fails with and without this CL.
Change-Id: I0841232dc7a6173eb3b03f939dbde15a84186296
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 daf14af87288..ab4d314e0c95 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); |