Flutter Engine
The Flutter Engine
MtlSharedContext.h
Go to the documentation of this file.
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
12
14
17
18#import <Metal/Metal.h>
19
20namespace skgpu {
21class MtlMemoryAllocator;
22}
23
24namespace skgpu::graphite {
25struct ContextOptions;
26
27class MtlSharedContext final : public SharedContext {
28public:
30 ~MtlSharedContext() override;
31
32 skgpu::MtlMemoryAllocator* memoryAllocator() const { return fMemoryAllocator.get(); }
33
34 id<MTLDevice> device() const { return fDevice.get(); }
35
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
42private:
43
44 MtlSharedContext(sk_cfp<id<MTLDevice>>,
46 std::unique_ptr<const MtlCaps>);
47
48 sk_sp<skgpu::MtlMemoryAllocator> fMemoryAllocator;
49
50 sk_cfp<id<MTLDevice>> fDevice;
51};
52
53} // namespace skgpu::graphite
54
55#endif // skgpu_graphite_MtlSharedContext_DEFINED
T * get() const
Definition: SkRefCnt.h:303
std::unique_ptr< ResourceProvider > makeResourceProvider(SingleOwner *, uint32_t recorderID, size_t resourceBudget) override
skgpu::MtlMemoryAllocator * memoryAllocator() const
static sk_sp< SharedContext > Make(const MtlBackendContext &, const ContextOptions &)
const MtlCaps & mtlCaps() const
id< MTLDevice > device() const
const Caps * caps() const
Definition: SharedContext.h:39
Definition: GpuTools.h:21