| Flutter Impeller |

filter_contents_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_contents_filter_input.h"
6
7 #include <utility>
8
9 #include "impeller/base/strings.h"
10 #include "impeller/entity/contents/filters/filter_contents.h"
11
12 namespace impeller {
13
14 FilterContentsFilterInput::FilterContentsFilterInput(
15 std::shared_ptr<FilterContents> filter)
16 : filter_(std::move(filter)) {}
17
18 FilterContentsFilterInput::~FilterContentsFilterInput() = default;
19
20 FilterInput::Variant FilterContentsFilterInput::GetInput() const {
21 return filter_;
22 }
23
24 std::optional<Snapshot> FilterContentsFilterInput::GetSnapshot(
25 const std::string& label,
26 const ContentContext& renderer,
27 const Entity& entity,
28 std::optional<Rect> coverage_limit) const {
29 if (!snapshot_.has_value()) {
30 snapshot_ = filter_->RenderToSnapshot(
31 renderer, // renderer
32 entity, // entity
33 coverage_limit, // coverage_limit
34 std::nullopt, // sampler_descriptor
35 true, // msaa_enabled
36 SPrintF("Filter to %s Filter Snapshot", label.c_str())); // label
37 }
38 return snapshot_;
39 }
40
41 std::optional<Rect> FilterContentsFilterInput::GetCoverage(
42 const Entity& entity) const {
43 return filter_->GetCoverage(entity);
44 }
45
46 std::optional<Rect> FilterContentsFilterInput::GetSourceCoverage(
47 const Matrix& effect_transform,
48 const Rect& output_limit) const {
49 return filter_->GetSourceCoverage(effect_transform, output_limit);
50 }
51
52 Matrix FilterContentsFilterInput::GetLocalTransform(
53 const Entity& entity) const {
54 return filter_->GetLocalTransform(entity.GetTransform());
55 }
56
57 Matrix FilterContentsFilterInput::GetTransform(const Entity& entity) const {
58 return filter_->GetTransform(entity.GetTransform());
59 }
60
61 void FilterContentsFilterInput::PopulateGlyphAtlas(
62 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
63 Scalar scale) {
64 filter_->PopulateGlyphAtlas(lazy_glyph_atlas, scale);
65 }
66
67 bool FilterContentsFilterInput::IsTranslationOnly() const {
68 return filter_->IsTranslationOnly();
69 }
70
71 bool FilterContentsFilterInput::IsLeaf() const {
72 return false;
73 }
74
75 void FilterContentsFilterInput::SetLeafInputs(
76 const FilterInput::Vector& inputs) {
77 filter_->SetLeafInputs(inputs);
78 }
79
80 void FilterContentsFilterInput::SetEffectTransform(const Matrix& matrix) {
81 filter_->SetEffectTransform(matrix);
82 }
83
84 void FilterContentsFilterInput::SetRenderingMode(
85 Entity::RenderingMode rendering_mode) {
86 filter_->SetRenderingMode(rendering_mode);
87 }
88
89 } // namespace impeller
impeller::FilterContentsFilterInput::IsLeaf
bool IsLeaf() const override
Returns true unless this input is a FilterInput, which may take other inputs.
Definition: filter_contents_filter_input.cc:71
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::Entity::GetTransform
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition: entity.cc:49
impeller::FilterContentsFilterInput::GetSourceCoverage
std::optional< Rect > GetSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const override
Definition: filter_contents_filter_input.cc:46
impeller::FilterContentsFilterInput::SetRenderingMode
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode) override
Turns on subpass mode for filter inputs.
Definition: filter_contents_filter_input.cc:84
impeller::FilterContentsFilterInput::GetTransform
Matrix GetTransform(const Entity &entity) const override
Get the transform of this FilterInput. This is equivalent to calling entity.GetTransform() * GetLocal...
Definition: filter_contents_filter_input.cc:57
impeller::FilterContentsFilterInput::GetInput
Variant GetInput() const override
Definition: filter_contents_filter_input.cc:20
impeller::Entity
Definition: entity.h:21
filter_contents.h
impeller::FilterContentsFilterInput::GetLocalTransform
Matrix GetLocalTransform(const Entity &entity) const override
Get the local transform of this filter input. This transform is relative to the Entity transform spac...
Definition: filter_contents_filter_input.cc:52
impeller::FilterContentsFilterInput::SetEffectTransform
virtual void SetEffectTransform(const Matrix &matrix) override
Sets the effect transform of filter inputs.
Definition: filter_contents_filter_input.cc:80
impeller::SPrintF
std::string SPrintF(const char *format,...)
Definition: strings.cc:12
impeller::FilterContentsFilterInput::IsTranslationOnly
bool IsTranslationOnly() const override
Definition: filter_contents_filter_input.cc:67
impeller::FilterInput::Variant
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:37
strings.h
filter_contents_filter_input.h
impeller::FilterContentsFilterInput::PopulateGlyphAtlas
void PopulateGlyphAtlas(const std::shared_ptr< LazyGlyphAtlas > &lazy_glyph_atlas, Scalar scale) override
Definition: filter_contents_filter_input.cc:61
impeller::FilterContentsFilterInput::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Definition: filter_contents_filter_input.cc:41
std
Definition: comparable.h:95
impeller::FilterContentsFilterInput::GetSnapshot
std::optional< Snapshot > GetSnapshot(const std::string &label, const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit) const override
Definition: filter_contents_filter_input.cc:24
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::FilterContentsFilterInput::~FilterContentsFilterInput
~FilterContentsFilterInput() override
impeller::ContentContext
Definition: content_context.h:332
impeller::TRect< Scalar >
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::FilterContentsFilterInput::SetLeafInputs
void SetLeafInputs(const FilterInput::Vector &inputs) override
Replaces the inputs of all leaf FilterContents with a new set of inputs.
Definition: filter_contents_filter_input.cc:75