Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
txt::ParagraphSkia Class Reference

#include <paragraph_skia.h>

Inheritance diagram for txt::ParagraphSkia:
flutter::Paragraph flutter::RefCountedDartWrappable< Paragraph > fml::RefCountedThreadSafe< Paragraph > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 ParagraphSkia (std::unique_ptr< skia::textlayout::Paragraph > paragraph, std::vector< flutter::DlPaint > &&dl_paints, bool impeller_enabled)
 
virtual ~ParagraphSkia ()=default
 
double GetMaxWidth () override
 
double GetHeight () override
 
double GetLongestLine () override
 
double GetMinIntrinsicWidth () override
 
double GetMaxIntrinsicWidth () override
 
double GetAlphabeticBaseline () override
 
double GetIdeographicBaseline () override
 
std::vector< LineMetrics > & GetLineMetrics () override
 
bool GetLineMetricsAt (int lineNumber, skia::textlayout::LineMetrics *lineMetrics) const override
 
size_t GetNumberOfLines () const override
 
int GetLineNumberAt (size_t utf16Offset) const override
 
bool DidExceedMaxLines () override
 
void Layout (double width) override
 
bool Paint (flutter::DisplayListBuilder *builder, double x, double y) 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
 
PositionWithAffinity GetGlyphPositionAtCoordinate (double dx, double dy) override
 
bool GetGlyphInfoAt (unsigned offset, skia::textlayout::Paragraph::GlyphInfo *glyphInfo) const override
 
bool GetClosestGlyphInfoAtCoordinate (double dx, double dy, skia::textlayout::Paragraph::GlyphInfo *glyphInfo) const override
 
Range< size_t > GetWordBoundary (size_t offset) override
 
- Public Member Functions inherited from flutter::Paragraph
 ~Paragraph () override
 
double width ()
 
double height ()
 
double longestLine ()
 
double minIntrinsicWidth ()
 
double maxIntrinsicWidth ()
 
double alphabeticBaseline ()
 
double ideographicBaseline ()
 
bool didExceedMaxLines ()
 
void layout (double width)
 
void paint (Canvas *canvas, double x, double y)
 
tonic::Float32List getRectsForRange (unsigned start, unsigned end, unsigned boxHeightStyle, unsigned boxWidthStyle)
 
tonic::Float32List getRectsForPlaceholders ()
 
Dart_Handle getPositionForOffset (double dx, double dy)
 
Dart_Handle getGlyphInfoAt (unsigned utf16Offset, Dart_Handle constructor) const
 
Dart_Handle getClosestGlyphInfo (double dx, double dy, Dart_Handle constructor) const
 
Dart_Handle getWordBoundary (unsigned offset)
 
Dart_Handle getLineBoundary (unsigned offset)
 
tonic::Float64List computeLineMetrics () const
 
Dart_Handle getLineMetricsAt (int lineNumber, Dart_Handle constructor) const
 
size_t getNumberOfLines () const
 
int getLineNumberAt (size_t utf16Offset) const
 
void dispose ()
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< Paragraph >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< Paragraph >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
virtual void RetainDartWrappableReference () const =0
 
virtual void ReleaseDartWrappableReference () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields { kPeerIndex , kNumberOfNativeFields }
 
- Static Public Member Functions inherited from flutter::Paragraph
static void Create (Dart_Handle paragraph_handle, std::unique_ptr< txt::Paragraph > txt_paragraph)
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< Paragraph >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 29 of file paragraph_skia.h.

Constructor & Destructor Documentation

◆ ParagraphSkia()

txt::ParagraphSkia::ParagraphSkia ( std::unique_ptr< skia::textlayout::Paragraph paragraph,
std::vector< flutter::DlPaint > &&  dl_paints,
bool  impeller_enabled 
)

Definition at line 207 of file paragraph_skia.cc.

210 : paragraph_(std::move(paragraph)),
211 dl_paints_(dl_paints),
212 impeller_enabled_(impeller_enabled) {}

◆ ~ParagraphSkia()

virtual txt::ParagraphSkia::~ParagraphSkia ( )
virtualdefault

Member Function Documentation

◆ DidExceedMaxLines()

bool txt::ParagraphSkia::DidExceedMaxLines ( )
override

Definition at line 286 of file paragraph_skia.cc.

286 {
287 return paragraph_->didExceedMaxLines();
288}

◆ GetAlphabeticBaseline()

double txt::ParagraphSkia::GetAlphabeticBaseline ( )
override

Definition at line 278 of file paragraph_skia.cc.

278 {
279 return SkScalarToDouble(paragraph_->getAlphabeticBaseline());
280}
#define SkScalarToDouble(x)
Definition: SkScalar.h:63

◆ GetClosestGlyphInfoAtCoordinate()

bool txt::ParagraphSkia::GetClosestGlyphInfoAtCoordinate ( double  dx,
double  dy,
skia::textlayout::Paragraph::GlyphInfo glyphInfo 
) const
override

Definition at line 348 of file paragraph_skia.cc.

351 {
352 return paragraph_->getClosestUTF16GlyphInfoAt(dx, dy, glyphInfo);
353};
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208

◆ GetGlyphInfoAt()

bool txt::ParagraphSkia::GetGlyphInfoAt ( unsigned  offset,
skia::textlayout::Paragraph::GlyphInfo glyphInfo 
) const
override

Definition at line 342 of file paragraph_skia.cc.

344 {
345 return paragraph_->getGlyphInfoAtUTF16Offset(offset, glyphInfo);
346}
SeparatedVector2 offset

◆ GetGlyphPositionAtCoordinate()

Paragraph::PositionWithAffinity txt::ParagraphSkia::GetGlyphPositionAtCoordinate ( double  dx,
double  dy 
)
override

Definition at line 332 of file paragraph_skia.cc.

334 {
336 paragraph_->getGlyphPositionAtCoordinate(dx, dy);
337
338 return ParagraphSkia::PositionWithAffinity(
339 skia_pos.position, static_cast<Affinity>(skia_pos.affinity));
340}

◆ GetHeight()

double txt::ParagraphSkia::GetHeight ( )
override

Definition at line 218 of file paragraph_skia.cc.

218 {
219 return SkScalarToDouble(paragraph_->getHeight());
220}

◆ GetIdeographicBaseline()

double txt::ParagraphSkia::GetIdeographicBaseline ( )
override

Definition at line 282 of file paragraph_skia.cc.

282 {
283 return SkScalarToDouble(paragraph_->getIdeographicBaseline());
284}

◆ GetLineMetrics()

std::vector< LineMetrics > & txt::ParagraphSkia::GetLineMetrics ( )
override

Definition at line 226 of file paragraph_skia.cc.

226 {
227 if (!line_metrics_) {
228 std::vector<skt::LineMetrics> metrics;
229 paragraph_->getLineMetrics(metrics);
230
231 line_metrics_.emplace();
232 line_metrics_styles_.reserve(
233 std::accumulate(metrics.begin(), metrics.end(), 0,
234 [](const int a, const skt::LineMetrics& b) {
235 return a + b.fLineMetrics.size();
236 }));
237
238 for (const skt::LineMetrics& skm : metrics) {
239 LineMetrics& txtm = line_metrics_->emplace_back(
240 skm.fStartIndex, skm.fEndIndex, skm.fEndExcludingWhitespaces,
241 skm.fEndIncludingNewline, skm.fHardBreak);
242 txtm.ascent = skm.fAscent;
243 txtm.descent = skm.fDescent;
244 txtm.unscaled_ascent = skm.fUnscaledAscent;
245 txtm.height = skm.fHeight;
246 txtm.width = skm.fWidth;
247 txtm.left = skm.fLeft;
248 txtm.baseline = skm.fBaseline;
249 txtm.line_number = skm.fLineNumber;
250
251 for (const auto& sk_iter : skm.fLineMetrics) {
252 const skt::StyleMetrics& sk_style_metrics = sk_iter.second;
253 line_metrics_styles_.push_back(SkiaToTxt(*sk_style_metrics.text_style));
254 txtm.run_metrics.emplace(
255 std::piecewise_construct, std::forward_as_tuple(sk_iter.first),
256 std::forward_as_tuple(&line_metrics_styles_.back(),
257 sk_style_metrics.font_metrics));
258 }
259 }
260 }
261
262 return line_metrics_.value();
263}
const TextStyle * text_style
Definition: Metrics.h:17
SkFontMetrics font_metrics
Definition: Metrics.h:36
static bool b
struct MyStruct a[10]

◆ GetLineMetricsAt()

bool txt::ParagraphSkia::GetLineMetricsAt ( int  lineNumber,
skia::textlayout::LineMetrics lineMetrics 
) const
override

Definition at line 265 of file paragraph_skia.cc.

266 {
267 return paragraph_->getLineMetricsAt(lineNumber, lineMetrics);
268};

◆ GetLineNumberAt()

int txt::ParagraphSkia::GetLineNumberAt ( size_t  utf16Offset) const
override

Definition at line 364 of file paragraph_skia.cc.

364 {
365 return paragraph_->getLineNumberAtUTF16Offset(codeUnitIndex);
366}

◆ GetLongestLine()

double txt::ParagraphSkia::GetLongestLine ( )
override

Definition at line 222 of file paragraph_skia.cc.

222 {
223 return SkScalarToDouble(paragraph_->getLongestLine());
224}

◆ GetMaxIntrinsicWidth()

double txt::ParagraphSkia::GetMaxIntrinsicWidth ( )
override

Definition at line 274 of file paragraph_skia.cc.

274 {
275 return SkScalarToDouble(paragraph_->getMaxIntrinsicWidth());
276}

◆ GetMaxWidth()

double txt::ParagraphSkia::GetMaxWidth ( )
override

Definition at line 214 of file paragraph_skia.cc.

214 {
215 return SkScalarToDouble(paragraph_->getMaxWidth());
216}

◆ GetMinIntrinsicWidth()

double txt::ParagraphSkia::GetMinIntrinsicWidth ( )
override

Definition at line 270 of file paragraph_skia.cc.

270 {
271 return SkScalarToDouble(paragraph_->getMinIntrinsicWidth());
272}

◆ GetNumberOfLines()

size_t txt::ParagraphSkia::GetNumberOfLines ( ) const
override

Definition at line 360 of file paragraph_skia.cc.

360 {
361 return paragraph_->lineNumber();
362}

◆ GetRectsForPlaceholders()

std::vector< Paragraph::TextBox > txt::ParagraphSkia::GetRectsForPlaceholders ( )
override

Definition at line 320 of file paragraph_skia.cc.

320 {
321 std::vector<skt::TextBox> skia_boxes = paragraph_->getRectsForPlaceholders();
322
323 std::vector<Paragraph::TextBox> boxes;
324 for (const skt::TextBox& skia_box : skia_boxes) {
325 boxes.emplace_back(skia_box.rect,
326 static_cast<TextDirection>(skia_box.direction));
327 }
328
329 return boxes;
330}

◆ GetRectsForRange()

std::vector< Paragraph::TextBox > txt::ParagraphSkia::GetRectsForRange ( size_t  start,
size_t  end,
RectHeightStyle  rect_height_style,
RectWidthStyle  rect_width_style 
)
override

Definition at line 302 of file paragraph_skia.cc.

306 {
307 std::vector<skt::TextBox> skia_boxes = paragraph_->getRectsForRange(
308 start, end, static_cast<skt::RectHeightStyle>(rect_height_style),
309 static_cast<skt::RectWidthStyle>(rect_width_style));
310
311 std::vector<Paragraph::TextBox> boxes;
312 for (const skt::TextBox& skia_box : skia_boxes) {
313 boxes.emplace_back(skia_box.rect,
314 static_cast<TextDirection>(skia_box.direction));
315 }
316
317 return boxes;
318}

◆ GetWordBoundary()

Paragraph::Range< size_t > txt::ParagraphSkia::GetWordBoundary ( size_t  offset)
override

Definition at line 355 of file paragraph_skia.cc.

355 {
356 skt::SkRange<size_t> range = paragraph_->getWordBoundary(offset);
357 return Paragraph::Range<size_t>(range.start, range.end);
358}

◆ Layout()

void txt::ParagraphSkia::Layout ( double  width)
override

Definition at line 290 of file paragraph_skia.cc.

290 {
291 line_metrics_.reset();
292 line_metrics_styles_.clear();
293 paragraph_->layout(width);
294}

◆ Paint()

bool txt::ParagraphSkia::Paint ( flutter::DisplayListBuilder builder,
double  x,
double  y 
)
override

Definition at line 296 of file paragraph_skia.cc.

296 {
297 DisplayListParagraphPainter painter(builder, dl_paints_, impeller_enabled_);
298 paragraph_->paint(&painter, x, y);
299 return true;
300}
double y
double x

The documentation for this class was generated from the following files: