| Flutter Impeller |

snapshot.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/renderer/snapshot.h"
6
7 #include <optional>
8
9 namespace impeller {
10
11 std::optional<Rect> Snapshot::GetCoverage() const {
12 if (!texture) {
13 return std::nullopt;
14 }
15 return Rect::MakeSize(texture->GetSize()).TransformBounds(transform);
16 }
17
18 std::optional<Matrix> Snapshot::GetUVTransform() const {
19 if (!texture || texture->GetSize().IsEmpty()) {
20 return std::nullopt;
21 }
22 return Matrix::MakeScale(1 / Vector2(texture->GetSize())) *
23 transform.Invert();
24 }
25
26 std::optional<std::array<Point, 4>> Snapshot::GetCoverageUVs(
27 const Rect& coverage) const {
28 auto uv_transform = GetUVTransform();
29 if (!uv_transform.has_value()) {
30 return std::nullopt;
31 }
32 return coverage.GetTransformedPoints(uv_transform.value());
33 }
34
35 } // namespace impeller
impeller
Definition: allocation.cc:12
impeller::Vector2
Point Vector2
Definition: point.h:331
snapshot.h
impeller::Matrix::Invert
Matrix Invert() const
Definition: matrix.cc:99
impeller::Matrix::MakeScale
static constexpr Matrix MakeScale(const Vector3 &s)
Definition: matrix.h:104
impeller::Snapshot::transform
Matrix transform
The transform that should be applied to this texture for rendering.
Definition: snapshot.h:27
impeller::Snapshot::texture
std::shared_ptr< Texture > texture
Definition: snapshot.h:25
impeller::Snapshot::GetCoverageUVs
std::optional< std::array< Point, 4 > > GetCoverageUVs(const Rect &coverage) const
Map a coverage rect to this filter input's UV space. Result order: Top left, top right,...
Definition: snapshot.cc:26
impeller::Snapshot::GetCoverage
std::optional< Rect > GetCoverage() const
Definition: snapshot.cc:11
impeller::Snapshot::GetUVTransform
std::optional< Matrix > GetUVTransform() const
Get the transform that converts screen space coordinates to the UV space of this snapshot.
Definition: snapshot.cc:18
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:476
impeller::TRect::GetTransformedPoints
constexpr std::array< TPoint< T >, 4 > GetTransformedPoints(const Matrix &transform) const
Definition: rect.h:430
impeller::TRect< Scalar >::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:150