| Flutter Impeller |

texture_filter_input.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/inputs/texture_filter_input.h"
6
7 #include <utility>
8
9 #include "impeller/core/formats.h"
10
11 namespace impeller {
12
13 TextureFilterInput::TextureFilterInput(std::shared_ptr<Texture> texture,
14 Matrix local_transform)
15 : texture_(std::move(texture)), local_transform_(local_transform) {}
16
17 TextureFilterInput::~TextureFilterInput() = default;
18
19 FilterInput::Variant TextureFilterInput::GetInput() const {
20 return texture_;
21 }
22
23 std::optional<Snapshot> TextureFilterInput::GetSnapshot(
24 const std::string& label,
25 const ContentContext& renderer,
26 const Entity& entity,
27 std::optional<Rect> coverage_limit,
28 int32_t mip_count) const {
29 auto snapshot =
30 Snapshot{.texture = texture_, .transform = GetTransform(entity)};
31 if (texture_->GetMipCount() > 1) {
32 snapshot.sampler_descriptor.label = "TextureFilterInput Trilinear Sampler";
33 snapshot.sampler_descriptor.mip_filter = MipFilter::kLinear;
34 }
35 return snapshot;
36 }
37
38 std::optional<Rect> TextureFilterInput::GetCoverage(
39 const Entity& entity) const {
40 return Rect::MakeSize(texture_->GetSize())
41 .TransformBounds(GetTransform(entity));
42 }
43
44 Matrix TextureFilterInput::GetLocalTransform(const Entity& entity) const {
45 return local_transform_;
46 }
47
48 } // namespace impeller
texture_filter_input.h
impeller::TextureFilterInput::GetLocalTransform
Matrix GetLocalTransform(const Entity &entity) const override
Get the local transform of this filter input. This transform is relative to the Entity transform spac...
Definition: texture_filter_input.cc:44
impeller::TRect::TransformBounds
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:466
formats.h
impeller::TextureFilterInput::GetInput
Variant GetInput() const override
Definition: texture_filter_input.cc:19
impeller::TextureFilterInput::GetSnapshot
std::optional< Snapshot > GetSnapshot(const std::string &label, const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit, int32_t mip_count) const override
Definition: texture_filter_input.cc:23
impeller::FilterInput::GetTransform
virtual Matrix GetTransform(const Entity &entity) const
Get the transform of this FilterInput. This is equivalent to calling entity.GetTransform() * GetLocal...
Definition: filter_input.cc:75
impeller::Entity
Definition: entity.h:20
impeller::Snapshot
Represents a texture and its intended draw transform/sampler configuration.
Definition: snapshot.h:24
impeller::TextureFilterInput::~TextureFilterInput
~TextureFilterInput() override
impeller::FilterInput::Variant
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:37
impeller::TRect< Scalar >::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:150
std
Definition: comparable.h:95
impeller::MipFilter::kLinear
@ kLinear
Sample from the two nearest mip levels and linearly interpolate.
impeller::TextureFilterInput::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Definition: texture_filter_input.cc:38
impeller::Snapshot::texture
std::shared_ptr< Texture > texture
Definition: snapshot.h:25
impeller
Definition: allocation.cc:12
impeller::ContentContext
Definition: content_context.h:366
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37