| 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,
29 int32_t mip_count) const {
30 if (!snapshot_.has_value()) {
31 snapshot_ = filter_->RenderToSnapshot(
32 renderer, // renderer
33 entity, // entity
34 coverage_limit, // coverage_limit
35 std::nullopt, // sampler_descriptor
36 true, // msaa_enabled
37 /*mip_count=*/mip_count,
38 SPrintF("Filter to %s Filter Snapshot", label.c_str())); // label
39 }
40 return snapshot_;
41 }
42
43 std::optional<Rect> FilterContentsFilterInput::GetCoverage(
44 const Entity& entity) const {
45 return filter_->GetCoverage(entity);
46 }
47
48 std::optional<Rect> FilterContentsFilterInput::GetSourceCoverage(
49 const Matrix& effect_transform,
50 const Rect& output_limit) const {
51 return filter_->GetSourceCoverage(effect_transform, output_limit);
52 }
53
54 Matrix FilterContentsFilterInput::GetLocalTransform(
55 const Entity& entity) const {
56 return filter_->GetLocalTransform(entity.GetTransform());
57 }
58
59 Matrix FilterContentsFilterInput::GetTransform(const Entity& entity) const {
60 return filter_->GetTransform(entity.GetTransform());
61 }
62
63 bool FilterContentsFilterInput::IsTranslationOnly() const {
64 return filter_->IsTranslationOnly();
65 }
66
67 bool FilterContentsFilterInput::IsLeaf() const {
68 return false;
69 }
70
71 void FilterContentsFilterInput::SetLeafInputs(
72 const FilterInput::Vector& inputs) {
73 filter_->SetLeafInputs(inputs);
74 }
75
76 void FilterContentsFilterInput::SetEffectTransform(const Matrix& matrix) {
77 filter_->SetEffectTransform(matrix);
78 }
79
80 void FilterContentsFilterInput::SetRenderingMode(
81 Entity::RenderingMode rendering_mode) {
82 filter_->SetRenderingMode(rendering_mode);
83 }
84
85 } // 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:67
impeller::Entity::GetTransform
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition: entity.cc:47
impeller::FilterContentsFilterInput::GetSourceCoverage
std::optional< Rect > GetSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const override
Definition: filter_contents_filter_input.cc:48
impeller::FilterContentsFilterInput::GetSnapshot
std::optional< Snapshot > GetSnapshot(const std::string &label, const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit, int32_t mip_count) const override
Definition: filter_contents_filter_input.cc:24
impeller::FilterContentsFilterInput::SetRenderingMode
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode) override
Turns on subpass mode for filter inputs.
Definition: filter_contents_filter_input.cc:80
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:59
impeller::FilterContentsFilterInput::GetInput
Variant GetInput() const override
Definition: filter_contents_filter_input.cc:20
impeller::Entity
Definition: entity.h:20
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:54
impeller::FilterContentsFilterInput::SetEffectTransform
virtual void SetEffectTransform(const Matrix &matrix) override
Sets the effect transform of filter inputs.
Definition: filter_contents_filter_input.cc:76
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: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
strings.h
filter_contents_filter_input.h
impeller::FilterContentsFilterInput::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Definition: filter_contents_filter_input.cc:43
std
Definition: comparable.h:95
impeller::Entity::RenderingMode
RenderingMode
Definition: entity.h:27
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
impeller
Definition: allocation.cc:12
impeller::FilterContentsFilterInput::~FilterContentsFilterInput
~FilterContentsFilterInput() override
impeller::ContentContext
Definition: content_context.h:366
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:71