Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 <functional>
9#include <memory>
10#include <vector>
11
12#include "flutter/fml/macros.h"
16
17namespace impeller {
18
19class Texture;
20
21class TextureContents final : public Contents {
22 public:
24
25 ~TextureContents() override;
26
27 /// @brief A common case factory that marks the texture contents as having a
28 /// destination rectangle. In this situation, a subpass can be avoided
29 /// when image filters are applied.
30 static std::shared_ptr<TextureContents> MakeRect(Rect destination);
31
32 void SetLabel(std::string label);
33
34 void SetDestinationRect(Rect rect);
35
36 void SetTexture(std::shared_ptr<Texture> texture);
37
38 std::shared_ptr<Texture> GetTexture() const;
39
41
43
44 void SetSourceRect(const Rect& source_rect);
45
46 const Rect& GetSourceRect() const;
47
48 void SetStrictSourceRect(bool strict);
49
50 bool GetStrictSourceRect() const;
51
52 void SetOpacity(Scalar opacity);
53
54 Scalar GetOpacity() const;
55
56 void SetStencilEnabled(bool enabled);
57
58 // |Contents|
59 std::optional<Rect> GetCoverage(const Entity& entity) const override;
60
61 // |Contents|
62 std::optional<Snapshot> RenderToSnapshot(
63 const ContentContext& renderer,
64 const Entity& entity,
65 std::optional<Rect> coverage_limit = std::nullopt,
66 const std::optional<SamplerDescriptor>& sampler_descriptor = std::nullopt,
67 bool msaa_enabled = true,
68 int32_t mip_count = 1,
69 const std::string& label = "Texture Snapshot") const override;
70
71 // |Contents|
72 bool Render(const ContentContext& renderer,
73 const Entity& entity,
74 RenderPass& pass) const override;
75
76 // |Contents|
77 bool CanInheritOpacity(const Entity& entity) const override;
78
79 // |Contents|
80 void SetInheritedOpacity(Scalar opacity) override;
81
82 void SetDeferApplyingOpacity(bool defer_applying_opacity);
83
84 private:
85 std::string label_;
86
87 Rect destination_rect_;
88 bool stencil_enabled_ = true;
89
90 std::shared_ptr<Texture> texture_;
91 SamplerDescriptor sampler_descriptor_ = {};
92 Rect source_rect_;
93 bool strict_source_rect_enabled_ = false;
94 Scalar opacity_ = 1.0f;
95 Scalar inherited_opacity_ = 1.0f;
96 bool defer_applying_opacity_ = false;
97
98 TextureContents(const TextureContents&) = delete;
99
100 TextureContents& operator=(const TextureContents&) = delete;
101};
102
103} // namespace impeller
104
105#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
float Scalar
Definition scalar.h:18