| 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;
65 local_entity.SetTransformation(GetLocalTransform(entity));
66 return GetCoverage(local_entity);
67 }
68
69 Matrix FilterInput::GetTransform(const Entity& entity) const {
70 return entity.GetTransformation() * GetLocalTransform(entity);
71 }
72
73 void FilterInput::PopulateGlyphAtlas(
74 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
75 Scalar scale) {}
76
77 FilterInput::~FilterInput() = default;
78
79 bool FilterInput::IsTranslationOnly() const {
80 return true;
81 }
82
83 bool FilterInput::IsLeaf() const {
84 return true;
85 }
86
87 void FilterInput::SetLeafInputs(const FilterInput::Vector& inputs) {}
88
89 void FilterInput::SetEffectTransform(const Matrix& matrix) {}
90
91 void FilterInput::SetRenderingMode(Entity::RenderingMode rendering_mode) {}
92
93 } // namespace impeller
impeller::Entity::SetTransformation
void SetTransformation(const Matrix &transformation)
Definition: entity.cc:53
impeller::FilterContentsFilterInput
Definition: filter_contents_filter_input.h:11
texture_filter_input.h
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::FilterInput::SetEffectTransform
virtual void SetEffectTransform(const Matrix &matrix)
Sets the effect transform of filter inputs.
Definition: filter_input.cc:89
impeller::FilterInput::IsLeaf
virtual bool IsLeaf() const
Returns true unless this input is a FilterInput, which may take other inputs.
Definition: filter_input.cc:83
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:79
impeller::FilterInput::Ref
std::shared_ptr< FilterInput > Ref
Definition: filter_input.h:31
placeholder_filter_input.h
impeller::TextureFilterInput
Definition: texture_filter_input.h:13
impeller::FilterInput::GetTransform
virtual Matrix GetTransform(const Entity &entity) const
Get the transform of this FilterInput. This is equivalent to calling entity.GetTransformation() * Get...
Definition: filter_input.cc:69
impeller::Entity::GetTransformation
const Matrix & GetTransformation() const
Definition: entity.cc:49
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:11
impeller::FilterInput::Variant
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:36
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:87
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:91
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:32
impeller
Definition: aiks_context.cc:10
impeller::FilterInput::PopulateGlyphAtlas
virtual void PopulateGlyphAtlas(const std::shared_ptr< LazyGlyphAtlas > &lazy_glyph_atlas, Scalar scale)
Definition: filter_input.cc:73
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:36
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:11
impeller::FilterInput::~FilterInput
virtual ~FilterInput()