Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
14
15namespace impeller {
16
17class LazyGlyphAtlas;
18class Context;
19
20class TextContents final : public Contents {
21 public:
23
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
45
46 std::optional<Rect> GetTextFrameBounds() const;
47
48 // |Contents|
49 std::optional<Rect> GetCoverage(const Entity& entity) const override;
50
51 // |Contents|
53 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
54 Scalar scale) override;
55
56 void SetScale(Scalar scale) { scale_ = scale; }
57
58 // |Contents|
59 bool Render(const ContentContext& renderer,
60 const Entity& entity,
61 RenderPass& pass) const override;
62
63 private:
64 std::shared_ptr<TextFrame> frame_;
65 Scalar scale_ = 1.0;
66 Color color_;
67 Scalar inherited_opacity_ = 1.0;
68 Vector2 offset_;
69 bool force_text_color_ = false;
70
71 TextContents(const TextContents&) = delete;
72
73 TextContents& operator=(const TextContents&) = delete;
74};
75
76} // namespace impeller
77
78#endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_TEXT_CONTENTS_H_
SkColor4f color
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:33
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...
void SetOffset(Vector2 offset)
bool CanInheritOpacity(const Entity &entity) const override
Whether or not this contents can accept the opacity peephole optimization.
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
void SetForceTextColor(bool value)
Force the text color to apply to the rendered glyphs, even if those glyphs are bitmaps.
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
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.
void SetTextFrame(const std::shared_ptr< TextFrame > &frame)
void SetScale(Scalar scale)
void SetColor(Color color)
std::optional< Rect > GetTextFrameBounds() const
double frame
Definition examples.cpp:31
float Scalar
Definition scalar.h:18
const Scalar scale
Point offset