12
12
13
13
extern crate libc;
14
14
extern crate core_foundation;
15
+ extern crate core_foundation_sys;
15
16
extern crate cgl;
16
17
extern crate leaky_cow;
17
18
@@ -20,6 +21,7 @@ extern crate leaky_cow;
20
21
use core_foundation:: base:: { CFRelease , CFRetain , CFTypeID , CFTypeRef , CFType , TCFType } ;
21
22
use core_foundation:: dictionary:: { CFDictionary , CFDictionaryRef } ;
22
23
use core_foundation:: string:: { CFString , CFStringRef } ;
24
+ use core_foundation_sys:: base:: mach_port_t;
23
25
use cgl:: { kCGLNoError, CGLGetCurrentContext , CGLTexImageIOSurface2D , CGLErrorString , GLenum } ;
24
26
use libc:: { c_int, size_t} ;
25
27
use std:: os:: raw:: c_void;
@@ -33,8 +35,12 @@ const RGB: GLenum = 0x1907;
33
35
const TEXTURE_RECTANGLE_ARB : GLenum = 0x84F5 ;
34
36
const UNSIGNED_INT_8_8_8_8_REV : GLenum = 0x8367 ;
35
37
36
- //static kIOSurfaceLockReadOnly: u32 = 0x1;
37
- //static kIOSurfaceLockAvoidSync: u32 = 0x2;
38
+ #[ allow( non_snake_case) ]
39
+ pub mod IOSurfaceLockOptions {
40
+ #![ allow( non_upper_case_globals) ]
41
+ pub const kIOSurfaceLockReadOnly: u32 = 0x00000001 ;
42
+ pub const kIOSurfaceLockAvoidSync: u32 = 0x00000002 ;
43
+ }
38
44
39
45
type IOReturn = c_int ;
40
46
@@ -143,7 +149,7 @@ impl IOSurface {
143
149
let error_msg = error_msg. to_string_lossy ( ) ;
144
150
// This will only actually leak memory if error_msg is a `Cow::Owned`, which
145
151
// will only happen if the platform gives us invalid unicode.
146
- panic ! ( error_msg. leak( ) ) ;
152
+ panic ! ( "{}" , error_msg. leak( ) ) ;
147
153
}
148
154
}
149
155
}
@@ -195,16 +201,47 @@ extern {
195
201
pub static kIOSurfaceIsGlobal: CFStringRef ;
196
202
pub static kIOSurfacePixelFormat: CFStringRef ;
197
203
198
- fn IOSurfaceCreate ( properties : CFDictionaryRef ) -> IOSurfaceRef ;
199
- fn IOSurfaceLookup ( csid : IOSurfaceID ) -> IOSurfaceRef ;
200
- fn IOSurfaceGetID ( buffer : IOSurfaceRef ) -> IOSurfaceID ;
201
-
202
- fn IOSurfaceGetTypeID ( ) -> CFTypeID ;
203
-
204
- fn IOSurfaceLock ( buffer : IOSurfaceRef , options : u32 , seed : * mut u32 ) -> IOReturn ;
205
- fn IOSurfaceUnlock ( buffer : IOSurfaceRef , options : u32 , seed : * mut u32 ) -> IOReturn ;
206
-
207
- fn IOSurfaceGetHeight ( buffer : IOSurfaceRef ) -> size_t ;
208
- fn IOSurfaceGetBytesPerRow ( buffer : IOSurfaceRef ) -> size_t ;
209
- fn IOSurfaceGetBaseAddress ( buffer : IOSurfaceRef ) -> * mut c_void ;
204
+ pub fn IOSurfaceCreate ( properties : CFDictionaryRef ) -> IOSurfaceRef ;
205
+ pub fn IOSurfaceLookup ( csid : IOSurfaceID ) -> IOSurfaceRef ;
206
+ pub fn IOSurfaceGetID ( buffer : IOSurfaceRef ) -> IOSurfaceID ;
207
+
208
+ pub fn IOSurfaceGetTypeID ( ) -> CFTypeID ;
209
+
210
+ pub fn IOSurfaceLock ( buffer : IOSurfaceRef , options : u32 , seed : * mut u32 ) -> IOReturn ;
211
+ pub fn IOSurfaceUnlock ( buffer : IOSurfaceRef , options : u32 , seed : * mut u32 ) -> IOReturn ;
212
+ pub fn IOSurfaceGetSeed ( buffer : IOSurfaceRef ) -> u32 ;
213
+
214
+ pub fn IOSurfaceGetHeight ( buffer : IOSurfaceRef ) -> size_t ;
215
+ pub fn IOSurfaceGetWidth ( buffer : IOSurfaceRef ) -> usize ;
216
+ pub fn IOSurfaceGetBytesPerRow ( buffer : IOSurfaceRef ) -> size_t ;
217
+ pub fn IOSurfaceGetBaseAddress ( buffer : IOSurfaceRef ) -> * mut c_void ;
218
+ pub fn IOSurfaceGetElementHeight ( buffer : IOSurfaceRef ) -> usize ;
219
+ pub fn IOSurfaceGetElementWidth ( buffer : IOSurfaceRef ) -> usize ;
220
+ pub fn IOSurfaceGetBytesPerElement ( buffer : IOSurfaceRef ) -> usize ;
221
+ pub fn IOSurfaceGetAllocSize ( buffer : IOSurfaceRef ) -> usize ;
222
+
223
+ pub fn IOSurfaceGetPixelFormat ( buffer : IOSurfaceRef ) -> i32 ;
224
+
225
+ pub fn IOSurfaceGetUseCount ( buffer : IOSurfaceRef ) -> i32 ;
226
+ pub fn IOSurfaceIncrementUseCount ( buffer : IOSurfaceRef ) ;
227
+ pub fn IOSurfaceDecrementUseCount ( buffer : IOSurfaceRef ) ;
228
+ pub fn IOSurfaceIsInUse ( buffer : IOSurfaceRef ) -> bool ;
229
+
230
+ pub fn IOSurfaceCreateMachPort ( buffer : IOSurfaceRef ) -> mach_port_t ;
231
+ pub fn IOSurfaceLookupFromMachPort ( port : mach_port_t ) -> IOSurfaceRef ;
232
+
233
+ pub fn IOSurfaceGetPropertyAlignment ( property : CFStringRef ) -> usize ;
234
+ pub fn IOSurfaceGetPropertyMaximum ( property : CFStringRef ) -> usize ;
235
+
236
+ pub fn IOSurfaceCopyValue ( buffer : IOSurfaceRef , key : CFStringRef ) -> CFTypeRef ;
237
+ pub fn IOSurfaceRemoveValue ( buffer : IOSurfaceRef , key : CFStringRef ) ;
238
+ pub fn IOSurfaceSetValue ( buffer : IOSurfaceRef , key : CFStringRef , value : CFTypeRef ) ;
239
+
240
+ pub fn IOSurfaceGetBaseAddressOfPlane ( buffer : IOSurfaceRef , plane_index : usize ) -> * mut c_void ;
241
+ pub fn IOSurfaceGetBytesPerElementOfPlane ( buffer : IOSurfaceRef , plane_index : usize ) -> usize ;
242
+ pub fn IOSurfaceGetBytesPerRowOfPlane ( buffer : IOSurfaceRef , plane_index : usize ) -> usize ;
243
+ pub fn IOSurfaceGetElementHeightOfPlane ( buffer : IOSurfaceRef , plane_index : usize ) -> usize ;
244
+ pub fn IOSurfaceGetElementWidthOfPlane ( buffer : IOSurfaceRef , plane_index : usize ) -> usize ;
245
+ pub fn IOSurfaceGetHeightOfPlane ( buffer : IOSurfaceRef , plane_index : usize ) -> usize ;
246
+ pub fn IOSurfaceGetWidthOfPlane ( buffer : IOSurfaceRef , plane_index : usize ) -> usize ;
210
247
}
0 commit comments