| 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 #pragma once
6
7 #include "flutter/fml/macros.h"
8 #include "impeller/typographer/glyph_atlas.h"
9 #include "impeller/typographer/text_run.h"
10
11 namespace impeller {
12
13 //------------------------------------------------------------------------------
14 /// @brief Represents a collection of shaped text runs.
15 ///
16 /// This object is typically the entrypoint in the Impeller type
17 /// rendering subsystem.
18 ///
19 class TextFrame {
20 public:
21 TextFrame();
22
23 TextFrame(std::vector<TextRun>& runs, Rect bounds, bool has_color);
24
25 ~TextFrame();
26
27 void CollectUniqueFontGlyphPairs(FontGlyphMap& glyph_map, Scalar scale) const;
28
29 static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size);
30
31 //----------------------------------------------------------------------------
32 /// @brief The conservative bounding box for this text frame.
33 ///
34 /// @return The bounds rectangle. If there are no glyphs in this text
35 /// frame and empty Rectangle is returned instead.
36 ///
37 Rect GetBounds() const;
38
39 //----------------------------------------------------------------------------
40 /// @brief The number of runs in this text frame.
41 ///
42 /// @return The run count.
43 ///
44 size_t GetRunCount() const;
45
46 //----------------------------------------------------------------------------
47 /// @brief Returns a reference to all the text runs in this frame.
48 ///
49 /// @return The runs in this frame.
50 ///
51 const std::vector<TextRun>& GetRuns() const;
52
53 //----------------------------------------------------------------------------
54 /// @brief Whether any of the glyphs of this run are potentially
55 /// overlapping
56 ///
57 /// It is always safe to return true from this method. Generally,
58 /// any large blobs of text should return true to avoid
59 /// computationally complex calculations. This information is used
60 /// to apply opacity peephole optimizations to text blobs.
61 bool MaybeHasOverlapping() const;
62
63 //----------------------------------------------------------------------------
64 /// @brief The type of atlas this run should be emplaced in.
65 GlyphAtlas::Type GetAtlasType() const;
66
67 TextFrame& operator=(TextFrame&& other) = default;
68
69 TextFrame(const TextFrame& other) = default;
70
71 private:
72 std::vector<TextRun> runs_;
73 Rect bounds_;
74 bool has_color_ = false;
75 };
76
77 } // namespace impeller
impeller::TextFrame::operator=
TextFrame & operator=(TextFrame &&other)=default
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::TextFrame::TextFrame
TextFrame()
impeller::TextFrame
Represents a collection of shaped text runs.
Definition: text_frame.h:19
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:28
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:32
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 >