38 int txt_weight = (font_weight - 100) / 100;
45 return font_slant == SkFontStyle::Slant::kUpright_Slant
70 const std::vector<DlPaint>& dl_paints,
71 bool impeller_enabled)
73 dl_paints_(dl_paints),
74 impeller_enabled_(impeller_enabled) {}
79 const SkPaintOrID&
paint)
override {
83 size_t paint_id = std::get<PaintID>(
paint);
86#ifdef IMPELLER_SUPPORTS_RENDERING
87 if (impeller_enabled_) {
88 if (ShouldRenderAsPath(dl_paints_[paint_id])) {
94 x,
y, dl_paints_[paint_id]);
101 builder_->DrawPath(transformed, dl_paints_[paint_id]);
105 y, dl_paints_[paint_id]);
109 builder_->DrawTextBlob(blob,
x,
y, dl_paints_[paint_id]);
122 if (blur_sigma > 0.0) {
124 paint.setMaskFilter(&filter);
126 if (impeller_enabled_) {
131 builder_->DrawTextBlob(blob,
x,
y,
paint);
135 size_t paint_id = std::get<PaintID>(
paint);
137 builder_->DrawRect(
rect, dl_paints_[paint_id]);
141 const DecorationStyle& decor_style)
override {
147 const DecorationStyle& decor_style)
override {
148 builder_->DrawPath(
path, toDlPaint(decor_style));
155 const DecorationStyle& decor_style)
override {
156 auto dash_path_effect = decor_style.getDashPathEffect();
157 auto paint = toDlPaint(decor_style);
159 if (dash_path_effect) {
161 dash_path_effect->fOnLength,
162 dash_path_effect->fOffLength,
paint);
169 builder_->ClipRect(
rect, DlCanvas::ClipOp::kIntersect,
false);
173 builder_->Translate(
dx, dy);
176 void save()
override { builder_->Save(); }
178 void restore()
override { builder_->Restore(); }
187 return (
paint.getColorSource() && !
paint.getColorSource()->asColor());
190 DlPaint toDlPaint(
const DecorationStyle& decor_style,
193 paint.setDrawStyle(draw_style);
194 paint.setAntiAlias(
true);
196 paint.setStrokeWidth(decor_style.getStrokeWidth());
201 const std::vector<DlPaint>& dl_paints_;
202 const bool impeller_enabled_;
208 std::vector<flutter::DlPaint>&& dl_paints,
209 bool impeller_enabled)
210 : paragraph_(
std::move(paragraph)),
211 dl_paints_(dl_paints),
212 impeller_enabled_(impeller_enabled) {}
227 if (!line_metrics_) {
228 std::vector<skt::LineMetrics> metrics;
229 paragraph_->getLineMetrics(metrics);
231 line_metrics_.emplace();
232 line_metrics_styles_.reserve(
233 std::accumulate(metrics.begin(), metrics.end(), 0,
235 return a + b.fLineMetrics.size();
240 skm.fStartIndex, skm.fEndIndex, skm.fEndExcludingWhitespaces,
241 skm.fEndIncludingNewline, skm.fHardBreak);
242 txtm.
ascent = skm.fAscent;
245 txtm.
height = skm.fHeight;
246 txtm.
width = skm.fWidth;
247 txtm.
left = skm.fLeft;
251 for (
const auto& sk_iter : skm.fLineMetrics) {
253 line_metrics_styles_.push_back(SkiaToTxt(*sk_style_metrics.
text_style));
255 std::piecewise_construct, std::forward_as_tuple(sk_iter.first),
256 std::forward_as_tuple(&line_metrics_styles_.back(),
262 return line_metrics_.value();
267 return paragraph_->getLineMetricsAt(lineNumber, lineMetrics);
287 return paragraph_->didExceedMaxLines();
291 line_metrics_.reset();
292 line_metrics_styles_.clear();
293 paragraph_->layout(
width);
297 DisplayListParagraphPainter painter(
builder, dl_paints_, impeller_enabled_);
298 paragraph_->paint(&painter,
x,
y);
307 std::vector<skt::TextBox> skia_boxes = paragraph_->getRectsForRange(
311 std::vector<Paragraph::TextBox> boxes;
313 boxes.emplace_back(skia_box.rect,
321 std::vector<skt::TextBox> skia_boxes = paragraph_->getRectsForPlaceholders();
323 std::vector<Paragraph::TextBox> boxes;
325 boxes.emplace_back(skia_box.rect,
336 paragraph_->getGlyphPositionAtCoordinate(
dx, dy);
338 return ParagraphSkia::PositionWithAffinity(
345 return paragraph_->getGlyphInfoAtUTF16Offset(
offset, glyphInfo);
352 return paragraph_->getClosestUTF16GlyphInfoAt(
dx, dy, glyphInfo);
361 return paragraph_->lineNumber();
365 return paragraph_->getLineNumberAtUTF16Offset(codeUnitIndex);
373 txt.decoration_color =
skia.getDecorationColor();
374 txt.decoration_style =
376 txt.decoration_thickness_multiplier =
378 txt.font_weight = GetTxtFontWeight(
skia.getFontStyle().weight());
379 txt.font_style = GetTxtFontStyle(
skia.getFontStyle().slant());
383 for (
const SkString& font_family :
skia.getFontFamilies()) {
384 txt.font_families.emplace_back(font_family.c_str());
392 txt.locale =
skia.getLocale().c_str();
393 if (
skia.hasBackground()) {
394 PaintID background_id = std::get<PaintID>(
skia.getBackgroundPaintOrID());
395 txt.background = dl_paints_[background_id];
397 if (
skia.hasForeground()) {
398 PaintID foreground_id = std::get<PaintID>(
skia.getForegroundPaintOrID());
399 txt.foreground = dl_paints_[foreground_id];
402 txt.text_shadows.clear();
405 shadow.
offset = skia_shadow.fOffset;
407 shadow.
color = skia_shadow.fColor;
408 txt.text_shadows.emplace_back(shadow);
static unsigned clamp(SkFixed fx, int max)
#define SkScalarToDouble(x)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
const SkRect & bounds() const
static SkPath GetPath(SkTextBlob *textBlob)
const TextStyle * text_style
SkFontMetrics font_metrics
std::map< size_t, RunMetrics > run_metrics
double GetMaxIntrinsicWidth() override
bool DidExceedMaxLines() override
double GetHeight() override
ParagraphSkia(std::unique_ptr< skia::textlayout::Paragraph > paragraph, std::vector< flutter::DlPaint > &&dl_paints, bool impeller_enabled)
size_t GetNumberOfLines() const override
PositionWithAffinity GetGlyphPositionAtCoordinate(double dx, double dy) override
double GetAlphabeticBaseline() override
bool GetClosestGlyphInfoAtCoordinate(double dx, double dy, skia::textlayout::Paragraph::GlyphInfo *glyphInfo) const override
int GetLineNumberAt(size_t utf16Offset) const override
bool GetLineMetricsAt(int lineNumber, skia::textlayout::LineMetrics *lineMetrics) const override
double GetLongestLine() override
std::vector< LineMetrics > & GetLineMetrics() override
void Layout(double width) override
std::vector< TextBox > GetRectsForRange(size_t start, size_t end, RectHeightStyle rect_height_style, RectWidthStyle rect_width_style) override
std::vector< TextBox > GetRectsForPlaceholders() override
double GetMaxWidth() override
bool Paint(flutter::DisplayListBuilder *builder, double x, double y) override
bool GetGlyphInfoAt(unsigned offset, skia::textlayout::Paragraph::GlyphInfo *glyphInfo) const override
double GetMinIntrinsicWidth() override
Range< size_t > GetWordBoundary(size_t offset) override
double GetIdeographicBaseline() override
#define FML_DCHECK(condition)
static void drawPath(SkPath &path, SkCanvas *canvas, SkColor color, const SkRect &clip, SkPaint::Cap cap, SkPaint::Join join, SkPaint::Style style, SkPathFillType fill, SkScalar strokeWidth)
drawTextBlob(r.blob.get(), r.x, r.y, r.paint)) DRAW(DrawSlug
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
sk_sp< SkBlender > blender SkRect rect
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
@ kStroke
strokes boundary of shapes
@ kFill
fills interior of shapes
@ kNormal
fuzzy inside and outside
std::shared_ptr< TextFrame > MakeTextFrameFromTextBlobSkia(const sk_sp< SkTextBlob > &blob)
skt::ParagraphPainter::PaintID PaintID
static constexpr SkPoint Make(float x, float y)
constexpr float left() const
constexpr float top() const