Flutter Engine
 
Loading...
Searching...
No Matches
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 17 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 206 of file paragraph_skia.cc.

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

◆ ~ParagraphSkia()

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

Member Function Documentation

◆ DidExceedMaxLines()

bool txt::ParagraphSkia::DidExceedMaxLines ( )
override

Definition at line 287 of file paragraph_skia.cc.

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

◆ GetAlphabeticBaseline()

double txt::ParagraphSkia::GetAlphabeticBaseline ( )
override

Definition at line 279 of file paragraph_skia.cc.

279 {
280 return SkScalarToDouble(paragraph_->getAlphabeticBaseline());
281}

◆ GetClosestGlyphInfoAtCoordinate()

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

Definition at line 351 of file paragraph_skia.cc.

354 {
355 return paragraph_->getClosestUTF16GlyphInfoAt(dx, dy, glyphInfo);
356};

◆ GetGlyphInfoAt()

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

Definition at line 345 of file paragraph_skia.cc.

347 {
348 return paragraph_->getGlyphInfoAtUTF16Offset(offset, glyphInfo);
349}

◆ GetGlyphPositionAtCoordinate()

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

Definition at line 335 of file paragraph_skia.cc.

337 {
338 skt::PositionWithAffinity skia_pos =
339 paragraph_->getGlyphPositionAtCoordinate(dx, dy);
340
341 return ParagraphSkia::PositionWithAffinity(
342 skia_pos.position, static_cast<Affinity>(skia_pos.affinity));
343}

◆ GetHeight()

double txt::ParagraphSkia::GetHeight ( )
override

Definition at line 217 of file paragraph_skia.cc.

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

◆ GetIdeographicBaseline()

double txt::ParagraphSkia::GetIdeographicBaseline ( )
override

Definition at line 283 of file paragraph_skia.cc.

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

◆ GetLineMetrics()

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

Definition at line 225 of file paragraph_skia.cc.

225 {
226 if (!line_metrics_) {
227 std::vector<skt::LineMetrics> metrics;
228 paragraph_->getLineMetrics(metrics);
229
230 line_metrics_.emplace();
231 line_metrics_styles_.reserve(
232 std::accumulate(metrics.begin(), metrics.end(), 0,
233 [](const int a, const skt::LineMetrics& b) {
234 return a + b.fLineMetrics.size();
235 }));
236
237 for (const skt::LineMetrics& skm : metrics) {
238 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
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 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
263 return line_metrics_.value();
264}

References txt::LineMetrics::ascent, txt::LineMetrics::baseline, txt::LineMetrics::descent, txt::LineMetrics::height, txt::LineMetrics::left, txt::LineMetrics::line_number, txt::LineMetrics::run_metrics, txt::LineMetrics::unscaled_ascent, and txt::LineMetrics::width.

◆ GetLineMetricsAt()

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

Definition at line 266 of file paragraph_skia.cc.

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

◆ GetLineNumberAt()

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

Definition at line 367 of file paragraph_skia.cc.

367 {
368 return paragraph_->getLineNumberAtUTF16Offset(codeUnitIndex);
369}

◆ GetLongestLine()

double txt::ParagraphSkia::GetLongestLine ( )
override

Definition at line 221 of file paragraph_skia.cc.

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

◆ GetMaxIntrinsicWidth()

double txt::ParagraphSkia::GetMaxIntrinsicWidth ( )
override

Definition at line 275 of file paragraph_skia.cc.

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

◆ GetMaxWidth()

double txt::ParagraphSkia::GetMaxWidth ( )
override

Definition at line 213 of file paragraph_skia.cc.

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

◆ GetMinIntrinsicWidth()

double txt::ParagraphSkia::GetMinIntrinsicWidth ( )
override

Definition at line 271 of file paragraph_skia.cc.

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

◆ GetNumberOfLines()

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

Definition at line 363 of file paragraph_skia.cc.

363 {
364 return paragraph_->lineNumber();
365}

◆ GetRectsForPlaceholders()

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

Definition at line 322 of file paragraph_skia.cc.

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

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

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

References txt::end, and start.

◆ GetWordBoundary()

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

Definition at line 358 of file paragraph_skia.cc.

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

◆ Layout()

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

Definition at line 291 of file paragraph_skia.cc.

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

References flutter::Paragraph::width().

◆ Paint()

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

Definition at line 297 of file paragraph_skia.cc.

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

References x, and y.


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