Debian Codegraph @

third_party/rust/metal/src/capturedescriptor.rs

raw
1 // Copyright 2020 GFX developers
2 //
3 // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4 // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5 // http://opensource.org/licenses/MIT>, at your option. This file may not be
6 // copied, modified, or distributed except according to those terms.
7
8 use super::*;
9
10 use std::path::Path;
11
12 /// See <https://developer.apple.com/documentation/metal/mtlcapturedestination?language=objc>
13 #[repr(u64)]
14 #[allow(non_camel_case_types)]
15 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
16 pub enum MTLCaptureDestination {
17 DeveloperTools = 1,
18 GpuTraceDocument = 2,
19 }
20
21 /// See <https://developer.apple.com/documentation/metal/mtlcapturedescriptor>
22 pub enum MTLCaptureDescriptor {}
23
24 foreign_obj_type! {
25 type CType = MTLCaptureDescriptor;
26 pub struct CaptureDescriptor;
27 }
28
29 impl CaptureDescriptor {
30 pub fn new() -> Self {
31 unsafe {
32 let class = class!(MTLCaptureDescriptor);
33 msg_send![class, new]
34 }
35 }
36 }
37
38 impl CaptureDescriptorRef {
39 /// See <https://developer.apple.com/documentation/metal/mtlcapturedescriptor/3237248-captureobject>
40 pub fn set_capture_device(&self, device: &DeviceRef) {
41 unsafe { msg_send![self, setCaptureObject: device] }
42 }
43
44 /// See <https://developer.apple.com/documentation/metal/mtlcapturedescriptor/3237248-captureobject>
45 pub fn set_capture_scope(&self, scope: &CaptureScopeRef) {
46 unsafe { msg_send![self, setCaptureObject: scope] }
47 }
48
49 /// See <https://developer.apple.com/documentation/metal/mtlcapturedescriptor/3237248-captureobject>
50 pub fn set_capture_command_queue(&self, command_queue: &CommandQueueRef) {
51 unsafe { msg_send![self, setCaptureObject: command_queue] }
52 }
53
54 /// See <https://developer.apple.com/documentation/metal/mtlcapturedescriptor/3237250-outputurl>
55 pub fn output_url(&self) -> &Path {
56 let url: &URLRef = unsafe { msg_send![self, outputURL] };
57 Path::new(url.path())
58 }
59
60 /// See <https://developer.apple.com/documentation/metal/mtlcapturedescriptor/3237250-outputurl>
61 pub fn set_output_url<P: AsRef<Path>>(&self, output_url: P) {
62 let output_url_string = String::from("file://") + output_url.as_ref().to_str().unwrap();
63 let output_url = URL::new_with_string(&output_url_string);
64 unsafe { msg_send![self, setOutputURL: output_url] }
65 }
66
67 /// See <https://developer.apple.com/documentation/metal/mtlcapturedescriptor?language=objc>
68 pub fn destination(&self) -> MTLCaptureDestination {
69 unsafe { msg_send![self, destination] }
70 }
71
72 /// See <https://developer.apple.com/documentation/metal/mtlcapturedescriptor?language=objc>
73 pub fn set_destination(&self, destination: MTLCaptureDestination) {
74 unsafe { msg_send![self, setDestination: destination] }
75 }
76 }