Debian Codegraph @

third_party/rust/metal/src/drawable.rs

raw
1 // Copyright 2016 GFX developers
2 //
3 // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4 // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5 // http://opensource.org/licenses/MIT>, at your option. This file may not be
6 // copied, modified, or distributed except according to those terms.
7
8 use block::Block;
9
10 use super::NSUInteger;
11
12 type DrawablePresentedHandler<'a> = Block<(&'a DrawableRef,), ()>;
13 type CFTimeInterval = f64;
14
15 /// See <https://developer.apple.com/documentation/metal/mtldrawable>
16 pub enum MTLDrawable {}
17
18 foreign_obj_type! {
19 type CType = MTLDrawable;
20 pub struct Drawable;
21 }
22
23 impl DrawableRef {
24 pub fn present(&self) {
25 unsafe { msg_send![self, present] }
26 }
27
28 pub fn drawable_id(&self) -> NSUInteger {
29 unsafe { msg_send![self, drawableID] }
30 }
31
32 pub fn add_presented_handler(&self, block: &DrawablePresentedHandler) {
33 unsafe { msg_send![self, addPresentedHandler: block] }
34 }
35
36 pub fn presented_time(&self) -> CFTimeInterval {
37 unsafe { msg_send![self, presentedTime] }
38 }
39 }