| Flutter Impeller |

filter_input.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_FILTERS_INPUTS_FILTER_INPUT_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_FILTERS_INPUTS_FILTER_INPUT_H_
7
8 #include <memory>
9 #include <optional>
10 #include <variant>
11 #include <vector>
12
13 #include "impeller/entity/contents/contents.h"
14 #include "impeller/entity/entity.h"
15 #include "impeller/geometry/rect.h"
16
17 namespace impeller {
18
19 class ContentContext;
20 class FilterContents;
21
22 /// `FilterInput` is a lazy/single eval `Snapshot` which may be shared across
23 /// filter parameters and used to evaluate input coverage.
24 ///
25 /// A `FilterInput` can be re-used for any filter inputs across an entity's
26 /// filter graph without repeating subpasses unnecessarily.
27 ///
28 /// Filters may decide to not evaluate inputs in situations where they won't
29 /// contribute to the filter's output texture.
30 class FilterInput {
31 public:
32 using Ref = std::shared_ptr<FilterInput>;
33 using Vector = std::vector<FilterInput::Ref>;
34 using Variant = std::variant<std::shared_ptr<FilterContents>,
35 std::shared_ptr<Contents>,
36 std::shared_ptr<Texture>,
37 Rect>;
38
39 virtual ~FilterInput();
40
41 static FilterInput::Ref Make(Variant input, bool msaa_enabled = true);
42
43 static FilterInput::Ref Make(std::shared_ptr<Texture> input,
44 Matrix local_transform);
45
46 static FilterInput::Vector Make(std::initializer_list<Variant> inputs);
47
48 virtual std::optional<Snapshot> GetSnapshot(
49 std::string_view label,
50 const ContentContext& renderer,
51 const Entity& entity,
52 std::optional<Rect> coverage_limit = std::nullopt,
53 int32_t mip_count = 1) const = 0;
54
55 std::optional<Rect> GetLocalCoverage(const Entity& entity) const;
56
57 virtual std::optional<Rect> GetCoverage(const Entity& entity) const = 0;
58
59 virtual std::optional<Rect> GetSourceCoverage(const Matrix& effect_transform,
60 const Rect& output_limit) const;
61
62 /// @brief Get the local transform of this filter input. This transform is
63 /// relative to the `Entity` transform space.
64 virtual Matrix GetLocalTransform(const Entity& entity) const;
65
66 /// @brief Get the transform of this `FilterInput`. This is equivalent to
67 /// calling `entity.GetTransform() * GetLocalTransform()`.
68 virtual Matrix GetTransform(const Entity& entity) const;
69
70 /// @brief Sets the effect transform of filter inputs.
71 virtual void SetEffectTransform(const Matrix& matrix);
72
73 /// @brief Turns on subpass mode for filter inputs.
74 virtual void SetRenderingMode(Entity::RenderingMode rendering_mode);
75 };
76
77 } // namespace impeller
78
79 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_FILTERS_INPUTS_FILTER_INPUT_H_
impeller::ContentContext
Definition: content_context.h:138
impeller::Entity
Definition: entity.h:20
impeller::Entity::RenderingMode
RenderingMode
Definition: entity.h:27
impeller::FilterInput
Definition: filter_input.h:30
impeller::FilterInput::GetSourceCoverage
virtual std::optional< Rect > GetSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const
Definition: filter_input.cc:69
impeller::FilterInput::SetEffectTransform
virtual void SetEffectTransform(const Matrix &matrix)
Sets the effect transform of filter inputs.
Definition: filter_input.cc:81
impeller::FilterInput::Ref
std::shared_ptr< FilterInput > Ref
Definition: filter_input.h:32
impeller::FilterInput::GetTransform
virtual Matrix GetTransform(const Entity &entity) const
Get the transform of this FilterInput. This is equivalent to calling entity.GetTransform() * GetLocal...
Definition: filter_input.cc:75
impeller::FilterInput::GetLocalCoverage
std::optional< Rect > GetLocalCoverage(const Entity &entity) const
Definition: filter_input.cc:63
impeller::FilterInput::Variant
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:37
impeller::FilterInput::GetCoverage
virtual std::optional< Rect > GetCoverage(const Entity &entity) const =0
impeller::FilterInput::Make
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
Definition: filter_input.cc:19
impeller::FilterInput::GetLocalTransform
virtual Matrix GetLocalTransform(const Entity &entity) const
Get the local transform of this filter input. This transform is relative to the Entity transform spac...
Definition: filter_input.cc:59
impeller::FilterInput::~FilterInput
virtual ~FilterInput()
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
impeller::FilterInput::SetRenderingMode
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode)
Turns on subpass mode for filter inputs.
Definition: filter_input.cc:83
impeller::FilterInput::GetSnapshot
virtual std::optional< Snapshot > GetSnapshot(std::string_view label, const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit=std::nullopt, int32_t mip_count=1) const =0
contents.h
entity.h
impeller
Definition: allocation.cc:12
rect.h
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::TRect< Scalar >