| Flutter Impeller |

filter_input.cc
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 #include "impeller/entity/contents/filters/inputs/filter_input.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "flutter/fml/logging.h"
11 #include "impeller/entity/contents/filters/filter_contents.h"
12 #include "impeller/entity/contents/filters/inputs/contents_filter_input.h"
13 #include "impeller/entity/contents/filters/inputs/filter_contents_filter_input.h"
14 #include "impeller/entity/contents/filters/inputs/placeholder_filter_input.h"
15 #include "impeller/entity/contents/filters/inputs/texture_filter_input.h"
16
17 namespace impeller {
18
19 FilterInput::Ref FilterInput::Make(Variant input, bool msaa_enabled) {
20 if (auto filter = std::get_if<std::shared_ptr<FilterContents>>(&input)) {
21 return std::static_pointer_cast<FilterInput>(
22 std::shared_ptr<FilterContentsFilterInput>(
23 new FilterContentsFilterInput(*filter)));
24 }
25
26 if (auto contents = std::get_if<std::shared_ptr<Contents>>(&input)) {
27 return std::static_pointer_cast<FilterInput>(
28 std::shared_ptr<ContentsFilterInput>(
29 new ContentsFilterInput(*contents, msaa_enabled)));
30 }
31
32 if (auto texture = std::get_if<std::shared_ptr<Texture>>(&input)) {
33 return Make(*texture, Matrix());
34 }
35
36 if (auto rect = std::get_if<Rect>(&input)) {
37 return std::shared_ptr<PlaceholderFilterInput>(
38 new PlaceholderFilterInput(*rect));
39 }
40
41 FML_UNREACHABLE();
42 }
43
44 FilterInput::Ref FilterInput::Make(std::shared_ptr<Texture> texture,
45 Matrix local_transform) {
46 return std::shared_ptr<TextureFilterInput>(
47 new TextureFilterInput(std::move(texture), local_transform));
48 }
49
50 FilterInput::Vector FilterInput::Make(std::initializer_list<Variant> inputs) {
51 FilterInput::Vector result;
52 result.reserve(inputs.size());
53 for (const auto& input : inputs) {
54 result.push_back(Make(input));
55 }
56 return result;
57 }
58
59 Matrix FilterInput::GetLocalTransform(const Entity& entity) const {
60 return Matrix();
61 }
62
63 std::optional<Rect> FilterInput::GetLocalCoverage(const Entity& entity) const {
64 Entity local_entity = entity.Clone();
65 local_entity.SetTransform(GetLocalTransform(entity));
66 return GetCoverage(local_entity);
67 }
68
69 std::optional<Rect> FilterInput::GetSourceCoverage(
70 const Matrix& effect_transform,
71 const Rect& output_limit) const {
72 return output_limit;
73 }
74
75 Matrix FilterInput::GetTransform(const Entity& entity) const {
76 return entity.GetTransform() * GetLocalTransform(entity);
77 }
78
79 void FilterInput::PopulateGlyphAtlas(
80 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
81 Scalar scale) {}
82
83 FilterInput::~FilterInput() = default;
84
85 bool FilterInput::IsTranslationOnly() const {
86 return true;
87 }
88
89 bool FilterInput::IsLeaf() const {
90 return true;
91 }
92
93 void FilterInput::SetLeafInputs(const FilterInput::Vector& inputs) {}
94
95 void FilterInput::SetEffectTransform(const Matrix& matrix) {}
96
97 void FilterInput::SetRenderingMode(Entity::RenderingMode rendering_mode) {}
98
99 } // namespace impeller
impeller::FilterContentsFilterInput
Definition: filter_contents_filter_input.h:12
texture_filter_input.h
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::FilterInput::SetEffectTransform
virtual void SetEffectTransform(const Matrix &matrix)
Sets the effect transform of filter inputs.
Definition: filter_input.cc:95
impeller::Entity::GetTransform
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition: entity.cc:49
impeller::FilterInput::IsLeaf
virtual bool IsLeaf() const
Returns true unless this input is a FilterInput, which may take other inputs.
Definition: filter_input.cc:89
impeller::FilterInput::Make
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
Definition: filter_input.cc:19
impeller::FilterInput::IsTranslationOnly
virtual bool IsTranslationOnly() const
Definition: filter_input.cc:85
impeller::FilterInput::Ref
std::shared_ptr< FilterInput > Ref
Definition: filter_input.h:32
placeholder_filter_input.h
impeller::TextureFilterInput
Definition: texture_filter_input.h:14
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::GetCoverage
virtual std::optional< Rect > GetCoverage(const Entity &entity) const =0
impeller::Entity
Definition: entity.h:21
filter_contents.h
impeller::ContentsFilterInput
Definition: contents_filter_input.h:12
impeller::FilterInput::Variant
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:37
filter_input.h
impeller::FilterInput::SetLeafInputs
virtual void SetLeafInputs(const FilterInput::Vector &inputs)
Replaces the inputs of all leaf FilterContents with a new set of inputs.
Definition: filter_input.cc:93
filter_contents_filter_input.h
impeller::FilterInput::SetRenderingMode
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode)
Turns on subpass mode for filter inputs.
Definition: filter_input.cc:97
impeller::Entity::SetTransform
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
Definition: entity.cc:53
impeller::Entity::Clone
Entity Clone() const
Definition: entity.cc:181
impeller::FilterInput::GetLocalCoverage
std::optional< Rect > GetLocalCoverage(const Entity &entity) const
Definition: filter_input.cc:63
contents_filter_input.h
impeller::Entity::RenderingMode
RenderingMode
Definition: entity.h:26
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
impeller
Definition: aiks_context.cc:10
impeller::FilterInput::GetSourceCoverage
virtual std::optional< Rect > GetSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const
Definition: filter_input.cc:69
impeller::TRect< Scalar >
impeller::FilterInput::PopulateGlyphAtlas
virtual void PopulateGlyphAtlas(const std::shared_ptr< LazyGlyphAtlas > &lazy_glyph_atlas, Scalar scale)
Definition: filter_input.cc:79
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
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::PlaceholderFilterInput
Definition: placeholder_filter_input.h:12
impeller::FilterInput::~FilterInput
virtual ~FilterInput()