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 
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 
28  Scalar scale,
29  Point offset,
30  const GlyphProperties& properties) const;
31 
33  const TextRun::GlyphPosition& glyph_position,
34  AxisAlignment alignment,
35  Point offset,
36  Scalar scale);
37 
38  static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size);
39 
40  //----------------------------------------------------------------------------
41  /// @brief The conservative bounding box for this text frame.
42  ///
43  /// @return The bounds rectangle. If there are no glyphs in this text
44  /// frame and empty Rectangle is returned instead.
45  ///
46  Rect GetBounds() const;
47 
48  //----------------------------------------------------------------------------
49  /// @brief The number of runs in this text frame.
50  ///
51  /// @return The run count.
52  ///
53  size_t GetRunCount() const;
54 
55  //----------------------------------------------------------------------------
56  /// @brief Returns a reference to all the text runs in this frame.
57  ///
58  /// @return The runs in this frame.
59  ///
60  const std::vector<TextRun>& GetRuns() const;
61 
62  //----------------------------------------------------------------------------
63  /// @brief Returns the paint color this text frame was recorded with.
64  ///
65  /// Non-bitmap/COLR fonts always use a black text color here, but
66  /// COLR fonts can potentially use the paint color in the glyph
67  /// atlas, so this color must be considered as part of the cache
68  /// key.
69  bool HasColor() const;
70 
71  //----------------------------------------------------------------------------
72  /// @brief The type of atlas this run should be emplaced in.
74 
75  TextFrame& operator=(TextFrame&& other) = default;
76 
77  TextFrame(const TextFrame& other) = default;
78 
79  private:
80  std::vector<TextRun> runs_;
81  Rect bounds_;
82  bool has_color_;
83 };
84 
85 } // namespace impeller
86 
87 #endif // FLUTTER_IMPELLER_TYPOGRAPHER_TEXT_FRAME_H_
impeller::TextFrame::operator=
TextFrame & operator=(TextFrame &&other)=default
impeller::TextFrame::HasColor
bool HasColor() const
Returns the paint color this text frame was recorded with.
Definition: text_frame.cc:35
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::GlyphProperties
Definition: font_glyph_pair.h:19
impeller::TextFrame::TextFrame
TextFrame()
impeller::TextFrame
Represents a collection of shaped text runs.
Definition: text_frame.h:19
impeller::TextFrame::~TextFrame
~TextFrame()
impeller::TextFrame::ComputeSubpixelPosition
static Point ComputeSubpixelPosition(const TextRun::GlyphPosition &glyph_position, AxisAlignment alignment, Point offset, Scalar scale)
Definition: text_frame.cc:68
impeller::TextFrame::GetRuns
const std::vector< TextRun > & GetRuns() const
Returns a reference to all the text runs in this frame.
Definition: text_frame.cc:26
impeller::TextFrame::GetRunCount
size_t GetRunCount() const
The number of runs in this text frame.
Definition: text_frame.cc:22
impeller::TextFrame::RoundScaledFontSize
static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size)
Definition: text_frame.cc:40
offset
SeparatedVector2 offset
Definition: stroke_path_geometry.cc:311
impeller::GlyphAtlas::Type
Type
Describes how the glyphs are represented in the texture.
Definition: glyph_atlas.h:31
impeller::FontGlyphMap
std::unordered_map< ScaledFont, std::unordered_set< SubpixelGlyph > > FontGlyphMap
Definition: font_glyph_pair.h:54
impeller::AxisAlignment
AxisAlignment
Determines the axis along which there is subpixel positioning.
Definition: font.h:20
impeller::TextFrame::CollectUniqueFontGlyphPairs
void CollectUniqueFontGlyphPairs(FontGlyphMap &glyph_map, Scalar scale, Point offset, const GlyphProperties &properties) const
Definition: text_frame.cc:87
impeller::TextFrame::GetBounds
Rect GetBounds() const
The conservative bounding box for this text frame.
Definition: text_frame.cc:18
text_run.h
impeller::TextFrame::GetAtlasType
GlyphAtlas::Type GetAtlasType() const
The type of atlas this run should be emplaced in.
Definition: text_frame.cc:30
impeller::TPoint< Scalar >
impeller::TextRun::GlyphPosition
Definition: text_run.h:22
scale
const Scalar scale
Definition: stroke_path_geometry.cc:308
glyph_atlas.h
impeller
Definition: aiks_blend_unittests.cc:18
impeller::TRect< Scalar >