Debian Codegraph @

example/external_client/src/graphite_metal_context_helper.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
8 #import "graphite_metal_context_helper.h"
9
10 #import "include/ports/SkCFObject.h"
11
12 #import <Metal/Metal.h>
13
14 skgpu::graphite::MtlBackendContext GetMetalContext() {
15 skgpu::graphite::MtlBackendContext backendContext = {};
16 sk_cfp<id<MTLDevice>> device;
17 device.reset(MTLCreateSystemDefaultDevice());
18
19 sk_cfp<id<MTLCommandQueue>> queue;
20 queue.reset([*device newCommandQueue]);
21
22 backendContext.fDevice.retain((CFTypeRef)device.get());
23 backendContext.fQueue.retain((CFTypeRef)queue.get());
24 return backendContext;
25 }