1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2016 GFX developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use super::*;
use cocoa::foundation::NSRange;
pub enum MTLBuffer {}
foreign_obj_type! {
type CType = MTLBuffer;
pub struct Buffer;
pub struct BufferRef;
type ParentType = ResourceRef;
}
impl BufferRef {
pub fn length(&self) -> u64 {
unsafe {
msg_send![self, length]
}
}
pub fn contents(&self) -> *mut libc::c_void {
unsafe {
msg_send![self, contents]
}
}
pub fn did_modify_range(&self, range: NSRange) {
unsafe {
msg_send![self, didModifyRange:range]
}
}
pub fn new_texture_from_contents(&self, descriptor: &TextureDescriptorRef, offset: u64, stride: u64) -> Texture {
unsafe {
msg_send![self,
newTextureWithDescriptor:descriptor
offset:offset
bytesPerRow:stride
]
}
}
}