| Flutter Impeller |

local_matrix_filter_contents.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/local_matrix_filter_contents.h"
6
7 namespace impeller {
8
9 LocalMatrixFilterContents::LocalMatrixFilterContents() = default;
10
11 LocalMatrixFilterContents::~LocalMatrixFilterContents() = default;
12
13 void LocalMatrixFilterContents::SetMatrix(Matrix matrix) {
14 matrix_ = matrix;
15 }
16
17 Matrix LocalMatrixFilterContents::GetLocalTransform(
18 const Matrix& parent_transform) const {
19 return matrix_;
20 }
21
22 std::optional<Rect> LocalMatrixFilterContents::GetFilterSourceCoverage(
23 const Matrix& effect_transform,
24 const Rect& output_limit) const {
25 auto matrix = matrix_.Basis();
26 if (matrix.GetDeterminant() == 0.0) {
27 return std::nullopt;
28 }
29 auto inverse = matrix.Invert();
30 return output_limit.TransformBounds(inverse);
31 }
32
33 std::optional<Entity> LocalMatrixFilterContents::RenderFilter(
34 const FilterInput::Vector& inputs,
35 const ContentContext& renderer,
36 const Entity& entity,
37 const Matrix& effect_transform,
38 const Rect& coverage,
39 const std::optional<Rect>& coverage_hint) const {
40 return Entity::FromSnapshot(
41 inputs[0]->GetSnapshot("LocalMatrix", renderer, entity),
42 entity.GetBlendMode(), entity.GetClipDepth());
43 }
44
45 } // namespace impeller
impeller::TRect::TransformBounds
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:264
impeller::LocalMatrixFilterContents::LocalMatrixFilterContents
LocalMatrixFilterContents()
local_matrix_filter_contents.h
impeller::Entity
Definition: entity.h:21
impeller::Matrix::Basis
constexpr Matrix Basis() const
The Matrix without its w components (without translation).
Definition: matrix.h:224
impeller::LocalMatrixFilterContents::GetFilterSourceCoverage
std::optional< Rect > GetFilterSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const override
Internal utility method for |GetSourceCoverage| that computes the inverse effect of this transform on...
Definition: local_matrix_filter_contents.cc:22
impeller::LocalMatrixFilterContents::GetLocalTransform
Matrix GetLocalTransform(const Matrix &parent_transform) const override
Definition: local_matrix_filter_contents.cc:17
impeller::Entity::GetBlendMode
BlendMode GetBlendMode() const
Definition: entity.cc:105
impeller::Matrix::Invert
Matrix Invert() const
Definition: matrix.cc:97
impeller::LocalMatrixFilterContents::SetMatrix
void SetMatrix(Matrix matrix)
Definition: local_matrix_filter_contents.cc:13
impeller::Entity::GetClipDepth
uint32_t GetClipDepth() const
Definition: entity.cc:93
impeller::LocalMatrixFilterContents::~LocalMatrixFilterContents
~LocalMatrixFilterContents() override
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
impeller::Entity::FromSnapshot
static std::optional< Entity > FromSnapshot(const std::optional< Snapshot > &snapshot, BlendMode blend_mode=BlendMode::kSourceOver, uint32_t clip_depth=0)
Create an entity that can be used to render a given snapshot.
Definition: entity.cc:21
impeller
Definition: aiks_context.cc:10
impeller::ContentContext
Definition: content_context.h:332
impeller::TRect< Scalar >
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37