Flutter Engine
The Flutter Engine
texture_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_TEXTURE_CONTENTS_H_
6#define FLUTTER_IMPELLER_ENTITY_CONTENTS_TEXTURE_CONTENTS_H_
7
8#include <memory>
9
12
13namespace impeller {
14
15class Texture;
16
17class TextureContents final : public Contents {
18 public:
20
21 ~TextureContents() override;
22
23 /// @brief A common case factory that marks the texture contents as having a
24 /// destination rectangle. In this situation, a subpass can be avoided
25 /// when image filters are applied.
26 static std::shared_ptr<TextureContents> MakeRect(Rect destination);
27
28 void SetLabel(std::string label);
29
31
32 void SetTexture(std::shared_ptr<Texture> texture);
33
34 std::shared_ptr<Texture> GetTexture() const;
35
37
39
40 void SetSourceRect(const Rect& source_rect);
41
42 const Rect& GetSourceRect() const;
43
44 void SetStrictSourceRect(bool strict);
45
46 bool GetStrictSourceRect() const;
47
48 void SetOpacity(Scalar opacity);
49
50 Scalar GetOpacity() const;
51
52 void SetStencilEnabled(bool enabled);
53
54 // |Contents|
55 std::optional<Rect> GetCoverage(const Entity& entity) const override;
56
57 // |Contents|
58 std::optional<Snapshot> RenderToSnapshot(
60 const Entity& entity,
61 std::optional<Rect> coverage_limit = std::nullopt,
62 const std::optional<SamplerDescriptor>& sampler_descriptor = std::nullopt,
63 bool msaa_enabled = true,
64 int32_t mip_count = 1,
65 const std::string& label = "Texture Snapshot") const override;
66
67 // |Contents|
68 bool Render(const ContentContext& renderer,
69 const Entity& entity,
70 RenderPass& pass) const override;
71
72 // |Contents|
73 bool CanInheritOpacity(const Entity& entity) const override;
74
75 // |Contents|
76 void SetInheritedOpacity(Scalar opacity) override;
77
78 void SetDeferApplyingOpacity(bool defer_applying_opacity);
79
80 private:
81 std::string label_;
82
83 Rect destination_rect_;
84 bool stencil_enabled_ = true;
85
86 std::shared_ptr<Texture> texture_;
87 SamplerDescriptor sampler_descriptor_ = {};
88 Rect source_rect_;
89 bool strict_source_rect_enabled_ = false;
90 Scalar opacity_ = 1.0f;
91 Scalar inherited_opacity_ = 1.0f;
92 bool defer_applying_opacity_ = false;
93
94 TextureContents(const TextureContents&) = delete;
95
96 TextureContents& operator=(const TextureContents&) = delete;
97};
98
99} // namespace impeller
100
101#endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_TEXTURE_CONTENTS_H_
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
std::shared_ptr< Texture > GetTexture() const
void SetSourceRect(const Rect &source_rect)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
void SetStrictSourceRect(bool strict)
void SetLabel(std::string label)
void SetDeferApplyingOpacity(bool defer_applying_opacity)
const SamplerDescriptor & GetSamplerDescriptor() const
void SetOpacity(Scalar opacity)
void SetSamplerDescriptor(SamplerDescriptor desc)
static std::shared_ptr< TextureContents > MakeRect(Rect destination)
A common case factory that marks the texture contents as having a destination rectangle....
const Rect & GetSourceRect() const
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
std::optional< Snapshot > RenderToSnapshot(const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit=std::nullopt, const std::optional< SamplerDescriptor > &sampler_descriptor=std::nullopt, bool msaa_enabled=true, int32_t mip_count=1, const std::string &label="Texture Snapshot") const override
Render this contents to a snapshot, respecting the entity's transform, path, clip depth,...
bool CanInheritOpacity(const Entity &entity) const override
Whether or not this contents can accept the opacity peephole optimization.
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 SetTexture(std::shared_ptr< Texture > texture)
void SetStencilEnabled(bool enabled)
void SetDestinationRect(Rect rect)
FlTexture * texture
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
float Scalar
Definition: scalar.h:18