Flutter Engine
The Flutter Engine
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
6
7#include <memory>
8#include <utility>
9
10#include "flutter/fml/logging.h"
16
17namespace impeller {
18
19FilterInput::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>(
39 }
40
42}
43
45 Matrix local_transform) {
46 return std::shared_ptr<TextureFilterInput>(
47 new TextureFilterInput(std::move(texture), local_transform));
48}
49
50FilterInput::Vector FilterInput::Make(std::initializer_list<Variant> inputs) {
52 result.reserve(inputs.size());
53 for (const auto& input : inputs) {
54 result.push_back(Make(input));
55 }
56 return result;
57}
58
60 return Matrix();
61}
62
63std::optional<Rect> FilterInput::GetLocalCoverage(const Entity& entity) const {
64 Entity local_entity = entity.Clone();
65 local_entity.SetTransform(GetLocalTransform(entity));
66 return GetCoverage(local_entity);
67}
68
70 const Matrix& effect_transform,
71 const Rect& output_limit) const {
72 return output_limit;
73}
74
76 return entity.GetTransform() * GetLocalTransform(entity);
77}
78
80 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
81 Scalar scale) {}
82
84
86 return true;
87}
88
89bool FilterInput::IsLeaf() const {
90 return true;
91}
92
94
96
98
99} // namespace impeller
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
Definition: entity.cc:62
Entity Clone() const
Definition: entity.cc:191
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition: entity.cc:46
virtual std::optional< Rect > GetSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const
Definition: filter_input.cc:69
virtual void SetEffectTransform(const Matrix &matrix)
Sets the effect transform of filter inputs.
Definition: filter_input.cc:95
std::shared_ptr< FilterInput > Ref
Definition: filter_input.h:32
virtual bool IsLeaf() const
Returns true unless this input is a FilterInput, which may take other inputs.
Definition: filter_input.cc:89
virtual Matrix GetTransform(const Entity &entity) const
Get the transform of this FilterInput. This is equivalent to calling entity.GetTransform() * GetLocal...
Definition: filter_input.cc:75
virtual void PopulateGlyphAtlas(const std::shared_ptr< LazyGlyphAtlas > &lazy_glyph_atlas, Scalar scale)
Definition: filter_input.cc:79
std::optional< Rect > GetLocalCoverage(const Entity &entity) const
Definition: filter_input.cc:63
virtual std::optional< Rect > GetCoverage(const Entity &entity) const =0
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:37
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
Definition: filter_input.cc:19
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
virtual void SetLeafInputs(const FilterInput::Vector &inputs)
Replaces the inputs of all leaf FilterContents with a new set of inputs.
Definition: filter_input.cc:93
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
virtual bool IsTranslationOnly() const
Definition: filter_input.cc:85
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode)
Turns on subpass mode for filter inputs.
Definition: filter_input.cc:97
GAsyncResult * result
#define FML_UNREACHABLE()
Definition: logging.h:109
FlTexture * texture
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
float Scalar
Definition: scalar.h:18
SK_API sk_sp< PrecompileColorFilter > Matrix()
const Scalar scale
A 4x4 matrix using column-major storage.
Definition: matrix.h:37