Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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< T > 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< T >
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
 
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< T >
 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 246 of file paragraph_skia.cc.

249 : paragraph_(std::move(paragraph)),
250 dl_paints_(dl_paints),
251 impeller_enabled_(impeller_enabled) {}

◆ ~ParagraphSkia()

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

Member Function Documentation

◆ DidExceedMaxLines()

bool txt::ParagraphSkia::DidExceedMaxLines ( )
override

Definition at line 325 of file paragraph_skia.cc.

325 {
326 return paragraph_->didExceedMaxLines();
327}

◆ GetAlphabeticBaseline()

double txt::ParagraphSkia::GetAlphabeticBaseline ( )
override

Definition at line 317 of file paragraph_skia.cc.

317 {
318 return SkScalarToDouble(paragraph_->getAlphabeticBaseline());
319}
#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 387 of file paragraph_skia.cc.

390 {
391 return paragraph_->getClosestUTF16GlyphInfoAt(dx, dy, glyphInfo);
392};

◆ GetGlyphInfoAt()

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

Definition at line 381 of file paragraph_skia.cc.

383 {
384 return paragraph_->getGlyphInfoAtUTF16Offset(offset, glyphInfo);
385}
Point offset

◆ GetGlyphPositionAtCoordinate()

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

Definition at line 371 of file paragraph_skia.cc.

373 {
375 paragraph_->getGlyphPositionAtCoordinate(dx, dy);
376
377 return ParagraphSkia::PositionWithAffinity(
378 skia_pos.position, static_cast<Affinity>(skia_pos.affinity));
379}

◆ GetHeight()

double txt::ParagraphSkia::GetHeight ( )
override

Definition at line 257 of file paragraph_skia.cc.

257 {
258 return SkScalarToDouble(paragraph_->getHeight());
259}

◆ GetIdeographicBaseline()

double txt::ParagraphSkia::GetIdeographicBaseline ( )
override

Definition at line 321 of file paragraph_skia.cc.

321 {
322 return SkScalarToDouble(paragraph_->getIdeographicBaseline());
323}

◆ GetLineMetrics()

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

Definition at line 265 of file paragraph_skia.cc.

265 {
266 if (!line_metrics_) {
267 std::vector<skt::LineMetrics> metrics;
268 paragraph_->getLineMetrics(metrics);
269
270 line_metrics_.emplace();
271 line_metrics_styles_.reserve(
272 std::accumulate(metrics.begin(), metrics.end(), 0,
273 [](const int a, const skt::LineMetrics& b) {
274 return a + b.fLineMetrics.size();
275 }));
276
277 for (const skt::LineMetrics& skm : metrics) {
278 LineMetrics& txtm = line_metrics_->emplace_back(
279 skm.fStartIndex, skm.fEndIndex, skm.fEndExcludingWhitespaces,
280 skm.fEndIncludingNewline, skm.fHardBreak);
281 txtm.ascent = skm.fAscent;
282 txtm.descent = skm.fDescent;
283 txtm.unscaled_ascent = skm.fUnscaledAscent;
284 txtm.height = skm.fHeight;
285 txtm.width = skm.fWidth;
286 txtm.left = skm.fLeft;
287 txtm.baseline = skm.fBaseline;
288 txtm.line_number = skm.fLineNumber;
289
290 for (const auto& sk_iter : skm.fLineMetrics) {
291 const skt::StyleMetrics& sk_style_metrics = sk_iter.second;
292 line_metrics_styles_.push_back(SkiaToTxt(*sk_style_metrics.text_style));
293 txtm.run_metrics.emplace(
294 std::piecewise_construct, std::forward_as_tuple(sk_iter.first),
295 std::forward_as_tuple(&line_metrics_styles_.back(),
296 sk_style_metrics.font_metrics));
297 }
298 }
299 }
300
301 return line_metrics_.value();
302}
const TextStyle * text_style
Definition Metrics.h:17
static bool b
struct MyStruct a[10]

◆ GetLineMetricsAt()

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

Definition at line 304 of file paragraph_skia.cc.

305 {
306 return paragraph_->getLineMetricsAt(lineNumber, lineMetrics);
307};

◆ GetLineNumberAt()

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

Definition at line 403 of file paragraph_skia.cc.

403 {
404 return paragraph_->getLineNumberAtUTF16Offset(codeUnitIndex);
405}

◆ GetLongestLine()

double txt::ParagraphSkia::GetLongestLine ( )
override

Definition at line 261 of file paragraph_skia.cc.

261 {
262 return SkScalarToDouble(paragraph_->getLongestLine());
263}

◆ GetMaxIntrinsicWidth()

double txt::ParagraphSkia::GetMaxIntrinsicWidth ( )
override

Definition at line 313 of file paragraph_skia.cc.

313 {
314 return SkScalarToDouble(paragraph_->getMaxIntrinsicWidth());
315}

◆ GetMaxWidth()

double txt::ParagraphSkia::GetMaxWidth ( )
override

Definition at line 253 of file paragraph_skia.cc.

253 {
254 return SkScalarToDouble(paragraph_->getMaxWidth());
255}

◆ GetMinIntrinsicWidth()

double txt::ParagraphSkia::GetMinIntrinsicWidth ( )
override

Definition at line 309 of file paragraph_skia.cc.

309 {
310 return SkScalarToDouble(paragraph_->getMinIntrinsicWidth());
311}

◆ GetNumberOfLines()

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

Definition at line 399 of file paragraph_skia.cc.

399 {
400 return paragraph_->lineNumber();
401}

◆ GetRectsForPlaceholders()

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

Definition at line 359 of file paragraph_skia.cc.

359 {
360 std::vector<skt::TextBox> skia_boxes = paragraph_->getRectsForPlaceholders();
361
362 std::vector<Paragraph::TextBox> boxes;
363 for (const skt::TextBox& skia_box : skia_boxes) {
364 boxes.emplace_back(skia_box.rect,
365 static_cast<TextDirection>(skia_box.direction));
366 }
367
368 return boxes;
369}

◆ 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 341 of file paragraph_skia.cc.

345 {
346 std::vector<skt::TextBox> skia_boxes = paragraph_->getRectsForRange(
347 start, end, static_cast<skt::RectHeightStyle>(rect_height_style),
348 static_cast<skt::RectWidthStyle>(rect_width_style));
349
350 std::vector<Paragraph::TextBox> boxes;
351 for (const skt::TextBox& skia_box : skia_boxes) {
352 boxes.emplace_back(skia_box.rect,
353 static_cast<TextDirection>(skia_box.direction));
354 }
355
356 return boxes;
357}

◆ GetWordBoundary()

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

Definition at line 394 of file paragraph_skia.cc.

394 {
395 skt::SkRange<size_t> range = paragraph_->getWordBoundary(offset);
396 return Paragraph::Range<size_t>(range.start, range.end);
397}

◆ Layout()

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

Definition at line 329 of file paragraph_skia.cc.

329 {
330 line_metrics_.reset();
331 line_metrics_styles_.clear();
332 paragraph_->layout(width);
333}

◆ Paint()

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

Definition at line 335 of file paragraph_skia.cc.

335 {
336 DisplayListParagraphPainter painter(builder, dl_paints_, impeller_enabled_);
337 paragraph_->paint(&painter, x, y);
338 return true;
339}
double y
double x

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