50 {
51 sk_cfp<MTLSamplerDescriptor*>
desc([[MTLSamplerDescriptor alloc]
init]);
52
53 MTLSamplerMinMagFilter minMagFilter = [&] {
54 switch (samplingOptions.
filter) {
57 }
59 }();
60
61 MTLSamplerMipFilter mipFilter = [&] {
62 switch (samplingOptions.
mipmap) {
66 }
68 }();
69
70 (*desc).rAddressMode = MTLSamplerAddressModeClampToEdge;
73 (*desc).magFilter = minMagFilter;
74 (*desc).minFilter = minMagFilter;
75 (*desc).mipFilter = mipFilter;
76 (*desc).lodMinClamp = 0.0f;
77 (*desc).lodMaxClamp = FLT_MAX;
78 (*desc).maxAnisotropy = 1;
79 (*desc).normalizedCoordinates = true;
80 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
81 (*desc).compareFunction = MTLCompareFunctionNever;
82 }
83#ifdef SK_ENABLE_MTL_DEBUG_INFO
84 NSString* tileModeLabels[] = {
85 @"Clamp",
86 @"Repeat",
87 @"Mirror",
88 @"Decal"
89 };
90 NSString* minMagFilterLabels[] = {
91 @"Nearest",
92 @"Linear"
93 };
94 NSString* mipFilterLabels[] = {
95 @"MipNone",
96 @"MipNearest",
97 @"MipLinear"
98 };
99
100 (*desc).label = [NSString stringWithFormat:@"X%@Y%@%@%@",
101 tileModeLabels[(
int)xTileMode],
102 tileModeLabels[(int)yTileMode],
103 minMagFilterLabels[(
int)samplingOptions.
filter],
104 mipFilterLabels[(
int)samplingOptions.
mipmap]];
105#endif
106
107 sk_cfp<id<MTLSamplerState>> sampler(
109 if (!sampler) {
110 return nullptr;
111 }
113}
const SharedContext * sharedContext() const
static MTLSamplerAddressMode tile_mode_to_mtl_sampler_address(SkTileMode tileMode, const Caps &caps)
const SkFilterMode filter
const SkMipmapMode mipmap