Loading libs/hwui/SkiaCanvas.cpp +0 −8 Original line number Original line Diff line number Diff line Loading @@ -732,14 +732,10 @@ void SkiaCanvas::drawGlyphs(ReadGlyphFunc glyphFunc, int count, const SkPaint& p float y, float boundsLeft, float boundsTop, float boundsRight, float y, float boundsLeft, float boundsTop, float boundsRight, float boundsBottom, float totalAdvance) { float boundsBottom, float totalAdvance) { if (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. SkPaint paintCopy(paint); SkPaint paintCopy(paint); if (mPaintFilter) { if (mPaintFilter) { mPaintFilter->filter(&paintCopy); mPaintFilter->filter(&paintCopy); } } paintCopy.setTextAlign(SkPaint::kLeft_Align); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); // Stroke with a hairline is drawn on HW with a fill style for compatibility with Android O and // Stroke with a hairline is drawn on HW with a fill style for compatibility with Android O and // older. // older. Loading @@ -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, void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset, const SkPaint& paint, const SkPath& path, size_t start, const SkPaint& paint, const SkPath& path, size_t start, size_t end) { 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); SkPaint paintCopy(paint); if (mPaintFilter) { if (mPaintFilter) { mPaintFilter->filter(&paintCopy); mPaintFilter->filter(&paintCopy); } } paintCopy.setTextAlign(SkPaint::kLeft_Align); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); const int N = end - start; const int N = end - start; Loading libs/hwui/hwui/Paint.h +9 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,14 @@ public: const Typeface* getAndroidTypeface() const { return mTypeface; } 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: private: float mLetterSpacing = 0; float mLetterSpacing = 0; float mWordSpacing = 0; float mWordSpacing = 0; Loading @@ -98,6 +106,7 @@ private: // object. Thus, following pointer can never be a dangling pointer. Note that // object. Thus, following pointer can never be a dangling pointer. Note that // nullptr is valid: it means the default typeface. // nullptr is valid: it means the default typeface. const Typeface* mTypeface = nullptr; const Typeface* mTypeface = nullptr; Align mAlign = kLeft_Align; }; }; } // namespace android } // namespace android Loading libs/hwui/hwui/PaintImpl.cpp +4 −2 Original line number Original line Diff line number Diff line Loading @@ -34,7 +34,8 @@ Paint::Paint(const Paint& paint) , mMinikinLocaleListId(paint.mMinikinLocaleListId) , mMinikinLocaleListId(paint.mMinikinLocaleListId) , mFamilyVariant(paint.mFamilyVariant) , mFamilyVariant(paint.mFamilyVariant) , mHyphenEdit(paint.mHyphenEdit) , mHyphenEdit(paint.mHyphenEdit) , mTypeface(paint.mTypeface) {} , mTypeface(paint.mTypeface) , mAlign(paint.mAlign) {} Paint::Paint(const SkPaint& paint) Paint::Paint(const SkPaint& paint) : SkPaint(paint) : SkPaint(paint) Loading @@ -55,6 +56,7 @@ Paint& Paint::operator=(const Paint& other) { mFamilyVariant = other.mFamilyVariant; mFamilyVariant = other.mFamilyVariant; mHyphenEdit = other.mHyphenEdit; mHyphenEdit = other.mHyphenEdit; mTypeface = other.mTypeface; mTypeface = other.mTypeface; mAlign = other.mAlign; return *this; return *this; } } Loading @@ -64,6 +66,6 @@ bool operator==(const Paint& a, const Paint& b) { a.mFontFeatureSettings == b.mFontFeatureSettings && a.mFontFeatureSettings == b.mFontFeatureSettings && a.mMinikinLocaleListId == b.mMinikinLocaleListId && a.mMinikinLocaleListId == b.mMinikinLocaleListId && a.mFamilyVariant == b.mFamilyVariant && a.mHyphenEdit == b.mHyphenEdit && a.mFamilyVariant == b.mFamilyVariant && a.mHyphenEdit == b.mHyphenEdit && a.mTypeface == b.mTypeface; a.mTypeface == b.mTypeface && a.mAlign == b.mAlign; } } } // namespace android } // namespace android libs/hwui/tests/common/scenes/ListViewAnimation.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -46,7 +46,6 @@ class ListViewAnimation : public TestListViewSceneBase { SkColorGetR(randomColor) + SkColorGetG(randomColor) + SkColorGetB(randomColor) < SkColorGetR(randomColor) + SkColorGetG(randomColor) + SkColorGetB(randomColor) < 128 * 3; 128 * 3; paint.setColor(bgDark ? Color::White : Color::Grey_700); paint.setColor(bgDark ? Color::White : Color::Grey_700); paint.setTextAlign(SkPaint::kCenter_Align); paint.setTextSize(size / 2); paint.setTextSize(size / 2); char charToShow = 'A' + (rand() % 26); char charToShow = 'A' + (rand() % 26); const SkPoint pos[] = {{SkIntToScalar(size / 2), const SkPoint pos[] = {{SkIntToScalar(size / 2), Loading Loading
libs/hwui/SkiaCanvas.cpp +0 −8 Original line number Original line Diff line number Diff line Loading @@ -732,14 +732,10 @@ void SkiaCanvas::drawGlyphs(ReadGlyphFunc glyphFunc, int count, const SkPaint& p float y, float boundsLeft, float boundsTop, float boundsRight, float y, float boundsLeft, float boundsTop, float boundsRight, float boundsBottom, float totalAdvance) { float boundsBottom, float totalAdvance) { if (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. SkPaint paintCopy(paint); SkPaint paintCopy(paint); if (mPaintFilter) { if (mPaintFilter) { mPaintFilter->filter(&paintCopy); mPaintFilter->filter(&paintCopy); } } paintCopy.setTextAlign(SkPaint::kLeft_Align); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); // Stroke with a hairline is drawn on HW with a fill style for compatibility with Android O and // Stroke with a hairline is drawn on HW with a fill style for compatibility with Android O and // older. // older. Loading @@ -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, void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset, const SkPaint& paint, const SkPath& path, size_t start, const SkPaint& paint, const SkPath& path, size_t start, size_t end) { 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); SkPaint paintCopy(paint); if (mPaintFilter) { if (mPaintFilter) { mPaintFilter->filter(&paintCopy); mPaintFilter->filter(&paintCopy); } } paintCopy.setTextAlign(SkPaint::kLeft_Align); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); const int N = end - start; const int N = end - start; Loading
libs/hwui/hwui/Paint.h +9 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,14 @@ public: const Typeface* getAndroidTypeface() const { return mTypeface; } 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: private: float mLetterSpacing = 0; float mLetterSpacing = 0; float mWordSpacing = 0; float mWordSpacing = 0; Loading @@ -98,6 +106,7 @@ private: // object. Thus, following pointer can never be a dangling pointer. Note that // object. Thus, following pointer can never be a dangling pointer. Note that // nullptr is valid: it means the default typeface. // nullptr is valid: it means the default typeface. const Typeface* mTypeface = nullptr; const Typeface* mTypeface = nullptr; Align mAlign = kLeft_Align; }; }; } // namespace android } // namespace android Loading
libs/hwui/hwui/PaintImpl.cpp +4 −2 Original line number Original line Diff line number Diff line Loading @@ -34,7 +34,8 @@ Paint::Paint(const Paint& paint) , mMinikinLocaleListId(paint.mMinikinLocaleListId) , mMinikinLocaleListId(paint.mMinikinLocaleListId) , mFamilyVariant(paint.mFamilyVariant) , mFamilyVariant(paint.mFamilyVariant) , mHyphenEdit(paint.mHyphenEdit) , mHyphenEdit(paint.mHyphenEdit) , mTypeface(paint.mTypeface) {} , mTypeface(paint.mTypeface) , mAlign(paint.mAlign) {} Paint::Paint(const SkPaint& paint) Paint::Paint(const SkPaint& paint) : SkPaint(paint) : SkPaint(paint) Loading @@ -55,6 +56,7 @@ Paint& Paint::operator=(const Paint& other) { mFamilyVariant = other.mFamilyVariant; mFamilyVariant = other.mFamilyVariant; mHyphenEdit = other.mHyphenEdit; mHyphenEdit = other.mHyphenEdit; mTypeface = other.mTypeface; mTypeface = other.mTypeface; mAlign = other.mAlign; return *this; return *this; } } Loading @@ -64,6 +66,6 @@ bool operator==(const Paint& a, const Paint& b) { a.mFontFeatureSettings == b.mFontFeatureSettings && a.mFontFeatureSettings == b.mFontFeatureSettings && a.mMinikinLocaleListId == b.mMinikinLocaleListId && a.mMinikinLocaleListId == b.mMinikinLocaleListId && a.mFamilyVariant == b.mFamilyVariant && a.mHyphenEdit == b.mHyphenEdit && a.mFamilyVariant == b.mFamilyVariant && a.mHyphenEdit == b.mHyphenEdit && a.mTypeface == b.mTypeface; a.mTypeface == b.mTypeface && a.mAlign == b.mAlign; } } } // namespace android } // namespace android
libs/hwui/tests/common/scenes/ListViewAnimation.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -46,7 +46,6 @@ class ListViewAnimation : public TestListViewSceneBase { SkColorGetR(randomColor) + SkColorGetG(randomColor) + SkColorGetB(randomColor) < SkColorGetR(randomColor) + SkColorGetG(randomColor) + SkColorGetB(randomColor) < 128 * 3; 128 * 3; paint.setColor(bgDark ? Color::White : Color::Grey_700); paint.setColor(bgDark ? Color::White : Color::Grey_700); paint.setTextAlign(SkPaint::kCenter_Align); paint.setTextSize(size / 2); paint.setTextSize(size / 2); char charToShow = 'A' + (rand() % 26); char charToShow = 'A' + (rand() % 26); const SkPoint pos[] = {{SkIntToScalar(size / 2), const SkPoint pos[] = {{SkIntToScalar(size / 2), Loading