| 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 #pragma once
6
7 #include <unordered_map>
8
9 #include "flutter/fml/macros.h"
10 #include "impeller/base/comparable.h"
11 #include "impeller/core/formats.h"
12
13 namespace impeller {
14
15 class Sampler;
16 class Context;
17
18 struct SamplerDescriptor final : public Comparable<SamplerDescriptor> {
19 MinMagFilter min_filter = MinMagFilter::kNearest;
20 MinMagFilter mag_filter = MinMagFilter::kNearest;
21 MipFilter mip_filter = MipFilter::kNearest;
22
23 SamplerAddressMode width_address_mode = SamplerAddressMode::kClampToEdge;
24 SamplerAddressMode height_address_mode = SamplerAddressMode::kClampToEdge;
25 SamplerAddressMode depth_address_mode = SamplerAddressMode::kClampToEdge;
26
27 std::string label = "NN Clamp Sampler";
28
29 SamplerDescriptor();
30
31 SamplerDescriptor(std::string label,
32 MinMagFilter min_filter,
33 MinMagFilter mag_filter,
34 MipFilter mip_filter);
35
36 // Comparable<SamplerDescriptor>
37 std::size_t GetHash() const override {
38 return fml::HashCombine(min_filter, mag_filter, mip_filter,
39 width_address_mode, height_address_mode,
40 depth_address_mode);
41 }
42
43 // Comparable<SamplerDescriptor>
44 bool IsEqual(const SamplerDescriptor& o) const override {
45 return min_filter == o.min_filter && mag_filter == o.mag_filter &&
46 mip_filter == o.mip_filter &&
47 width_address_mode == o.width_address_mode &&
48 height_address_mode == o.height_address_mode &&
49 depth_address_mode == o.depth_address_mode;
50 }
51 };
52
53 using SamplerMap = std::unordered_map<SamplerDescriptor,
54 std::shared_ptr<const Sampler>,
55 ComparableHash<SamplerDescriptor>,
56 ComparableEqual<SamplerDescriptor>>;
57
58 } // namespace impeller
impeller::SamplerAddressMode
SamplerAddressMode
Definition: formats.h:377
formats.h
impeller::SamplerAddressMode::kClampToEdge
@ kClampToEdge
impeller::SamplerDescriptor::GetHash
std::size_t GetHash() const override
Definition: sampler_descriptor.h:37
impeller::MinMagFilter::kNearest
@ kNearest
Select nearest to the sample point. Most widely supported.
impeller::SamplerDescriptor::mag_filter
MinMagFilter mag_filter
Definition: sampler_descriptor.h:20
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:18
impeller::MipFilter::kNearest
@ kNearest
Sample from the nearest mip level.
impeller::SamplerDescriptor::min_filter
MinMagFilter min_filter
Definition: sampler_descriptor.h:19
impeller::MipFilter
MipFilter
Definition: formats.h:369
impeller::SamplerMap
std::unordered_map< SamplerDescriptor, std::shared_ptr< const Sampler >, ComparableHash< SamplerDescriptor >, ComparableEqual< SamplerDescriptor > > SamplerMap
Definition: sampler_descriptor.h:56
impeller::SamplerDescriptor::width_address_mode
SamplerAddressMode width_address_mode
Definition: sampler_descriptor.h:23
impeller::MinMagFilter
MinMagFilter
Definition: formats.h:361
impeller::SamplerDescriptor::depth_address_mode
SamplerAddressMode depth_address_mode
Definition: sampler_descriptor.h:25
impeller::ComparableEqual
Definition: comparable.h:51
impeller::SamplerDescriptor::mip_filter
MipFilter mip_filter
Definition: sampler_descriptor.h:21
impeller::Comparable
Definition: comparable.h:32
comparable.h
impeller::SamplerDescriptor::label
std::string label
Definition: sampler_descriptor.h:27
impeller::SamplerDescriptor::SamplerDescriptor
SamplerDescriptor()
impeller::SamplerDescriptor::height_address_mode
SamplerAddressMode height_address_mode
Definition: sampler_descriptor.h:24
impeller
Definition: aiks_context.cc:10
impeller::SamplerDescriptor::IsEqual
bool IsEqual(const SamplerDescriptor &o) const override
Definition: sampler_descriptor.h:44