| Flutter Impeller |

Public Member Functions | Public Attributes | List of all members
impeller::Snapshot Struct Reference

Represents a texture and its intended draw transform/sampler configuration. More...

`#include <snapshot.h>`

## Public Member Functions
bool | ShouldRasterizeForRuntimeEffects () const
std::optional< Rect > | GetCoverage () const
std::optional< Matrix > | GetUVTransform () const
| Get the transform that converts screen space coordinates to the UV space of this snapshot. More...
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, bottom left, bottom right. More...

## Public Attributes
std::shared_ptr< Texture > | texture
Matrix | transform
| The transform that should be applied to this texture for rendering. More...
SamplerDescriptor | sampler_descriptor
Scalar | opacity = 1.0f
bool | needs_rasterization_for_runtime_effects = false
| Whether this snapshot needs to be re-rasterized when used as an input to a runtime effect. More...

## Detailed Description

Represents a texture and its intended draw transform/sampler configuration.

Definition at line 24 of file snapshot.h.

## Member Function Documentation

## ◆ GetCoverage()

std::optional< Rect > impeller::Snapshot::GetCoverage | ( |  | ) | const

Definition at line 11 of file snapshot.cc.

11 {
12 if (!texture) {
13 return std::nullopt;
14 }
15 return Rect::MakeSize(texture->GetSize()).TransformBounds(transform);
16 }
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::TRect::TransformBounds
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:472
impeller::TRect< Scalar >::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:150

References impeller::TRect< Scalar >::MakeSize(), texture, transform, and impeller::TRect< T >::TransformBounds().

## ◆ GetCoverageUVs()

std::optional< std::array< Point, 4 > > impeller::Snapshot::GetCoverageUVs | ( | const Rect & | coverage | ) | const

Map a coverage rect to this filter input's UV space. Result order: Top left, top right, bottom left, bottom right.

Definition at line 26 of file snapshot.cc.

27 {
28 auto uv_transform = GetUVTransform();
29 if (!uv_transform.has_value()) {
30 return std::nullopt;
31 }
32 return coverage.GetTransformedPoints(uv_transform.value());
33 }
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

References impeller::TRect< T >::GetTransformedPoints(), and GetUVTransform().

## ◆ GetUVTransform()

std::optional< Matrix > impeller::Snapshot::GetUVTransform | ( |  | ) | const

Get the transform that converts screen space coordinates to the UV space of this snapshot.

Definition at line 18 of file snapshot.cc.

18 {
19 if (!texture || texture->GetSize().IsEmpty()) {
20 return std::nullopt;
21 }
22 return Matrix::MakeScale(1 / Vector2(texture->GetSize())) *
23 transform.Invert();
24 }
impeller::Vector2
Point Vector2
Definition: point.h:331
impeller::Matrix::Invert
Matrix Invert() const
Definition: matrix.cc:99
impeller::Matrix::MakeScale
static constexpr Matrix MakeScale(const Vector3 &s)
Definition: matrix.h:104

References impeller::Matrix::Invert(), impeller::Matrix::MakeScale(), texture, and transform.

Referenced by GetCoverageUVs().

## ◆ ShouldRasterizeForRuntimeEffects()

bool impeller::Snapshot::ShouldRasterizeForRuntimeEffects | ( |  | ) | const
| inline

Any snapshot that is scaled should rerasterize because we should be performing the RuntimeEffect at the resolution of the screen, not the scaled up or scaled down version of the snapshot.

Definition at line 51 of file snapshot.h.

51 {
52 return !transform.IsTranslationOnly() ||
53 needs_rasterization_for_runtime_effects;
54 }
impeller::Matrix::IsTranslationOnly
constexpr bool IsTranslationOnly() const
Returns true if the matrix has no entries other than translation components. Note that an identity ma...
Definition: matrix.h:480
impeller::Snapshot::needs_rasterization_for_runtime_effects
bool needs_rasterization_for_runtime_effects
Whether this snapshot needs to be re-rasterized when used as an input to a runtime effect.
Definition: snapshot.h:46

References impeller::Matrix::IsTranslationOnly(), needs_rasterization_for_runtime_effects, and transform.

## Member Data Documentation

## ◆ needs_rasterization_for_runtime_effects

bool impeller::Snapshot::needs_rasterization_for_runtime_effects = false

Whether this snapshot needs to be re-rasterized when used as an input to a runtime effect.

This is required because there is no good heuristic to determine if a `Snapshot` needs to be rerasterized before applying a RuntimeFilter. In particular the GaussianBlurContents will return a Snapshot that includes padding for the blur halo which is not possible for the RuntimeEffectContents to know about. This value will tell RuntimeEffectContents that the Snapshot will have to be rerasterized to capture the padding.

Definition at line 46 of file snapshot.h.

Referenced by impeller::Entity::FromSnapshot(), and ShouldRasterizeForRuntimeEffects().

## ◆ opacity

Scalar impeller::Snapshot::opacity = 1.0f

Definition at line 35 of file snapshot.h.

Referenced by impeller::Entity::FromSnapshot().

## ◆ sampler_descriptor

SamplerDescriptor impeller::Snapshot::sampler_descriptor

Initial value:
=
SamplerDescriptor("Default Snapshot Sampler",
MinMagFilter::kLinear,
MinMagFilter::kLinear,
MipFilter::kNearest)
impeller::MipFilter::kNearest
@ kNearest
The nearst mipmap level is selected.
impeller::MinMagFilter::kLinear
@ kLinear

Definition at line 29 of file snapshot.h.

Referenced by impeller::Entity::FromSnapshot(), and impeller::Canvas::SaveLayer().

## ◆ texture

std::shared_ptr<Texture> impeller::Snapshot::texture

Definition at line 25 of file snapshot.h.

Referenced by impeller::AdvancedBlend(), impeller::Entity::FromSnapshot(), GetCoverage(), impeller::TextureFilterInput::GetSnapshot(), GetUVTransform(), impeller::PipelineBlend(), impeller::Contents::RenderToSnapshot(), impeller::TextureContents::RenderToSnapshot(), impeller::TiledTextureContents::RenderToSnapshot(), and impeller::Canvas::SaveLayer().

## ◆ transform

Matrix impeller::Snapshot::transform

The transform that should be applied to this texture for rendering.

Definition at line 27 of file snapshot.h.

Referenced by impeller::Entity::FromSnapshot(), GetCoverage(), GetUVTransform(), impeller::Canvas::SaveLayer(), and ShouldRasterizeForRuntimeEffects().

The documentation for this struct was generated from the following files:

- impeller/renderer/snapshot.h
- impeller/renderer/snapshot.cc