Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
6
7#include <utility>
8
10
11namespace impeller {
12
13TextureFilterInput::TextureFilterInput(std::shared_ptr<Texture> texture,
14 Matrix local_transform)
15 : texture_(std::move(texture)), local_transform_(local_transform) {}
16
17TextureFilterInput::~TextureFilterInput() = default;
18
19FilterInput::Variant TextureFilterInput::GetInput() const {
20 return texture_;
21}
22
23std::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
38std::optional<Rect> TextureFilterInput::GetCoverage(
39 const Entity& entity) const {
40 return Rect::MakeSize(texture_->GetSize())
41 .TransformBounds(GetTransform(entity));
42}
43
44Matrix TextureFilterInput::GetLocalTransform(const Entity& entity) const {
45 return local_transform_;
46}
47
48} // namespace impeller
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
FlTexture * texture
Definition ref_ptr.h:256
A 4x4 matrix using column-major storage.
Definition matrix.h:37
Represents a texture and its intended draw transform/sampler configuration.
Definition snapshot.h:24
std::shared_ptr< Texture > texture
Definition snapshot.h:25