1use super::Handle;
2use crate::prelude::{self, NativeDrop};
3use skia_bindings::{self as sb, GrMtlBackendContext};
4use std::fmt;
5
6pub type BackendContext = prelude::Handle<GrMtlBackendContext>;
7unsafe_send_sync!(BackendContext);
8
9impl NativeDrop for GrMtlBackendContext {
10 fn drop(&mut self) {
11 unsafe { sb::C_GrMtlBackendContext_Destruct(self) }
12 }
13}
14
15impl fmt::Debug for BackendContext {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 f.debug_struct(name:"BackendContext").finish()
18 }
19}
20
21impl BackendContext {
22 /// # Safety
23 ///
24 /// Unsafe because it expects various objects in form of `c_void` pointers.
25 ///
26 /// This function retains all the non-`null` handles passed to it and releases them as soon the
27 /// [BackendContext] is dropped.
28 pub unsafe fn new(device: Handle, queue: Handle, binary_archive: Handle) -> Self {
29 BackendContext::construct(|bc: *mut {unknown}| {
30 sb::C_GrMtlBackendContext_Construct(bc, device, queue, binary_archive)
31 })
32 }
33}
34