Debian Codegraph @

src/gpu/ganesh/mtl/GrMtlDirectContext.mm

raw
1 /*
2 * Copyright 2024 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 #include "include/gpu/ganesh/mtl/GrMtlDirectContext.h"
8
9 #include "include/gpu/ganesh/GrDirectContext.h"
10 #include "include/gpu/ganesh/mtl/GrMtlBackendContext.h"
11 #include "src/gpu/ganesh/GrContextThreadSafeProxyPriv.h"
12 #include "src/gpu/ganesh/GrDirectContextPriv.h"
13 #include "src/gpu/ganesh/mtl/GrMtlTrampoline.h"
14
15 namespace GrDirectContexts {
16 sk_sp<GrDirectContext> MakeMetal(const GrMtlBackendContext& backendContext) {
17 GrContextOptions defaultOptions;
18 return MakeMetal(backendContext, defaultOptions);
19 }
20
21 sk_sp<GrDirectContext> MakeMetal(const GrMtlBackendContext& backendContext,
22 const GrContextOptions& options) {
23 sk_sp<GrDirectContext> direct = GrDirectContextPriv::Make(
24 GrBackendApi::kMetal,
25 options,
26 GrContextThreadSafeProxyPriv::Make(GrBackendApi::kMetal, options));
27
28 GrDirectContextPriv::SetGpu(direct,
29 GrMtlTrampoline::MakeGpu(backendContext, options, direct.get()));
30 if (!GrDirectContextPriv::Init(direct)) {
31 return nullptr;
32 }
33
34 return direct;
35 }
36 } // namespace GrDirectContexts