Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions
paragraph.cpp File Reference
#include "third_party/skia/modules/skparagraph/include/Paragraph.h"
#include "../export.h"
#include "DartTypes.h"
#include "TextStyle.h"
#include "include/core/SkScalar.h"

Go to the source code of this file.

Classes

struct  TextBoxList
 

Functions

SKWASM_EXPORT void paragraph_dispose (Paragraph *paragraph)
 
SKWASM_EXPORT SkScalar paragraph_getWidth (Paragraph *paragraph)
 
SKWASM_EXPORT SkScalar paragraph_getHeight (Paragraph *paragraph)
 
SKWASM_EXPORT SkScalar paragraph_getLongestLine (Paragraph *paragraph)
 
SKWASM_EXPORT SkScalar paragraph_getMinIntrinsicWidth (Paragraph *paragraph)
 
SKWASM_EXPORT SkScalar paragraph_getMaxIntrinsicWidth (Paragraph *paragraph)
 
SKWASM_EXPORT SkScalar paragraph_getAlphabeticBaseline (Paragraph *paragraph)
 
SKWASM_EXPORT SkScalar paragraph_getIdeographicBaseline (Paragraph *paragraph)
 
SKWASM_EXPORT bool paragraph_getDidExceedMaxLines (Paragraph *paragraph)
 
SKWASM_EXPORT void paragraph_layout (Paragraph *paragraph, SkScalar width)
 
SKWASM_EXPORT int32_t paragraph_getPositionForOffset (Paragraph *paragraph, SkScalar offsetX, SkScalar offsetY, Affinity *outAffinity)
 
SKWASM_EXPORT bool paragraph_getClosestGlyphInfoAtCoordinate (Paragraph *paragraph, SkScalar offsetX, SkScalar offsetY, SkRect *graphemeLayoutBounds, size_t *graphemeCodeUnitRange, bool *booleanFlags)
 
SKWASM_EXPORT bool paragraph_getGlyphInfoAt (Paragraph *paragraph, size_t index, SkRect *graphemeLayoutBounds, size_t *graphemeCodeUnitRange, bool *booleanFlags)
 
SKWASM_EXPORT void paragraph_getWordBoundary (Paragraph *paragraph, unsigned int position, int32_t *outRange)
 
SKWASM_EXPORT size_t paragraph_getLineCount (Paragraph *paragraph)
 
SKWASM_EXPORT int paragraph_getLineNumberAt (Paragraph *paragraph, size_t characterIndex)
 
SKWASM_EXPORT LineMetricsparagraph_getLineMetricsAtIndex (Paragraph *paragraph, size_t lineNumber)
 
SKWASM_EXPORT void textBoxList_dispose (TextBoxList *list)
 
SKWASM_EXPORT size_t textBoxList_getLength (TextBoxList *list)
 
SKWASM_EXPORT TextDirection textBoxList_getBoxAtIndex (TextBoxList *list, size_t index, SkRect *outRect)
 
SKWASM_EXPORT TextBoxListparagraph_getBoxesForRange (Paragraph *paragraph, int start, int end, RectHeightStyle heightStyle, RectWidthStyle widthStyle)
 
SKWASM_EXPORT TextBoxListparagraph_getBoxesForPlaceholders (Paragraph *paragraph)
 
SKWASM_EXPORT int paragraph_getUnresolvedCodePoints (Paragraph *paragraph, SkUnichar *outCodePoints, int outLength)
 

Function Documentation

◆ paragraph_dispose()

SKWASM_EXPORT void paragraph_dispose ( Paragraph paragraph)

Definition at line 13 of file paragraph.cpp.

13 {
14 delete paragraph;
15}

◆ paragraph_getAlphabeticBaseline()

SKWASM_EXPORT SkScalar paragraph_getAlphabeticBaseline ( Paragraph paragraph)

Definition at line 37 of file paragraph.cpp.

37 {
38 return paragraph->getAlphabeticBaseline();
39}
SkScalar getAlphabeticBaseline()
Definition Paragraph.h:34

◆ paragraph_getBoxesForPlaceholders()

SKWASM_EXPORT TextBoxList * paragraph_getBoxesForPlaceholders ( Paragraph paragraph)

Definition at line 167 of file paragraph.cpp.

168 {
169 return new TextBoxList{paragraph->getRectsForPlaceholders()};
170}
virtual std::vector< TextBox > getRectsForPlaceholders()=0

◆ paragraph_getBoxesForRange()

SKWASM_EXPORT TextBoxList * paragraph_getBoxesForRange ( Paragraph paragraph,
int  start,
int  end,
RectHeightStyle  heightStyle,
RectWidthStyle  widthStyle 
)

Definition at line 157 of file paragraph.cpp.

162 {
163 return new TextBoxList{
164 paragraph->getRectsForRange(start, end, heightStyle, widthStyle)};
165}
virtual std::vector< TextBox > getRectsForRange(unsigned start, unsigned end, RectHeightStyle rectHeightStyle, RectWidthStyle rectWidthStyle)=0
glong glong end

◆ paragraph_getClosestGlyphInfoAtCoordinate()

SKWASM_EXPORT bool paragraph_getClosestGlyphInfoAtCoordinate ( Paragraph paragraph,
SkScalar  offsetX,
SkScalar  offsetY,
SkRect graphemeLayoutBounds,
size_t *  graphemeCodeUnitRange,
bool *  booleanFlags 
)

Definition at line 64 of file paragraph.cpp.

71 { // 1 boolean: isLTR
72 Paragraph::GlyphInfo glyphInfo;
73 if (!paragraph->getClosestUTF16GlyphInfoAt(offsetX, offsetY, &glyphInfo)) {
74 return false;
75 }
76 // This is more verbose than memcpying the whole struct but ideally we don't
77 // want to depend on the exact memory layout of the struct.
78 std::memcpy(graphemeLayoutBounds, &glyphInfo.fGraphemeLayoutBounds,
79 sizeof(SkRect));
80 std::memcpy(graphemeCodeUnitRange, &glyphInfo.fGraphemeClusterTextRange,
81 2 * sizeof(size_t));
82 booleanFlags[0] =
84 return true;
85}
virtual bool getClosestUTF16GlyphInfoAt(SkScalar dx, SkScalar dy, GlyphInfo *glyphInfo)=0
SkScalar offsetX
SkScalar offsetY

◆ paragraph_getDidExceedMaxLines()

SKWASM_EXPORT bool paragraph_getDidExceedMaxLines ( Paragraph paragraph)

Definition at line 45 of file paragraph.cpp.

45 {
46 return paragraph->didExceedMaxLines();
47}

◆ paragraph_getGlyphInfoAt()

SKWASM_EXPORT bool paragraph_getGlyphInfoAt ( Paragraph paragraph,
size_t  index,
SkRect graphemeLayoutBounds,
size_t *  graphemeCodeUnitRange,
bool *  booleanFlags 
)

Definition at line 87 of file paragraph.cpp.

93 { // 1 boolean: isLTR
94 Paragraph::GlyphInfo glyphInfo;
95 if (!paragraph->getGlyphInfoAtUTF16Offset(index, &glyphInfo)) {
96 return false;
97 }
98 std::memcpy(graphemeLayoutBounds, &glyphInfo.fGraphemeLayoutBounds,
99 sizeof(SkRect));
100 std::memcpy(graphemeCodeUnitRange, &glyphInfo.fGraphemeClusterTextRange,
101 2 * sizeof(size_t));
102 booleanFlags[0] =
104 return true;
105}
virtual bool getGlyphInfoAtUTF16Offset(size_t codeUnitIndex, GlyphInfo *glyphInfo)=0

◆ paragraph_getHeight()

SKWASM_EXPORT SkScalar paragraph_getHeight ( Paragraph paragraph)

Definition at line 21 of file paragraph.cpp.

21 {
22 return paragraph->getHeight();
23}

◆ paragraph_getIdeographicBaseline()

SKWASM_EXPORT SkScalar paragraph_getIdeographicBaseline ( Paragraph paragraph)

Definition at line 41 of file paragraph.cpp.

41 {
42 return paragraph->getIdeographicBaseline();
43}
SkScalar getIdeographicBaseline()
Definition Paragraph.h:36

◆ paragraph_getLineCount()

SKWASM_EXPORT size_t paragraph_getLineCount ( Paragraph paragraph)

Definition at line 117 of file paragraph.cpp.

117 {
118 return paragraph->lineNumber();
119}
virtual size_t lineNumber()=0

◆ paragraph_getLineMetricsAtIndex()

SKWASM_EXPORT LineMetrics * paragraph_getLineMetricsAtIndex ( Paragraph paragraph,
size_t  lineNumber 
)

Definition at line 126 of file paragraph.cpp.

127 {
128 auto metrics = new LineMetrics();
129 if (paragraph->getLineMetricsAt(lineNumber, metrics)) {
130 return metrics;
131 } else {
132 delete metrics;
133 return nullptr;
134 }
135}
virtual bool getLineMetricsAt(int lineNumber, LineMetrics *lineMetrics) const =0

◆ paragraph_getLineNumberAt()

SKWASM_EXPORT int paragraph_getLineNumberAt ( Paragraph paragraph,
size_t  characterIndex 
)

Definition at line 121 of file paragraph.cpp.

122 {
123 return paragraph->getLineNumberAtUTF16Offset(characterIndex);
124}
virtual int getLineNumberAtUTF16Offset(size_t codeUnitIndex)=0

◆ paragraph_getLongestLine()

SKWASM_EXPORT SkScalar paragraph_getLongestLine ( Paragraph paragraph)

Definition at line 25 of file paragraph.cpp.

25 {
26 return paragraph->getLongestLine();
27}

◆ paragraph_getMaxIntrinsicWidth()

SKWASM_EXPORT SkScalar paragraph_getMaxIntrinsicWidth ( Paragraph paragraph)

Definition at line 33 of file paragraph.cpp.

33 {
34 return paragraph->getMaxIntrinsicWidth();
35}
SkScalar getMaxIntrinsicWidth()
Definition Paragraph.h:32

◆ paragraph_getMinIntrinsicWidth()

SKWASM_EXPORT SkScalar paragraph_getMinIntrinsicWidth ( Paragraph paragraph)

Definition at line 29 of file paragraph.cpp.

29 {
30 return paragraph->getMinIntrinsicWidth();
31}
SkScalar getMinIntrinsicWidth()
Definition Paragraph.h:30

◆ paragraph_getPositionForOffset()

SKWASM_EXPORT int32_t paragraph_getPositionForOffset ( Paragraph paragraph,
SkScalar  offsetX,
SkScalar  offsetY,
Affinity outAffinity 
)

Definition at line 53 of file paragraph.cpp.

56 {
57 auto position = paragraph->getGlyphPositionAtCoordinate(offsetX, offsetY);
58 if (outAffinity) {
59 *outAffinity = position.affinity;
60 }
61 return position.position;
62}
virtual PositionWithAffinity getGlyphPositionAtCoordinate(SkScalar dx, SkScalar dy)=0

◆ paragraph_getUnresolvedCodePoints()

SKWASM_EXPORT int paragraph_getUnresolvedCodePoints ( Paragraph paragraph,
SkUnichar outCodePoints,
int  outLength 
)

Definition at line 179 of file paragraph.cpp.

181 {
182 if (!outCodePoints) {
183 return paragraph->unresolvedCodepoints().size();
184 }
185 int outIndex = 0;
186 for (SkUnichar character : paragraph->unresolvedCodepoints()) {
187 if (outIndex < outLength) {
188 outCodePoints[outIndex] = character;
189 outIndex++;
190 } else {
191 break;
192 }
193 }
194 return outIndex;
195}
int32_t SkUnichar
Definition SkTypes.h:175
virtual std::unordered_set< SkUnichar > unresolvedCodepoints()=0

◆ paragraph_getWidth()

SKWASM_EXPORT SkScalar paragraph_getWidth ( Paragraph paragraph)

Definition at line 17 of file paragraph.cpp.

17 {
18 return paragraph->getMaxWidth();
19}

◆ paragraph_getWordBoundary()

SKWASM_EXPORT void paragraph_getWordBoundary ( Paragraph paragraph,
unsigned int  position,
int32_t *  outRange 
)

Definition at line 107 of file paragraph.cpp.

111 {
112 auto range = paragraph->getWordBoundary(position);
113 outRange[0] = range.start;
114 outRange[1] = range.end;
115}
virtual SkRange< size_t > getWordBoundary(unsigned offset)=0

◆ paragraph_layout()

SKWASM_EXPORT void paragraph_layout ( Paragraph paragraph,
SkScalar  width 
)

Definition at line 49 of file paragraph.cpp.

49 {
50 paragraph->layout(width);
51}
virtual void layout(SkScalar width)=0
int32_t width

◆ textBoxList_dispose()

SKWASM_EXPORT void textBoxList_dispose ( TextBoxList list)

Definition at line 141 of file paragraph.cpp.

141 {
142 delete list;
143}

◆ textBoxList_getBoxAtIndex()

SKWASM_EXPORT TextDirection textBoxList_getBoxAtIndex ( TextBoxList list,
size_t  index,
SkRect outRect 
)

Definition at line 149 of file paragraph.cpp.

151 {
152 const auto& box = list->boxes[index];
153 *outRect = box.rect;
154 return box.direction;
155}
std::vector< TextBox > boxes

◆ textBoxList_getLength()

SKWASM_EXPORT size_t textBoxList_getLength ( TextBoxList list)

Definition at line 145 of file paragraph.cpp.

145 {
146 return list->boxes.size();
147}