diff options
-rw-r--r-- | libs/hwui/SkiaCanvas.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/hwui/Paint.h | 9 | ||||
-rw-r--r-- | libs/hwui/hwui/PaintImpl.cpp | 6 | ||||
-rw-r--r-- | libs/hwui/tests/common/scenes/ListViewAnimation.cpp | 1 |
4 files changed, 13 insertions, 11 deletions
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp index 2e5aef5347d5..9c707bab95f1 100644 --- a/libs/hwui/SkiaCanvas.cpp +++ b/libs/hwui/SkiaCanvas.cpp @@ -732,14 +732,10 @@ void SkiaCanvas::drawGlyphs(ReadGlyphFunc glyphFunc, int count, const SkPaint& p float y, float boundsLeft, float boundsTop, float boundsRight, float boundsBottom, float totalAdvance) { 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. SkPaint paintCopy(paint); if (mPaintFilter) { mPaintFilter->filter(&paintCopy); } - 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. @@ -763,14 +759,10 @@ void SkiaCanvas::drawGlyphs(ReadGlyphFunc glyphFunc, int count, const SkPaint& p void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset, const SkPaint& paint, const SkPath& path, size_t start, size_t end) { - // Set align to left for drawing, as we don't want individual - // glyphs centered or right-aligned; the offsets take care of - // that portion of the alignment. SkPaint paintCopy(paint); if (mPaintFilter) { mPaintFilter->filter(&paintCopy); } - paintCopy.setTextAlign(SkPaint::kLeft_Align); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); const int N = end - start; diff --git a/libs/hwui/hwui/Paint.h b/libs/hwui/hwui/Paint.h index 31d3c0d00b36..c1a3b6d1143b 100644 --- a/libs/hwui/hwui/Paint.h +++ b/libs/hwui/hwui/Paint.h @@ -86,6 +86,14 @@ public: const Typeface* getAndroidTypeface() const { return mTypeface; } + enum Align { + kLeft_Align, + kCenter_Align, + kRight_Align, + }; + Align getTextAlign() const { return mAlign; } + void setTextAlign(Align align) { mAlign = align; } + private: float mLetterSpacing = 0; float mWordSpacing = 0; @@ -98,6 +106,7 @@ private: // object. Thus, following pointer can never be a dangling pointer. Note that // nullptr is valid: it means the default typeface. const Typeface* mTypeface = nullptr; + Align mAlign = kLeft_Align; }; } // namespace android diff --git a/libs/hwui/hwui/PaintImpl.cpp b/libs/hwui/hwui/PaintImpl.cpp index 29cc890682f0..bdbf5cacaaf0 100644 --- a/libs/hwui/hwui/PaintImpl.cpp +++ b/libs/hwui/hwui/PaintImpl.cpp @@ -34,7 +34,8 @@ Paint::Paint(const Paint& paint) , mMinikinLocaleListId(paint.mMinikinLocaleListId) , mFamilyVariant(paint.mFamilyVariant) , mHyphenEdit(paint.mHyphenEdit) - , mTypeface(paint.mTypeface) {} + , mTypeface(paint.mTypeface) + , mAlign(paint.mAlign) {} Paint::Paint(const SkPaint& paint) : SkPaint(paint) @@ -55,6 +56,7 @@ Paint& Paint::operator=(const Paint& other) { mFamilyVariant = other.mFamilyVariant; mHyphenEdit = other.mHyphenEdit; mTypeface = other.mTypeface; + mAlign = other.mAlign; return *this; } @@ -64,6 +66,6 @@ bool operator==(const Paint& a, const Paint& b) { a.mFontFeatureSettings == b.mFontFeatureSettings && a.mMinikinLocaleListId == b.mMinikinLocaleListId && a.mFamilyVariant == b.mFamilyVariant && a.mHyphenEdit == b.mHyphenEdit && - a.mTypeface == b.mTypeface; + a.mTypeface == b.mTypeface && a.mAlign == b.mAlign; } } // namespace android diff --git a/libs/hwui/tests/common/scenes/ListViewAnimation.cpp b/libs/hwui/tests/common/scenes/ListViewAnimation.cpp index fd8c252ff318..9a1ee54bff49 100644 --- a/libs/hwui/tests/common/scenes/ListViewAnimation.cpp +++ b/libs/hwui/tests/common/scenes/ListViewAnimation.cpp @@ -46,7 +46,6 @@ class ListViewAnimation : public TestListViewSceneBase { SkColorGetR(randomColor) + SkColorGetG(randomColor) + SkColorGetB(randomColor) < 128 * 3; paint.setColor(bgDark ? Color::White : Color::Grey_700); - paint.setTextAlign(SkPaint::kCenter_Align); paint.setTextSize(size / 2); char charToShow = 'A' + (rand() % 26); const SkPoint pos[] = {{SkIntToScalar(size / 2), |