skia_safe/gpu/ganesh/mtl/
direct_context.rs

1pub mod direct_contexts {
2
3    use skia_bindings as sb;
4
5    use crate::{
6        gpu::{mtl, ContextOptions, DirectContext},
7        prelude::*,
8    };
9
10    /// Makes a [`DirectContext`] which uses Metal as the backend. The [`mtl::BackendContext`] contains a
11    /// MTLDevice and MTLCommandQueue which should be used by the backend. These objects must
12    /// have their own ref which will be released when the [`mtl::BackendContext`] is destroyed.
13    /// Ganesh will take its own ref on the objects which will be released when the [`DirectContext`]
14    /// is destroyed.
15    pub fn make_metal<'a>(
16        backend: &mtl::BackendContext,
17        options: impl Into<Option<&'a ContextOptions>>,
18    ) -> Option<DirectContext> {
19        DirectContext::from_ptr(unsafe {
20            sb::C_GrContext_MakeMetal(backend.native(), options.into().native_ptr_or_null())
21        })
22    }
23}