Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
impeller::TextFrame Class Reference

Represents a collection of shaped text runs. More...

#include <text_frame.h>

Public Member Functions

 TextFrame ()
 
 TextFrame (std::vector< TextRun > &runs, Rect bounds, bool has_color)
 
 ~TextFrame ()
 
void CollectUniqueFontGlyphPairs (FontGlyphMap &glyph_map, Scalar scale, Point offset, const GlyphProperties &properties) const
 
Rect GetBounds () const
 The conservative bounding box for this text frame. More...
 
size_t GetRunCount () const
 The number of runs in this text frame. More...
 
const std::vector< TextRun > & GetRuns () const
 Returns a reference to all the text runs in this frame. More...
 
bool HasColor () const
 Returns the paint color this text frame was recorded with. More...
 
GlyphAtlas::Type GetAtlasType () const
 The type of atlas this run should be emplaced in. More...
 
TextFrameoperator= (TextFrame &&other)=default
 
 TextFrame (const TextFrame &other)=default
 

Static Public Member Functions

static Point ComputeSubpixelPosition (const TextRun::GlyphPosition &glyph_position, AxisAlignment alignment, Point offset, Scalar scale)
 
static Scalar RoundScaledFontSize (Scalar scale, Scalar point_size)
 

Detailed Description

Represents a collection of shaped text runs.

        This object is typically the entrypoint in the Impeller type
        rendering subsystem.

Definition at line 19 of file text_frame.h.

Constructor & Destructor Documentation

◆ TextFrame() [1/3]

impeller::TextFrame::TextFrame ( )
default

◆ TextFrame() [2/3]

impeller::TextFrame::TextFrame ( std::vector< TextRun > &  runs,
Rect  bounds,
bool  has_color 
)

Definition at line 13 of file text_frame.cc.

14 : runs_(std::move(runs)), bounds_(bounds), has_color_(has_color) {}
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ ~TextFrame()

impeller::TextFrame::~TextFrame ( )
default

◆ TextFrame() [3/3]

impeller::TextFrame::TextFrame ( const TextFrame other)
default

Member Function Documentation

◆ CollectUniqueFontGlyphPairs()

void impeller::TextFrame::CollectUniqueFontGlyphPairs ( FontGlyphMap glyph_map,
Scalar  scale,
Point  offset,
const GlyphProperties properties 
) const

Definition at line 87 of file text_frame.cc.

91 {
92 for (const TextRun& run : GetRuns()) {
93 const Font& font = run.GetFont();
94 auto rounded_scale =
95 RoundScaledFontSize(scale, font.GetMetrics().point_size);
96 auto& set = glyph_map[ScaledFont{font, rounded_scale}];
97 for (const TextRun::GlyphPosition& glyph_position :
98 run.GetGlyphPositions()) {
100 glyph_position, font.GetAxisAlignment(), offset, scale);
101 set.emplace(glyph_position.glyph, subpixel, properties);
102 }
103 }
104}
static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size)
Definition: text_frame.cc:40
static Point ComputeSubpixelPosition(const TextRun::GlyphPosition &glyph_position, AxisAlignment alignment, Point offset, Scalar scale)
Definition: text_frame.cc:68
const std::vector< TextRun > & GetRuns() const
Returns a reference to all the text runs in this frame.
Definition: text_frame.cc:26
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76
font
Font Metadata and Metrics.
TPoint< Scalar > Point
Definition: point.h:322
Definition: run.py:1
const Scalar scale
SeparatedVector2 offset

◆ ComputeSubpixelPosition()

Point impeller::TextFrame::ComputeSubpixelPosition ( const TextRun::GlyphPosition glyph_position,
AxisAlignment  alignment,
Point  offset,
Scalar  scale 
)
static

Definition at line 68 of file text_frame.cc.

72 {
73 Point pos = glyph_position.position + offset;
74 switch (alignment) {
76 return Point(0, 0);
84 }
85}
SkPoint pos
static constexpr Scalar ComputeFractionalPosition(Scalar value)
Definition: text_frame.cc:49
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181

◆ GetAtlasType()

GlyphAtlas::Type impeller::TextFrame::GetAtlasType ( ) const

The type of atlas this run should be emplaced in.

Definition at line 30 of file text_frame.cc.

◆ GetBounds()

Rect impeller::TextFrame::GetBounds ( ) const

The conservative bounding box for this text frame.

Returns
The bounds rectangle. If there are no glyphs in this text frame and empty Rectangle is returned instead.

Definition at line 18 of file text_frame.cc.

18 {
19 return bounds_;
20}

◆ GetRunCount()

size_t impeller::TextFrame::GetRunCount ( ) const

The number of runs in this text frame.

Returns
The run count.

Definition at line 22 of file text_frame.cc.

22 {
23 return runs_.size();
24}

◆ GetRuns()

const std::vector< TextRun > & impeller::TextFrame::GetRuns ( ) const

Returns a reference to all the text runs in this frame.

Returns
The runs in this frame.

Definition at line 26 of file text_frame.cc.

26 {
27 return runs_;
28}

◆ HasColor()

bool impeller::TextFrame::HasColor ( ) const

Returns the paint color this text frame was recorded with.

        Non-bitmap/COLR fonts always use a black text color here, but
        COLR fonts can potentially use the paint color in the glyph
        atlas, so this color must be considered as part of the cache
        key. 

Definition at line 35 of file text_frame.cc.

35 {
36 return has_color_;
37}

◆ operator=()

TextFrame & impeller::TextFrame::operator= ( TextFrame &&  other)
default

◆ RoundScaledFontSize()

Scalar impeller::TextFrame::RoundScaledFontSize ( Scalar  scale,
Scalar  point_size 
)
static

Definition at line 40 of file text_frame.cc.

40 {
41 // An arbitrarily chosen maximum text scale to ensure that regardless of the
42 // CTM, a glyph will fit in the atlas. If we clamp significantly, this may
43 // reduce fidelity but is preferable to the alternative of failing to render.
44 constexpr Scalar kMaximumTextScale = 48;
45 Scalar result = std::round(scale * 100) / 100;
46 return std::clamp(result, 0.0f, kMaximumTextScale);
47}
static void round(SkPoint *p)
static unsigned clamp(SkFixed fx, int max)
GAsyncResult * result
float Scalar
Definition: scalar.h:18

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