| Flutter Impeller |

text_contents.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_ENTITY_CONTENTS_TEXT_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_TEXT_CONTENTS_H_
7
8 #include <memory>
9
10 #include "impeller/entity/contents/contents.h"
11 #include "impeller/geometry/color.h"
12 #include "impeller/typographer/glyph_atlas.h"
13 #include "impeller/typographer/text_frame.h"
14
15 namespace impeller {
16
17 class LazyGlyphAtlas;
18 class Context;
19
20 class TextContents final : public Contents {
21 public:
22 TextContents();
23
24 ~TextContents();
25
26 void SetTextFrame(const std::shared_ptr<TextFrame>& frame);
27
28 void SetColor(Color color);
29
30 /// @brief Force the text color to apply to the rendered glyphs, even if those
31 /// glyphs are bitmaps.
32 ///
33 /// This is used to ensure that mask blurs work correctly on emoji.
34 void SetForceTextColor(bool value);
35
36 Color GetColor() const;
37
38 // |Contents|
39 bool CanInheritOpacity(const Entity& entity) const override;
40
41 // |Contents|
42 void SetInheritedOpacity(Scalar opacity) override;
43
44 void SetOffset(Vector2 offset);
45
46 std::optional<Rect> GetTextFrameBounds() const;
47
48 // |Contents|
49 std::optional<Rect> GetCoverage(const Entity& entity) const override;
50
51 // |Contents|
52 void PopulateGlyphAtlas(
53 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
54 Scalar scale) override;
55
56 // |Contents|
57 bool Render(const ContentContext& renderer,
58 const Entity& entity,
59 RenderPass& pass) const override;
60
61 private:
62 std::shared_ptr<TextFrame> frame_;
63 Scalar scale_ = 1.0;
64 Color color_;
65 Scalar inherited_opacity_ = 1.0;
66 Vector2 offset_;
67 bool force_text_color_ = false;
68
69 TextContents(const TextContents&) = delete;
70
71 TextContents& operator=(const TextContents&) = delete;
72 };
73
74 } // namespace impeller
75
76 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_TEXT_CONTENTS_H_
impeller::TextContents::CanInheritOpacity
bool CanInheritOpacity(const Entity &entity) const override
Whether or not this contents can accept the opacity peephole optimization.
Definition: text_contents.cc:37
contents.h
impeller::TextContents
Definition: text_contents.h:20
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::TextContents::GetTextFrameBounds
std::optional< Rect > GetTextFrameBounds() const
impeller::Color
Definition: color.h:124
impeller::TextContents::SetForceTextColor
void SetForceTextColor(bool value)
Force the text color to apply to the rendered glyphs, even if those glyphs are bitmaps.
Definition: text_contents.cc:49
impeller::TextContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
Definition: text_contents.cc:53
impeller::TextContents::SetColor
void SetColor(Color color)
Definition: text_contents.cc:29
impeller::Entity
Definition: entity.h:21
impeller::TextContents::PopulateGlyphAtlas
void PopulateGlyphAtlas(const std::shared_ptr< LazyGlyphAtlas > &lazy_glyph_atlas, Scalar scale) override
Add any text data to the specified lazy atlas. The scale parameter must be used again later when draw...
Definition: text_contents.cc:57
impeller::TextContents::~TextContents
~TextContents()
impeller::TextContents::SetOffset
void SetOffset(Vector2 offset)
Definition: text_contents.cc:45
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::TextContents::TextContents
TextContents()
impeller::TextContents::SetInheritedOpacity
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
Definition: text_contents.cc:41
impeller::TPoint< Scalar >
impeller::TextContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: text_contents.cc:64
scale
const Scalar scale
Definition: stroke_path_geometry.cc:297
impeller::TextContents::GetColor
Color GetColor() const
Definition: text_contents.cc:33
color.h
impeller::TextContents::SetTextFrame
void SetTextFrame(const std::shared_ptr< TextFrame > &frame)
Definition: text_contents.cc:25
glyph_atlas.h
text_frame.h
offset
Point offset
Definition: stroke_path_geometry.cc:300
impeller::Contents
Definition: contents.h:34
impeller
Definition: aiks_blur_unittests.cc:20
impeller::ContentContext
Definition: content_context.h:392