| 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.IsInvertible()) {
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 std::optional<Snapshot> snapshot =
41 inputs[0]->GetSnapshot("LocalMatrix", renderer, entity);
42 if (!snapshot.has_value()) {
43 return std::nullopt;
44 }
45 return Entity::FromSnapshot(snapshot.value(), entity.GetBlendMode());
46 }
47
48 } // namespace impeller
impeller::ContentContext
Definition: content_context.h:122
impeller::Entity
Definition: entity.h:26
impeller::Entity::GetBlendMode
BlendMode GetBlendMode() const
Definition: entity.cc:102
impeller::Entity::FromSnapshot
static Entity FromSnapshot(const Snapshot &snapshot, BlendMode blend_mode=BlendMode::kSrcOver)
Create an entity that can be used to render a given snapshot.
Definition: entity.cc:18
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
impeller::LocalMatrixFilterContents::~LocalMatrixFilterContents
~LocalMatrixFilterContents() override
impeller::LocalMatrixFilterContents::SetMatrix
void SetMatrix(Matrix matrix)
Definition: local_matrix_filter_contents.cc:13
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::LocalMatrixFilterContents::LocalMatrixFilterContents
LocalMatrixFilterContents()
local_matrix_filter_contents.h
impeller
Definition: allocation.cc:12
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::Matrix::Basis
constexpr Matrix Basis() const
The Matrix without its w components (without translation).
Definition: matrix.h:239
impeller::Matrix::Invert
Matrix Invert() const
Definition: matrix.cc:99
impeller::TRect< Scalar >
impeller::TRect::TransformBounds
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:472