• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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_MtlSharedContext_DEFINED
9 #define skgpu_graphite_MtlSharedContext_DEFINED
10 
11 #include "src/gpu/graphite/SharedContext.h"
12 
13 #include "include/ports/SkCFObject.h"
14 
15 #include "include/gpu/graphite/mtl/MtlBackendContext.h"
16 #include "src/gpu/graphite/mtl/MtlCaps.h"
17 
18 #import <Metal/Metal.h>
19 
20 namespace skgpu {
21 class MtlMemoryAllocator;
22 }
23 
24 namespace skgpu::graphite {
25 struct ContextOptions;
26 
27 class MtlSharedContext final : public SharedContext {
28 public:
29     static sk_sp<SharedContext> Make(const MtlBackendContext&, const ContextOptions&);
30     ~MtlSharedContext() override;
31 
memoryAllocator()32     skgpu::MtlMemoryAllocator* memoryAllocator() const { return fMemoryAllocator.get(); }
33 
device()34     id<MTLDevice> device() const { return fDevice.get(); }
35 
mtlCaps()36     const MtlCaps& mtlCaps() const { return static_cast<const MtlCaps&>(*this->caps()); }
37 
38     std::unique_ptr<ResourceProvider> makeResourceProvider(SingleOwner*,
39                                                            uint32_t recorderID,
40                                                            size_t resourceBudget) override;
41 
42 private:
43 
44     MtlSharedContext(sk_cfp<id<MTLDevice>>,
45                      sk_sp<skgpu::MtlMemoryAllocator> memoryAllocator,
46                      std::unique_ptr<const MtlCaps>,
47                      SkSpan<sk_sp<SkRuntimeEffect>> userDefinedKnownRuntimeEffects);
48 
49     sk_sp<skgpu::MtlMemoryAllocator> fMemoryAllocator;
50 
51     sk_cfp<id<MTLDevice>> fDevice;
52 };
53 
54 } // namespace skgpu::graphite
55 
56 #endif // skgpu_graphite_MtlSharedContext_DEFINED
57