Paint all backgrounds first to prevent overlap (flutter/engine#7287)

This commit is contained in:
Gary Qian 2019-01-02 16:22:05 -05:00 committed by GitHub
parent deff80f12e
commit bfbb7a080b

View File

@ -923,6 +923,11 @@ sk_sp<SkTypeface> Paragraph::GetDefaultSkiaTypeface(const TextStyle& style) {
void Paragraph::Paint(SkCanvas* canvas, double x, double y) {
SkPoint base_offset = SkPoint::Make(x, y);
SkPaint paint;
// Paint the background first before painting any text to prevent
// potential overlap.
for (const PaintRecord& record : records_) {
PaintBackground(canvas, record, base_offset);
}
for (const PaintRecord& record : records_) {
if (record.style().has_foreground) {
paint = record.style().foreground;
@ -931,7 +936,6 @@ void Paragraph::Paint(SkCanvas* canvas, double x, double y) {
paint.setColor(record.style().color);
}
SkPoint offset = base_offset + record.offset();
PaintBackground(canvas, record, base_offset);
PaintShadow(canvas, record, offset);
canvas->drawTextBlob(record.text(), offset.x(), offset.y(), paint);
PaintDecorations(canvas, record, base_offset);