summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2010-09-22 19:49:04 -0700
committerRomain Guy <romainguy@android.com>2010-09-22 19:49:04 -0700
commite20ecbd12d26467754a7770d44bcce2ea92335ef (patch)
tree129cc4cfc5a5fd38c4a3be2ae665fcc25033cf9e /libs/hwui
parent29d8997bd43b7c4ad37fc3d6f91eaafa74913c88 (diff)
downloadframeworks_base-e20ecbd12d26467754a7770d44bcce2ea92335ef.zip
frameworks_base-e20ecbd12d26467754a7770d44bcce2ea92335ef.tar.gz
frameworks_base-e20ecbd12d26467754a7770d44bcce2ea92335ef.tar.bz2
Draw text decorations with lines instead of rectangles.
Change-Id: Icd25c85c3a24da96a3d2f76f9477da6f87e0303c
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/OpenGLRenderer.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 102a933..e62a693 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -961,25 +961,36 @@ void OpenGLRenderer::drawTextDecorations(const char* text, int bytesCount, float
}
if (underlineWidth > 0.0f) {
- float textSize = paint->getTextSize();
- float height = textSize * kStdUnderline_Thickness;
+ const float textSize = paint->getTextSize();
+ const float strokeWidth = textSize * kStdUnderline_Thickness;
- float left = x - offsetX;
+ const float left = x - offsetX;
float top = 0.0f;
- float right = left + underlineWidth;
- float bottom = 0.0f;
+
+ const int pointsCount = 4 * (flags & SkPaint::kStrikeThruText_Flag ? 2 : 1);
+ float points[pointsCount];
+ int currentPoint = 0;
if (flags & SkPaint::kUnderlineText_Flag) {
top = y + textSize * kStdUnderline_Offset;
- bottom = top + height;
- drawRect(left, top, right, bottom, paint);
+ points[currentPoint++] = left;
+ points[currentPoint++] = top;
+ points[currentPoint++] = left + underlineWidth;
+ points[currentPoint++] = top;
}
if (flags & SkPaint::kStrikeThruText_Flag) {
top = y + textSize * kStdStrikeThru_Offset;
- bottom = top + height;
- drawRect(left, top, right, bottom, paint);
+ points[currentPoint++] = left;
+ points[currentPoint++] = top;
+ points[currentPoint++] = left + underlineWidth;
+ points[currentPoint++] = top;
}
+
+ SkPaint linesPaint(*paint);
+ linesPaint.setStrokeWidth(strokeWidth);
+
+ drawLines(&points[0], pointsCount, &linesPaint);
}
}
}