xref: /aosp_15_r20/external/skia/src/gpu/graphite/mtl/MtlSampler.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef skgpu_graphite_MtlSampler_DEFINED
9 #define skgpu_graphite_MtlSampler_DEFINED
10 
11 #include "src/gpu/graphite/Sampler.h"
12 
13 #include "include/core/SkRefCnt.h"
14 #include "include/core/SkTileMode.h"
15 #include "include/ports/SkCFObject.h"
16 
17 #import <Metal/Metal.h>
18 
19 struct SkSamplingOptions;
20 
21 namespace skgpu::graphite {
22 
23 class MtlSharedContext;
24 
25 class MtlSampler : public Sampler {
26 public:
27     static sk_sp<MtlSampler> Make(const MtlSharedContext*,
28                                   const SkSamplingOptions& samplingOptions,
29                                   SkTileMode xTileMode,
30                                   SkTileMode yTileMode);
31 
~MtlSampler()32     ~MtlSampler() override {}
33 
mtlSamplerState()34     id<MTLSamplerState> mtlSamplerState() const { return fSamplerState.get(); }
35 
36 private:
37     MtlSampler(const MtlSharedContext* sharedContext,
38                sk_cfp<id<MTLSamplerState>>);
39 
40     void freeGpuData() override;
41 
42     sk_cfp<id<MTLSamplerState>> fSamplerState;
43 };
44 
45 } // namepsace skgpu::graphite
46 
47 #endif // skgpu_graphite_MtlSampler_DEFINED
48