Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Friends | List of all members
impeller::SamplerLibraryMTL Class Referencefinal

#include <sampler_library_mtl.h>

Inheritance diagram for impeller::SamplerLibraryMTL:
impeller::SamplerLibrary impeller::BackendCast< SamplerLibraryMTL, SamplerLibrary >

Public Member Functions

 ~SamplerLibraryMTL () override
 
- Public Member Functions inherited from impeller::SamplerLibrary
virtual ~SamplerLibrary ()
 

Private Member Functions

const std::unique_ptr< const Sampler > & GetSampler (SamplerDescriptor descriptor) override
 Retrieve a backend specific sampler object for the given sampler descriptor.
 

Friends

class ContextMTL
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::BackendCast< SamplerLibraryMTL, SamplerLibrary >
static SamplerLibraryMTLCast (SamplerLibrary &base)
 
static const SamplerLibraryMTLCast (const SamplerLibrary &base)
 
static SamplerLibraryMTLCast (SamplerLibrary *base)
 
static const SamplerLibraryMTLCast (const SamplerLibrary *base)
 
- Protected Member Functions inherited from impeller::SamplerLibrary
 SamplerLibrary ()
 

Detailed Description

Definition at line 20 of file sampler_library_mtl.h.

Constructor & Destructor Documentation

◆ ~SamplerLibraryMTL()

impeller::SamplerLibraryMTL::~SamplerLibraryMTL ( )
overridedefault

Member Function Documentation

◆ GetSampler()

const std::unique_ptr< const Sampler > & impeller::SamplerLibraryMTL::GetSampler ( SamplerDescriptor  descriptor)
overrideprivatevirtual

Retrieve a backend specific sampler object for the given sampler descriptor.

If the descriptor is invalid or there is a loss of rendering context, this method may return a nullptr.

The sampler library implementations must cache this sampler object and guarantee that the reference will continue to be valid throughout the lifetime of the Impeller context.

Implements impeller::SamplerLibrary.

Definition at line 18 of file sampler_library_mtl.mm.

19 {
20 auto found = samplers_.find(descriptor);
21 if (found != samplers_.end()) {
22 return found->second;
23 }
24 if (!device_) {
25 return kNullSampler;
26 }
27 auto desc = [[MTLSamplerDescriptor alloc] init];
28 desc.minFilter = ToMTLSamplerMinMagFilter(descriptor.min_filter);
29 desc.magFilter = ToMTLSamplerMinMagFilter(descriptor.mag_filter);
30 desc.mipFilter = ToMTLSamplerMipFilter(descriptor.mip_filter);
31 desc.sAddressMode = ToMTLSamplerAddressMode(descriptor.width_address_mode);
32 desc.tAddressMode = ToMTLSamplerAddressMode(descriptor.height_address_mode);
33 desc.rAddressMode = ToMTLSamplerAddressMode(descriptor.depth_address_mode);
34 if (@available(iOS 14.0, macos 10.12, *)) {
35 desc.borderColor = MTLSamplerBorderColorTransparentBlack;
36 }
37 if (!descriptor.label.empty()) {
38 desc.label = @(descriptor.label.c_str());
39 }
40
41 auto mtl_sampler = [device_ newSamplerStateWithDescriptor:desc];
42 if (!mtl_sampler) {
43 return kNullSampler;
44 }
45 auto sampler =
46 std::unique_ptr<SamplerMTL>(new SamplerMTL(descriptor, mtl_sampler));
47
48 return (samplers_[descriptor] = std::move(sampler));
49}
constexpr MTLSamplerMipFilter ToMTLSamplerMipFilter(MipFilter filter)
constexpr MTLSamplerAddressMode ToMTLSamplerAddressMode(SamplerAddressMode mode)
constexpr MTLSamplerMinMagFilter ToMTLSamplerMinMagFilter(MinMagFilter filter)
static const std::unique_ptr< const Sampler > kNullSampler
init(device_serial, adb_binary)
Definition _adb_path.py:12

Friends And Related Symbol Documentation

◆ ContextMTL

friend class ContextMTL
friend

Definition at line 28 of file sampler_library_mtl.h.


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