| 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 Matrix FilterContentsFilterInput::GetLocalTransform(
47 const Entity& entity) const {
48 return filter_->GetLocalTransform(entity.GetTransformation());
49 }
50
51 Matrix FilterContentsFilterInput::GetTransform(const Entity& entity) const {
52 return filter_->GetTransform(entity.GetTransformation());
53 }
54
55 void FilterContentsFilterInput::PopulateGlyphAtlas(
56 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
57 Scalar scale) {
58 filter_->PopulateGlyphAtlas(lazy_glyph_atlas, scale);
59 }
60
61 bool FilterContentsFilterInput::IsTranslationOnly() const {
62 return filter_->IsTranslationOnly();
63 }
64
65 bool FilterContentsFilterInput::IsLeaf() const {
66 return false;
67 }
68
69 void FilterContentsFilterInput::SetLeafInputs(
70 const FilterInput::Vector& inputs) {
71 filter_->SetLeafInputs(inputs);
72 }
73
74 void FilterContentsFilterInput::SetEffectTransform(const Matrix& matrix) {
75 filter_->SetEffectTransform(matrix);
76 }
77
78 void FilterContentsFilterInput::SetRenderingMode(
79 Entity::RenderingMode rendering_mode) {
80 filter_->SetRenderingMode(rendering_mode);
81 }
82
83 } // 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:65
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::FilterContentsFilterInput::SetRenderingMode
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode) override
Turns on subpass mode for filter inputs.
Definition: filter_contents_filter_input.cc:78
impeller::FilterContentsFilterInput::GetTransform
Matrix GetTransform(const Entity &entity) const override
Get the transform of this FilterInput. This is equivalent to calling entity.GetTransformation() * Get...
Definition: filter_contents_filter_input.cc:51
impeller::Entity::GetTransformation
const Matrix & GetTransformation() const
Definition: entity.cc:49
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:46
impeller::FilterContentsFilterInput::SetEffectTransform
virtual void SetEffectTransform(const Matrix &matrix) override
Sets the effect transform of filter inputs.
Definition: filter_contents_filter_input.cc:74
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:61
impeller::FilterInput::Variant
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:36
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:55
impeller::FilterContentsFilterInput::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Definition: filter_contents_filter_input.cc:41
std
Definition: comparable.h:98
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:32
impeller
Definition: aiks_context.cc:10
impeller::FilterContentsFilterInput::~FilterContentsFilterInput
~FilterContentsFilterInput() override
impeller::ContentContext
Definition: content_context.h:344
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:36
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:69