summaryrefslogtreecommitdiffstats
path: root/libs/hwui/SkiaCanvasProxy.cpp
diff options
context:
space:
mode:
authorTom Hudson <tomhudson@google.com>2015-02-19 17:11:32 -0500
committerDerek Sollenberger <djsollen@google.com>2015-02-20 13:08:47 +0000
commit806a6f07a37c16b37631d8707dd1f2b41276fafc (patch)
treebbdcf4119ea0b32d64d754e4cf1b20d7b1b5ce22 /libs/hwui/SkiaCanvasProxy.cpp
parentf580c91618fa5d5f783f33db8136734cde6d6862 (diff)
downloadframeworks_base-806a6f07a37c16b37631d8707dd1f2b41276fafc.zip
frameworks_base-806a6f07a37c16b37631d8707dd1f2b41276fafc.tar.gz
frameworks_base-806a6f07a37c16b37631d8707dd1f2b41276fafc.tar.bz2
Fix onDrawText for non-absolute positioning
If we were drawing text with drawTextAbsolutePos() false, we would draw the first character at 0,0 but subsequent characters would get improperly offset by y. (or x if vertical text) Change-Id: I4e76cd9d95bf1bb6ac021d99ef7cdd6333a290ba
Diffstat (limited to 'libs/hwui/SkiaCanvasProxy.cpp')
-rw-r--r--libs/hwui/SkiaCanvasProxy.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/libs/hwui/SkiaCanvasProxy.cpp b/libs/hwui/SkiaCanvasProxy.cpp
index de5f91c..3c65705 100644
--- a/libs/hwui/SkiaCanvasProxy.cpp
+++ b/libs/hwui/SkiaCanvasProxy.cpp
@@ -228,21 +228,23 @@ void SkiaCanvasProxy::onDrawText(const void* text, size_t byteLength, SkScalar x
}
// setup the first glyph position and adjust bounds if needed
+ int xBaseline = 0;
+ int yBaseline = 0;
if (mCanvas->drawTextAbsolutePos()) {
bounds.offset(x,y);
- pointStorage[0].set(x, y);
- } else {
- pointStorage[0].set(0, 0);
+ xBaseline = x;
+ yBaseline = y;
}
+ pointStorage[0].set(xBaseline, yBaseline);
// setup the remaining glyph positions
if (glyphs.paint.isVerticalText()) {
for (int i = 1; i < glyphs.count; i++) {
- pointStorage[i].set(x, glyphWidths[i-1] + pointStorage[i-1].fY);
+ pointStorage[i].set(xBaseline, glyphWidths[i-1] + pointStorage[i-1].fY);
}
} else {
for (int i = 1; i < glyphs.count; i++) {
- pointStorage[i].set(glyphWidths[i-1] + pointStorage[i-1].fX, y);
+ pointStorage[i].set(glyphWidths[i-1] + pointStorage[i-1].fX, yBaseline);
}
}