Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
paragraph_skia.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef LIB_TXT_SRC_PARAGRAPH_SKIA_H_
18#define LIB_TXT_SRC_PARAGRAPH_SKIA_H_
19
20#include <optional>
21
22#include "txt/paragraph.h"
23
25
26namespace txt {
27
28// Implementation of Paragraph based on Skia's text layout module.
29class ParagraphSkia : public Paragraph {
30 public:
31 ParagraphSkia(std::unique_ptr<skia::textlayout::Paragraph> paragraph,
32 std::vector<flutter::DlPaint>&& dl_paints,
33 bool impeller_enabled);
34
35 virtual ~ParagraphSkia() = default;
36
37 double GetMaxWidth() override;
38
39 double GetHeight() override;
40
41 double GetLongestLine() override;
42
43 double GetMinIntrinsicWidth() override;
44
45 double GetMaxIntrinsicWidth() override;
46
47 double GetAlphabeticBaseline() override;
48
49 double GetIdeographicBaseline() override;
50
51 std::vector<LineMetrics>& GetLineMetrics() override;
52
54 int lineNumber,
55 skia::textlayout::LineMetrics* lineMetrics) const override;
56
57 size_t GetNumberOfLines() const override;
58
59 int GetLineNumberAt(size_t utf16Offset) const override;
60
61 bool DidExceedMaxLines() override;
62
63 void Layout(double width) override;
64
65 bool Paint(flutter::DisplayListBuilder* builder, double x, double y) override;
66
67 std::vector<TextBox> GetRectsForRange(
68 size_t start,
69 size_t end,
70 RectHeightStyle rect_height_style,
71 RectWidthStyle rect_width_style) override;
72
73 std::vector<TextBox> GetRectsForPlaceholders() override;
74
75 PositionWithAffinity GetGlyphPositionAtCoordinate(double dx,
76 double dy) override;
77
78 bool GetGlyphInfoAt(
79 unsigned offset,
80 skia::textlayout::Paragraph::GlyphInfo* glyphInfo) const override;
81
83 double dx,
84 double dy,
85 skia::textlayout::Paragraph::GlyphInfo* glyphInfo) const override;
86
87 Range<size_t> GetWordBoundary(size_t offset) override;
88
89 private:
91
92 std::unique_ptr<skia::textlayout::Paragraph> paragraph_;
93 std::vector<flutter::DlPaint> dl_paints_;
94 std::optional<std::vector<LineMetrics>> line_metrics_;
95 std::vector<TextStyle> line_metrics_styles_;
96 const bool impeller_enabled_;
97};
98
99} // namespace txt
100
101#endif // LIB_TXT_SRC_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
double y
double x
Point offset