| Flutter Impeller |

sampler_descriptor.h
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 #ifndef FLUTTER_IMPELLER_CORE_SAMPLER_DESCRIPTOR_H_
6 #define FLUTTER_IMPELLER_CORE_SAMPLER_DESCRIPTOR_H_
7
8 #include "impeller/core/formats.h"
9
10 namespace impeller {
11
12 class Context;
13
14 struct SamplerDescriptor final {
15 MinMagFilter min_filter = MinMagFilter::kNearest;
16 MinMagFilter mag_filter = MinMagFilter::kNearest;
17 MipFilter mip_filter = MipFilter::kNearest;
18
19 SamplerAddressMode width_address_mode = SamplerAddressMode::kClampToEdge;
20 SamplerAddressMode height_address_mode = SamplerAddressMode::kClampToEdge;
21 SamplerAddressMode depth_address_mode = SamplerAddressMode::kClampToEdge;
22
23 std::string_view label = "NN Clamp Sampler";
24
25 SamplerDescriptor();
26
27 SamplerDescriptor(std::string_view label,
28 MinMagFilter min_filter,
29 MinMagFilter mag_filter,
30 MipFilter mip_filter);
31
32 static uint64_t ToKey(const SamplerDescriptor& d) {
33 static_assert(sizeof(MinMagFilter) == 1);
34 static_assert(sizeof(MipFilter) == 1);
35 static_assert(sizeof(SamplerAddressMode) == 1);
36
37 return static_cast<uint64_t>(d.min_filter) << 0 |
38 static_cast<uint64_t>(d.mag_filter) << 8 |
39 static_cast<uint64_t>(d.mip_filter) << 16 |
40 static_cast<uint64_t>(d.width_address_mode) << 24 |
41 static_cast<uint64_t>(d.height_address_mode) << 32 |
42 static_cast<uint64_t>(d.depth_address_mode) << 40;
43 }
44 };
45
46 } // namespace impeller
47
48 #endif // FLUTTER_IMPELLER_CORE_SAMPLER_DESCRIPTOR_H_
formats.h
impeller
Definition: allocation.cc:12
impeller::SamplerAddressMode
SamplerAddressMode
Definition: formats.h:441
impeller::SamplerAddressMode::kClampToEdge
@ kClampToEdge
impeller::MipFilter
MipFilter
Options for selecting and filtering between mipmap levels.
Definition: formats.h:425
impeller::MipFilter::kNearest
@ kNearest
The nearst mipmap level is selected.
impeller::MinMagFilter
MinMagFilter
Describes how the texture should be sampled when the texture is being shrunk (minified) or expanded (...
Definition: formats.h:415
impeller::MinMagFilter::kNearest
@ kNearest
Select nearest to the sample point. Most widely supported.
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:14
impeller::SamplerDescriptor::depth_address_mode
SamplerAddressMode depth_address_mode
Definition: sampler_descriptor.h:21
impeller::SamplerDescriptor::mip_filter
MipFilter mip_filter
Definition: sampler_descriptor.h:17
impeller::SamplerDescriptor::width_address_mode
SamplerAddressMode width_address_mode
Definition: sampler_descriptor.h:19
impeller::SamplerDescriptor::height_address_mode
SamplerAddressMode height_address_mode
Definition: sampler_descriptor.h:20
impeller::SamplerDescriptor::mag_filter
MinMagFilter mag_filter
Definition: sampler_descriptor.h:16
impeller::SamplerDescriptor::SamplerDescriptor
SamplerDescriptor()
impeller::SamplerDescriptor::label
std::string_view label
Definition: sampler_descriptor.h:23
impeller::SamplerDescriptor::ToKey
static uint64_t ToKey(const SamplerDescriptor &d)
Definition: sampler_descriptor.h:32
impeller::SamplerDescriptor::min_filter
MinMagFilter min_filter
Definition: sampler_descriptor.h:15