diff --git a/engine/src/flutter/lib/ui/text/paragraph_builder.cc b/engine/src/flutter/lib/ui/text/paragraph_builder.cc index 4b1c07bc61..3857a10572 100644 --- a/engine/src/flutter/lib/ui/text/paragraph_builder.cc +++ b/engine/src/flutter/lib/ui/text/paragraph_builder.cc @@ -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; } } diff --git a/engine/src/flutter/third_party/txt/src/skia/paragraph_builder_skia.cc b/engine/src/flutter/third_party/txt/src/skia/paragraph_builder_skia.cc index 272b6e09cb..96d98f3f4c 100644 --- a/engine/src/flutter/third_party/txt/src/skia/paragraph_builder_skia.cc +++ b/engine/src/flutter/third_party/txt/src/skia/paragraph_builder_skia.cc @@ -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); diff --git a/engine/src/flutter/third_party/txt/src/skia/paragraph_skia.cc b/engine/src/flutter/third_party/txt/src/skia/paragraph_skia.cc index f78890331d..dad981f07e 100644 --- a/engine/src/flutter/third_party/txt/src/skia/paragraph_skia.cc +++ b/engine/src/flutter/third_party/txt/src/skia/paragraph_skia.cc @@ -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(background)) { - txt.background = std::get(background); - } else if (std::holds_alternative(background)) { - txt.background_dl = dl_paints_[std::get(background)]; - } + PaintID background_id = std::get(skia.getBackgroundPaintOrID()); + txt.background = dl_paints_[background_id]; } if (skia.hasForeground()) { - skt::ParagraphPainter::SkPaintOrID foreground = - skia.getForegroundPaintOrID(); - if (std::holds_alternative(foreground)) { - txt.foreground = std::get(foreground); - } else if (std::holds_alternative(foreground)) { - txt.foreground_dl = dl_paints_[std::get(foreground)]; - } + PaintID foreground_id = std::get(skia.getForegroundPaintOrID()); + txt.foreground = dl_paints_[foreground_id]; } txt.text_shadows.clear(); diff --git a/engine/src/flutter/third_party/txt/src/txt/text_style.h b/engine/src/flutter/third_party/txt/src/txt/text_style.h index 7fcb30a261..afc5d14966 100644 --- a/engine/src/flutter/third_party/txt/src/txt/text_style.h +++ b/engine/src/flutter/third_party/txt/src/txt/text_style.h @@ -17,6 +17,7 @@ #ifndef LIB_TXT_SRC_TEXT_STYLE_H_ #define LIB_TXT_SRC_TEXT_STYLE_H_ +#include #include #include @@ -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 background; + std::optional foreground; // An ordered list of shadows where the first shadow will be drawn first (at // the bottom). std::vector text_shadows;