Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DeviceRef::new_texture_with_descriptor_and_iosurface #331

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ block = "0.1.6"
foreign-types = "0.5"
dispatch = { version = "0.2", optional = true }
paste = "1"
io-surface = { git = "https://github.com/servo/core-foundation-rs" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not that this is a rather confusing dependency. Ideally, it matches the crate name


[dependencies.objc]
version = "0.2.4"
Expand Down
21 changes: 21 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,14 @@ impl Device {
}

impl DeviceRef {
pub fn architecture_name(&self) -> &str {
unsafe {
let arch: *const NSObject = msg_send![self, architecture];
let name = msg_send![arch, name];
crate::nsstring_as_str(name)
}
}

pub fn name(&self) -> &str {
unsafe {
let name = msg_send![self, name];
Expand Down Expand Up @@ -1985,6 +1993,19 @@ impl DeviceRef {
unsafe { msg_send![self, newTextureWithDescriptor: descriptor] }
}

pub fn new_texture_with_descriptor_and_iosurface(
&self,
descriptor: &TextureDescriptorRef,
iosurface: io_surface::IOSurfaceRef,
plane: NSUInteger,
) -> Texture {
unsafe {
msg_send![self, newTextureWithDescriptor:descriptor
iosurface:iosurface
plane:plane]
}
}

pub fn new_sampler(&self, descriptor: &SamplerDescriptorRef) -> SamplerState {
unsafe { msg_send![self, newSamplerStateWithDescriptor: descriptor] }
}
Expand Down