| 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 void FilterContentsFilterInput::PopulateGlyphAtlas(
64 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
65 Scalar scale) {
66 filter_->PopulateGlyphAtlas(lazy_glyph_atlas, scale);
67 }
68
69 bool FilterContentsFilterInput::IsTranslationOnly() const {
70 return filter_->IsTranslationOnly();
71 }
72
73 bool FilterContentsFilterInput::IsLeaf() const {
74 return false;
75 }
76
77 void FilterContentsFilterInput::SetLeafInputs(
78 const FilterInput::Vector& inputs) {
79 filter_->SetLeafInputs(inputs);
80 }
81
82 void FilterContentsFilterInput::SetEffectTransform(const Matrix& matrix) {
83 filter_->SetEffectTransform(matrix);
84 }
85
86 void FilterContentsFilterInput::SetRenderingMode(
87 Entity::RenderingMode rendering_mode) {
88 filter_->SetRenderingMode(rendering_mode);
89 }
90
91 } // 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:73
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: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:86
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: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:54
impeller::FilterContentsFilterInput::SetEffectTransform
virtual void SetEffectTransform(const Matrix &matrix) override
Sets the effect transform of filter inputs.
Definition: filter_contents_filter_input.cc:82
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:69
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:63
impeller::FilterContentsFilterInput::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Definition: filter_contents_filter_input.cc:43
std
Definition: comparable.h:95
scale
const Scalar scale
Definition: stroke_path_geometry.cc:297
impeller::Entity::RenderingMode
RenderingMode
Definition: entity.h:28
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
impeller
Definition: aiks_blur_unittests.cc:20
impeller::FilterContentsFilterInput::~FilterContentsFilterInput
~FilterContentsFilterInput() override
impeller::ContentContext
Definition: content_context.h:392
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:77