From 020ec6de33e3a1f507782ffd3fbebd48ddffbe80 Mon Sep 17 00:00:00 2001 From: ComfyFluffy <24245520+ComfyFluffy@users.noreply.github.com> Date: Fri, 1 Dec 2023 22:28:37 +0800 Subject: [PATCH] add `colorspace` to `MetalLayer` --- Cargo.toml | 13 +++++++++---- src/lib.rs | 9 +++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7e6900e..c800ae6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,13 @@ readme = "README.md" keywords = ["metal", "graphics", "bindings"] license = "MIT OR Apache-2.0" edition = "2021" -exclude = ["guide/**/*", "examples/texture/**/*", "tests/**/*", "Cargo.lock", "target/**/*"] +exclude = [ + "guide/**/*", + "examples/texture/**/*", + "tests/**/*", + "Cargo.lock", + "target/**/*", +] [package.metadata.docs.rs] default-target = "x86_64-apple-darwin" @@ -29,6 +35,7 @@ block = "0.1.6" foreign-types = "0.5" dispatch = { version = "0.2", optional = true } paste = "1" +core-graphics = "0.23.1" [dependencies.objc] version = "0.2.4" @@ -98,6 +105,4 @@ required-features = ["dispatch"] name = "fence" [workspace] -members = [ - "examples/texture", -] +members = ["examples/texture"] diff --git a/src/lib.rs b/src/lib.rs index b79acf6..4de7163 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,6 +28,7 @@ use std::{ os::raw::c_void, }; +use core_graphics::color_space::CGColorSpaceRef; use core_graphics_types::{base::CGFloat, geometry::CGSize}; use foreign_types::ForeignType; use objc::runtime::{Object, NO, YES}; @@ -544,6 +545,14 @@ impl MetalLayerRef { ] } } + + pub fn colorspace(&self) -> Option<&CGColorSpaceRef> { + unsafe { msg_send![self, colorspace] } + } + + pub fn set_colorspace(&self, colorspace: Option<&CGColorSpaceRef>) { + unsafe { msg_send![self, setColorspace: colorspace] } + } } mod accelerator_structure;