From 7717e22c85fd2eaba39f1dc38c65fb7f723882f4 Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Mon, 5 Feb 2018 18:04:11 -0500 Subject: Draw text with a hairline stroke as if it is fill style Dew to a side effect of HWUI opengl pipeline, the hairline stroke is not respected, but it is drawn as a fill style. Implement the same behaviour for skiagl pipeline with SDK API 27 and older. On SDK released with Android P, the hairline stroke is respected. Bug: 72494357 Test: Ran duolingo app Change-Id: I48bdcf3ddec4bf65b5e93e01c5002177c4e3da90 --- libs/hwui/SkiaCanvas.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libs/hwui/SkiaCanvas.cpp') diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp index 9e0d10d07892..2b0b22df7edf 100644 --- a/libs/hwui/SkiaCanvas.cpp +++ b/libs/hwui/SkiaCanvas.cpp @@ -742,6 +742,12 @@ void SkiaCanvas::drawGlyphs(ReadGlyphFunc glyphFunc, int count, const SkPaint& p SkPaint paintCopy(paint); paintCopy.setTextAlign(SkPaint::kLeft_Align); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); + // Stroke with a hairline is drawn on HW with a fill style for compatibility with Android O and + // older. + if (!mCanvasOwned && sApiLevel <= 27 && paintCopy.getStrokeWidth() <= 0 + && paintCopy.getStyle() == SkPaint::kStroke_Style) { + paintCopy.setStyle(SkPaint::kFill_Style); + } SkRect bounds = SkRect::MakeLTRB(boundsLeft + x, boundsTop + y, boundsRight + x, boundsBottom + y); -- cgit v1.2.3-59-g8ed1b