| Flutter Impeller |

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"
9 #include "impeller/typographer/glyph_atlas.h"
10 #include "impeller/typographer/text_run.h"
11
12 namespace 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 ///
20 class TextFrame {
21 public:
22 TextFrame();
23
24 TextFrame(std::vector<TextRun>& runs, Rect bounds, bool has_color);
25
26 ~TextFrame();
27
28 void CollectUniqueFontGlyphPairs(FontGlyphMap& glyph_map, Scalar scale) const;
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.
66 GlyphAtlas::Type GetAtlasType() const;
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_
impeller::TextFrame::operator=
TextFrame & operator=(TextFrame &&other)=default
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::TextFrame::TextFrame
TextFrame()
impeller::TextFrame
Represents a collection of shaped text runs.
Definition: text_frame.h:20
impeller::TextFrame::~TextFrame
~TextFrame()
impeller::TextFrame::CollectUniqueFontGlyphPairs
void CollectUniqueFontGlyphPairs(FontGlyphMap &glyph_map, Scalar scale) const
Definition: text_frame.cc:70
impeller::FontGlyphMap
std::unordered_map< ScaledFont, std::unordered_set< Glyph > > FontGlyphMap
Definition: font_glyph_pair.h:29
impeller::TextFrame::GetRuns
const std::vector< TextRun > & GetRuns() const
Returns a reference to all the text runs in this frame.
Definition: text_frame.cc:24
impeller::TextFrame::GetRunCount
size_t GetRunCount() const
The number of runs in this text frame.
Definition: text_frame.cc:20
impeller::TextFrame::RoundScaledFontSize
static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size)
Definition: text_frame.cc:66
impeller::TextFrame::MaybeHasOverlapping
bool MaybeHasOverlapping() const
Whether any of the glyphs of this run are potentially overlapping.
Definition: text_frame.cc:33
impeller::GlyphAtlas::Type
Type
Describes how the glyphs are represented in the texture.
Definition: glyph_atlas.h:33
impeller::TextFrame::GetBounds
Rect GetBounds() const
The conservative bounding box for this text frame.
Definition: text_frame.cc:16
text_run.h
impeller::TextFrame::GetAtlasType
GlyphAtlas::Type GetAtlasType() const
The type of atlas this run should be emplaced in.
Definition: text_frame.cc:28
glyph_atlas.h
impeller
Definition: aiks_context.cc:10
impeller::TRect< Scalar >