100 lines
2.6 KiB
Plaintext
100 lines
2.6 KiB
Plaintext
#[link(name = "io_surface",
|
|
vers = "0.1")];
|
|
#[crate_type = "lib"];
|
|
|
|
extern mod core_foundation;
|
|
extern mod std;
|
|
|
|
// Rust bindings to the IOSurface framework on Mac OS X.
|
|
|
|
use cf = core_foundation;
|
|
use cf::base::{
|
|
AbstractCFTypeRef,
|
|
CFType,
|
|
CFTypeID,
|
|
CFTypeRef,
|
|
CFWrapper,
|
|
};
|
|
use cf::dictionary::{CFDictionary, CFDictionaryRef, UntypedCFDictionary};
|
|
use cf::number::CFNumber;
|
|
use cf::string::{CFString, CFStringRef};
|
|
|
|
struct __IOSurface { private: () }
|
|
pub type IOSurfaceRef = *__IOSurface;
|
|
|
|
impl AbstractCFTypeRef for IOSurfaceRef {
|
|
pure fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef }
|
|
|
|
static pure fn type_id() -> CFTypeID {
|
|
unsafe {
|
|
IOSurfaceGetTypeID()
|
|
}
|
|
}
|
|
}
|
|
|
|
pub type IOSurface = CFWrapper<IOSurfaceRef, (), ()>;
|
|
|
|
pub type IOSurfaceID = u32;
|
|
|
|
pub trait IOSurfaceMethods {
|
|
fn get_id(&self) -> IOSurfaceID;
|
|
}
|
|
|
|
pub fn new(properties: &UntypedCFDictionary) -> IOSurface {
|
|
unsafe {
|
|
let result = IOSurfaceCreate(*properties.borrow_ref());
|
|
CFWrapper::wrap_owned(result)
|
|
}
|
|
}
|
|
|
|
pub fn lookup(csid: IOSurfaceID) -> IOSurface {
|
|
unsafe {
|
|
let result = IOSurfaceLookup(csid);
|
|
CFWrapper::wrap_owned(result)
|
|
}
|
|
}
|
|
|
|
pub impl IOSurfaceMethods for IOSurface {
|
|
fn get_id(&self) -> IOSurfaceID {
|
|
unsafe {
|
|
IOSurfaceGetID(self.obj)
|
|
}
|
|
}
|
|
}
|
|
|
|
#[link_args="-framework IOSurface"]
|
|
#[nolink]
|
|
extern {
|
|
const kIOSurfaceAllocSize: CFStringRef;
|
|
const kIOSurfaceWidth: CFStringRef;
|
|
const kIOSurfaceHeight: CFStringRef;
|
|
const kIOSurfaceBytesPerRow: CFStringRef;
|
|
const kIOSurfaceBytesPerElement: CFStringRef;
|
|
const kIOSurfaceElementWidth: CFStringRef;
|
|
const kIOSurfaceElementHeight: CFStringRef;
|
|
const kIOSurfaceOffset: CFStringRef;
|
|
|
|
const kIOSurfacePlaneInfo: CFStringRef;
|
|
const kIOSurfacePlaneWidth: CFStringRef;
|
|
const kIOSurfacePlaneHeight: CFStringRef;
|
|
const kIOSurfacePlaneBytesPerRow: CFStringRef;
|
|
const kIOSurfacePlaneOffset: CFStringRef;
|
|
const kIOSurfacePlaneSize: CFStringRef;
|
|
|
|
const kIOSurfacePlaneBase: CFStringRef;
|
|
const kIOSurfacePlaneBytesPerElement: CFStringRef;
|
|
const kIOSurfacePlaneElementWidth: CFStringRef;
|
|
const kIOSurfacePlaneElementHeight: CFStringRef;
|
|
|
|
const kIOSurfaceCacheMode: CFStringRef;
|
|
const kIOSurfaceIsGlobal: CFStringRef;
|
|
const kIOSurfacePixelFormat: CFStringRef;
|
|
|
|
fn IOSurfaceCreate(properties: CFDictionaryRef) -> IOSurfaceRef;
|
|
fn IOSurfaceLookup(csid: IOSurfaceID) -> IOSurfaceRef;
|
|
fn IOSurfaceGetID(buffer: IOSurfaceRef) -> IOSurfaceID;
|
|
|
|
fn IOSurfaceGetTypeID() -> CFTypeID;
|
|
}
|
|
|