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 
6 
7 namespace impeller {
8 
10 
12 
14  matrix_ = matrix;
15 }
16 
18  const Matrix& parent_transform) const {
19  return matrix_;
20 }
21 
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
BlendMode GetBlendMode() const
Definition: entity.cc:101
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
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
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...
Matrix GetLocalTransform(const Matrix &parent_transform) const override
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
constexpr Matrix Basis() const
The Matrix without its w components (without translation).
Definition: matrix.h:239
Matrix Invert() const
Definition: matrix.cc:97
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:476