Remove obsolete SkPaint foreground/background attributes from TextStyle (flutter/engine#40059)

Remove obsolete SkPaint foreground/background attributes from TextStyle
This commit is contained in:
Jason Simmons
2023-03-03 14:02:47 -08:00
committed by GitHub
parent 11c7a824db
commit 90c1952420
4 changed files with 13 additions and 32 deletions

View File

@@ -454,24 +454,18 @@ void ParagraphBuilder::pushStyle(const tonic::Int32List& encoded,
if (mask & kTSBackgroundMask) {
Paint background(background_objects, background_data);
if (background.isNotNull()) {
SkPaint sk_paint;
style.has_background = true;
style.background = *background.paint(sk_paint);
DlPaint dl_paint;
background.toDlPaint(dl_paint);
style.background_dl = dl_paint;
style.background = dl_paint;
}
}
if (mask & kTSForegroundMask) {
Paint foreground(foreground_objects, foreground_data);
if (foreground.isNotNull()) {
SkPaint sk_paint;
style.has_foreground = true;
style.foreground = *foreground.paint(sk_paint);
DlPaint dl_paint;
foreground.toDlPaint(dl_paint);
style.foreground_dl = dl_paint;
style.foreground = dl_paint;
}
}

View File

@@ -169,11 +169,11 @@ skt::TextStyle ParagraphBuilderSkia::TxtToSkia(const TextStyle& txt) {
skia.setHalfLeading(txt.half_leading);
skia.setLocale(SkString(txt.locale.c_str()));
if (txt.has_background) {
skia.setBackgroundPaintID(CreatePaintID(txt.background_dl));
if (txt.background.has_value()) {
skia.setBackgroundPaintID(CreatePaintID(txt.background.value()));
}
if (txt.has_foreground) {
skia.setForegroundPaintID(CreatePaintID(txt.foreground_dl));
if (txt.foreground.has_value()) {
skia.setForegroundPaintID(CreatePaintID(txt.foreground.value()));
} else {
flutter::DlPaint dl_paint;
dl_paint.setColor(txt.color);

View File

@@ -300,22 +300,12 @@ TextStyle ParagraphSkia::SkiaToTxt(const skt::TextStyle& skia) {
txt.locale = skia.getLocale().c_str();
if (skia.hasBackground()) {
skt::ParagraphPainter::SkPaintOrID background =
skia.getBackgroundPaintOrID();
if (std::holds_alternative<SkPaint>(background)) {
txt.background = std::get<SkPaint>(background);
} else if (std::holds_alternative<PaintID>(background)) {
txt.background_dl = dl_paints_[std::get<PaintID>(background)];
}
PaintID background_id = std::get<PaintID>(skia.getBackgroundPaintOrID());
txt.background = dl_paints_[background_id];
}
if (skia.hasForeground()) {
skt::ParagraphPainter::SkPaintOrID foreground =
skia.getForegroundPaintOrID();
if (std::holds_alternative<SkPaint>(foreground)) {
txt.foreground = std::get<SkPaint>(foreground);
} else if (std::holds_alternative<PaintID>(foreground)) {
txt.foreground_dl = dl_paints_[std::get<PaintID>(foreground)];
}
PaintID foreground_id = std::get<PaintID>(skia.getForegroundPaintOrID());
txt.foreground = dl_paints_[foreground_id];
}
txt.text_shadows.clear();

View File

@@ -17,6 +17,7 @@
#ifndef LIB_TXT_SRC_TEXT_STYLE_H_
#define LIB_TXT_SRC_TEXT_STYLE_H_
#include <optional>
#include <string>
#include <vector>
@@ -55,12 +56,8 @@ class TextStyle {
double height = 1.0;
bool has_height_override = false;
std::string locale;
bool has_background = false;
SkPaint background;
flutter::DlPaint background_dl;
bool has_foreground = false;
SkPaint foreground;
flutter::DlPaint foreground_dl;
std::optional<flutter::DlPaint> background;
std::optional<flutter::DlPaint> foreground;
// An ordered list of shadows where the first shadow will be drawn first (at
// the bottom).
std::vector<TextShadow> text_shadows;