Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
text_frame.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_TYPOGRAPHER_TEXT_FRAME_H_
6#define FLUTTER_IMPELLER_TYPOGRAPHER_TEXT_FRAME_H_
7
8#include "flutter/fml/macros.h"
11
12namespace impeller {
13
14//------------------------------------------------------------------------------
15/// @brief Represents a collection of shaped text runs.
16///
17/// This object is typically the entrypoint in the Impeller type
18/// rendering subsystem.
19///
20class TextFrame {
21 public:
23
24 TextFrame(std::vector<TextRun>& runs, Rect bounds, bool has_color);
25
27
29
30 static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size);
31
32 //----------------------------------------------------------------------------
33 /// @brief The conservative bounding box for this text frame.
34 ///
35 /// @return The bounds rectangle. If there are no glyphs in this text
36 /// frame and empty Rectangle is returned instead.
37 ///
38 Rect GetBounds() const;
39
40 //----------------------------------------------------------------------------
41 /// @brief The number of runs in this text frame.
42 ///
43 /// @return The run count.
44 ///
45 size_t GetRunCount() const;
46
47 //----------------------------------------------------------------------------
48 /// @brief Returns a reference to all the text runs in this frame.
49 ///
50 /// @return The runs in this frame.
51 ///
52 const std::vector<TextRun>& GetRuns() const;
53
54 //----------------------------------------------------------------------------
55 /// @brief Whether any of the glyphs of this run are potentially
56 /// overlapping
57 ///
58 /// It is always safe to return true from this method. Generally,
59 /// any large blobs of text should return true to avoid
60 /// computationally complex calculations. This information is used
61 /// to apply opacity peephole optimizations to text blobs.
62 bool MaybeHasOverlapping() const;
63
64 //----------------------------------------------------------------------------
65 /// @brief The type of atlas this run should be emplaced in.
67
68 TextFrame& operator=(TextFrame&& other) = default;
69
70 TextFrame(const TextFrame& other) = default;
71
72 private:
73 std::vector<TextRun> runs_;
74 Rect bounds_;
75 bool has_color_ = false;
76};
77
78} // namespace impeller
79
80#endif // FLUTTER_IMPELLER_TYPOGRAPHER_TEXT_FRAME_H_
Type
Describes how the glyphs are represented in the texture.
Definition glyph_atlas.h:32
Represents a collection of shaped text runs.
Definition text_frame.h:20
Rect GetBounds() const
The conservative bounding box for this text frame.
Definition text_frame.cc:16
static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size)
Definition text_frame.cc:66
GlyphAtlas::Type GetAtlasType() const
The type of atlas this run should be emplaced in.
Definition text_frame.cc:28
TextFrame & operator=(TextFrame &&other)=default
void CollectUniqueFontGlyphPairs(FontGlyphMap &glyph_map, Scalar scale) const
Definition text_frame.cc:70
bool MaybeHasOverlapping() const
Whether any of the glyphs of this run are potentially overlapping.
Definition text_frame.cc:33
TextFrame(const TextFrame &other)=default
size_t GetRunCount() const
The number of runs in this text frame.
Definition text_frame.cc:20
const std::vector< TextRun > & GetRuns() const
Returns a reference to all the text runs in this frame.
Definition text_frame.cc:24
float Scalar
Definition scalar.h:18
std::unordered_map< ScaledFont, std::unordered_set< Glyph > > FontGlyphMap
const Scalar scale