Flutter Engine
 
Loading...
Searching...
No Matches
paragraph_skia.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_TXT_SRC_SKIA_PARAGRAPH_SKIA_H_
6#define FLUTTER_TXT_SRC_SKIA_PARAGRAPH_SKIA_H_
7
8#include <optional>
9
10#include "txt/paragraph.h"
11
12#include "third_party/skia/modules/skparagraph/include/Paragraph.h"
13
14namespace txt {
15
16// Implementation of Paragraph based on Skia's text layout module.
17class ParagraphSkia : public Paragraph {
18 public:
19 ParagraphSkia(std::unique_ptr<skia::textlayout::Paragraph> paragraph,
20 std::vector<flutter::DlPaint>&& dl_paints,
21 bool impeller_enabled);
22
23 virtual ~ParagraphSkia() = default;
24
25 double GetMaxWidth() override;
26
27 double GetHeight() override;
28
29 double GetLongestLine() override;
30
31 double GetMinIntrinsicWidth() override;
32
33 double GetMaxIntrinsicWidth() override;
34
35 double GetAlphabeticBaseline() override;
36
37 double GetIdeographicBaseline() override;
38
39 std::vector<LineMetrics>& GetLineMetrics() override;
40
42 int lineNumber,
43 skia::textlayout::LineMetrics* lineMetrics) const override;
44
45 size_t GetNumberOfLines() const override;
46
47 int GetLineNumberAt(size_t utf16Offset) const override;
48
49 bool DidExceedMaxLines() override;
50
51 void Layout(double width) override;
52
53 bool Paint(flutter::DisplayListBuilder* builder, double x, double y) override;
54
55 std::vector<TextBox> GetRectsForRange(
56 size_t start,
57 size_t end,
58 RectHeightStyle rect_height_style,
59 RectWidthStyle rect_width_style) override;
60
61 std::vector<TextBox> GetRectsForPlaceholders() override;
62
63 PositionWithAffinity GetGlyphPositionAtCoordinate(double dx,
64 double dy) override;
65
66 bool GetGlyphInfoAt(
67 unsigned offset,
68 skia::textlayout::Paragraph::GlyphInfo* glyphInfo) const override;
69
71 double dx,
72 double dy,
73 skia::textlayout::Paragraph::GlyphInfo* glyphInfo) const override;
74
75 Range<size_t> GetWordBoundary(size_t offset) override;
76
77 private:
78 TextStyle SkiaToTxt(const skia::textlayout::TextStyle& skia);
79
80 std::unique_ptr<skia::textlayout::Paragraph> paragraph_;
81 std::vector<flutter::DlPaint> dl_paints_;
82 std::optional<std::vector<LineMetrics>> line_metrics_;
83 std::vector<TextStyle> line_metrics_styles_;
84 const bool impeller_enabled_;
85};
86
87} // namespace txt
88
89#endif // FLUTTER_TXT_SRC_SKIA_PARAGRAPH_SKIA_H_
double GetMaxIntrinsicWidth() override
bool DidExceedMaxLines() override
double GetHeight() override
size_t GetNumberOfLines() const override
PositionWithAffinity GetGlyphPositionAtCoordinate(double dx, double dy) override
virtual ~ParagraphSkia()=default
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 GetGlyphInfoAt(unsigned offset, skia::textlayout::Paragraph::GlyphInfo *glyphInfo) const override
double GetMinIntrinsicWidth() override
Range< size_t > GetWordBoundary(size_t offset) override
double GetIdeographicBaseline() override
int32_t x
double y