Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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
17
18namespace impeller {
19
20class LazyGlyphAtlas;
21class Context;
22
23class TextContents final : public Contents {
24 public:
26
28
29 void SetTextFrame(const std::shared_ptr<TextFrame>& frame);
30
31 void SetColor(Color color);
32
33 /// @brief Force the text color to apply to the rendered glyphs, even if those
34 /// glyphs are bitmaps.
35 ///
36 /// This is used to ensure that mask blurs work correctly on emoji.
37 void SetForceTextColor(bool value);
38
39 /// Must be set after text frame.
40 void SetTextProperties(Color color,
41 const std::optional<StrokeParameters>& stroke);
42
43 Color GetColor() const;
44
45 // |Contents|
46 void SetInheritedOpacity(Scalar opacity) override;
47
48 // The position provided in the DrawTextFrame call.
49 void SetPosition(Point position);
50
51 // The true screen space transform of the text, ignoring any offsets
52 // and adjustments that may be imparted on the text by the rendering
53 // context. This value is equivalent to Canvas::GetCurrentTransform()
54 // from the DrawTextFrame call.
56
57 // |Contents|
58 std::optional<Rect> GetCoverage(const Entity& entity) const override;
59
60 // |Contents|
61 bool Render(const ContentContext& renderer,
62 const Entity& entity,
63 RenderPass& pass) const override;
64
65 /// @brief Computes the vertex data for the render operation from
66 /// a collection of data drawn from the DrawTextFrame call
67 /// itself and the entity environment.
68 ///
69 /// vtx_contents A pointer to the array of PerVertexData to fill.
70 /// entity_transform The transform from the entity which might include
71 /// offsets due to an intermediate temporary rendering
72 /// target. This transform is used for final placement
73 /// of glyphs on the screen.
74 /// frame The TextFrame object from the DrawTextFrame call.
75 /// position The position from the DrawTextFrame call.
76 /// screen_transform The value of Canvas::GetCurrentTransform() from the
77 /// DrawTextFrame call. It is the full transform of the
78 /// text relative to screen space and is not adjusted
79 /// relative to the origin of an intermidate buffer
80 /// as the entity_transform may be. This transform is
81 /// used to retrieve metrics and glyph information from
82 /// the atlas so that the data matches what was stored
83 /// in the atlas when the global DisplayList did a
84 /// pre-pass to collect the glyph information.
85 /// glyph_properties The GlyphProperties providing the color and stroke
86 /// information from the Paint object used in the
87 /// DrawTextFrame call, optionally and only if they
88 /// should come into play for rendering the glyphs.
89 /// atlas The glyph atlas containing the glyph texture and
90 /// placement metrics for all of the glyphs that
91 /// appear in the TextFrame.
92 static void ComputeVertexData(
93 GlyphAtlasPipeline::VertexShader::PerVertexData* vtx_contents,
94 const Matrix& entity_transform,
95 const std::shared_ptr<TextFrame>& frame,
96 Point position,
97 const Matrix& screen_transform,
98 GlyphProperties glyph_properties,
99 const std::shared_ptr<GlyphAtlas>& atlas);
100
101 private:
102 std::shared_ptr<TextFrame> frame_;
103 Scalar inherited_opacity_ = 1.0;
104 Point position_;
105 Matrix screen_transform_;
106 bool force_text_color_ = false;
107 Color color_;
108 GlyphProperties properties_;
109
110 TextContents(const TextContents&) = delete;
111
112 TextContents& operator=(const TextContents&) = delete;
113};
114
115} // namespace impeller
116
117#endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_TEXT_CONTENTS_H_
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:30
static void ComputeVertexData(GlyphAtlasPipeline::VertexShader::PerVertexData *vtx_contents, const Matrix &entity_transform, const std::shared_ptr< TextFrame > &frame, Point position, const Matrix &screen_transform, GlyphProperties glyph_properties, const std::shared_ptr< GlyphAtlas > &atlas)
Computes the vertex data for the render operation from a collection of data drawn from the DrawTextFr...
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.
void SetTextProperties(Color color, const std::optional< StrokeParameters > &stroke)
Must be set after text frame.
void SetPosition(Point position)
void SetScreenTransform(const Matrix &transform)
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 SetColor(Color color)
float Scalar
Definition scalar.h:19
A 4x4 matrix using column-major storage.
Definition matrix.h:37