Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8c634f3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "move alignment to Paint (from SkPaint)"

parents 06432b66 16c142b4
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -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;
+9 −0
Original line number Diff line number Diff line
@@ -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
+4 −2
Original line number Diff line number Diff line
@@ -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
+0 −1
Original line number Diff line number Diff line
@@ -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),