diff --git a/cidre/pomace/sc/sc.h b/cidre/pomace/sc/sc.h index ead70120..f663535c 100644 --- a/cidre/pomace/sc/sc.h +++ b/cidre/pomace/sc/sc.h @@ -21,11 +21,15 @@ static void mtl_initializer(void) { static int initialized = 0; if (!initialized) { - SC_STREAM_CONFIGURATION = [SCStreamConfiguration class]; - SC_CONTENT_FILTER = [SCContentFilter class]; - SC_STREAM = [SCStream class]; - SC_SHAREABLE_CONTENT = [SCShareableContent class]; - + if (@available(macOS 12.3, *)) { + SC_STREAM_CONFIGURATION = [SCStreamConfiguration class]; + SC_CONTENT_FILTER = [SCContentFilter class]; + SC_STREAM = [SCStream class]; + SC_SHAREABLE_CONTENT = [SCShareableContent class]; + } else { + // Fallback on earlier versions + } + initialized = 1; } } diff --git a/cidre/src/ca.rs b/cidre/src/ca.rs index b2a93484..75b64a99 100644 --- a/cidre/src/ca.rs +++ b/cidre/src/ca.rs @@ -36,3 +36,7 @@ pub use layer::Layer; mod metal_layer; pub use metal_layer::MetalDrawable; pub use metal_layer::MetalLayer; + +mod renderer; +pub use renderer::OptionKey as RendererOptionKey; +pub use renderer::Renderer; diff --git a/cidre/src/ca/renderer.rs b/cidre/src/ca/renderer.rs index 5c8434b6..5f40478f 100644 --- a/cidre/src/ca/renderer.rs +++ b/cidre/src/ca/renderer.rs @@ -1,20 +1,33 @@ use crate::{arc, cf, cv, define_cls, define_obj_type, ns, objc}; -define_obj_type!(Renderer(ns::Id)); +define_obj_type!(OptionKey(ns::String)); + +impl OptionKey { + #[inline] + pub fn color_space() -> &'static Self { + unsafe { kCARendererColorSpace } + } + + #[inline] + pub fn metal_cmd_queue() -> &'static Self { + unsafe { kCARendererMetalCommandQueue } + } +} +define_obj_type!(Renderer(ns::Id)); impl Renderer { define_cls!(CA_RENDERER); #[objc::cls_msg_send(rendererWithMTLTexture:options:)] pub fn with_mtl_texture_ar( texture: &mtl::Texture, - options: Option<&ns::Dictionary>, + options: Option<&ns::Dictionary>, ) -> &'ar Self; #[objc::rar_retain] pub fn with_mtl_texture( texture: &mtl::Texture, - options: Option<&ns::Dictionary>, + options: Option<&ns::Dictionary>, ) -> arc::R; #[objc::msg_send(layer)] @@ -56,3 +69,8 @@ impl Renderer { extern "C" { static CA_RENDERER: &'static objc::Class; } + +extern "C" { + static kCARendererColorSpace: &'static OptionKey; + static kCARendererMetalCommandQueue: &'static OptionKey; +}