aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/cocoa')
-rw-r--r--src/api/cocoa/headless.rs6
-rw-r--r--src/api/cocoa/mod.rs18
-rw-r--r--src/api/cocoa/monitor.rs2
3 files changed, 26 insertions, 0 deletions
diff --git a/src/api/cocoa/headless.rs b/src/api/cocoa/headless.rs
index f9bbffd..eb1a06f 100644
--- a/src/api/cocoa/headless.rs
+++ b/src/api/cocoa/headless.rs
@@ -85,10 +85,12 @@ impl GlContext for HeadlessContext {
Ok(())
}
+ #[inline]
fn is_current(&self) -> bool {
unimplemented!()
}
+ #[inline]
fn get_proc_address(&self, _addr: &str) -> *const libc::c_void {
let symbol_name: CFString = _addr.parse().unwrap();
let framework_name: CFString = "com.apple.opengl".parse().unwrap();
@@ -101,14 +103,17 @@ impl GlContext for HeadlessContext {
symbol as *const libc::c_void
}
+ #[inline]
fn swap_buffers(&self) -> Result<(), ContextError> {
Ok(())
}
+ #[inline]
fn get_api(&self) -> ::Api {
::Api::OpenGl
}
+ #[inline]
fn get_pixel_format(&self) -> PixelFormat {
unimplemented!();
}
@@ -118,6 +123,7 @@ unsafe impl Send for HeadlessContext {}
unsafe impl Sync for HeadlessContext {}
impl Drop for HeadlessContext {
+ #[inline]
fn drop(&mut self) {
unsafe {
gl::DeleteTextures(1, &texture);
diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs
index 539545c..9e9a001 100644
--- a/src/api/cocoa/mod.rs
+++ b/src/api/cocoa/mod.rs
@@ -568,10 +568,12 @@ impl Window {
}
}
+ #[inline]
pub fn show(&self) {
unsafe { NSWindow::makeKeyAndOrderFront_(*self.window, nil); }
}
+ #[inline]
pub fn hide(&self) {
unsafe { NSWindow::orderOut_(*self.window, nil); }
}
@@ -606,6 +608,7 @@ impl Window {
}
}
+ #[inline]
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
unsafe {
let view_frame = NSView::frame(*self.view);
@@ -613,6 +616,7 @@ impl Window {
}
}
+ #[inline]
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
unsafe {
let window_frame = NSWindow::frame(*self.window);
@@ -620,22 +624,26 @@ impl Window {
}
}
+ #[inline]
pub fn set_inner_size(&self, width: u32, height: u32) {
unsafe {
NSWindow::setContentSize_(*self.window, NSSize::new(width as f64, height as f64));
}
}
+ #[inline]
pub fn create_window_proxy(&self) -> WindowProxy {
WindowProxy
}
+ #[inline]
pub fn poll_events(&self) -> PollEventsIterator {
PollEventsIterator {
window: self
}
}
+ #[inline]
pub fn wait_events(&self) -> WaitEventsIterator {
WaitEventsIterator {
window: self
@@ -652,14 +660,17 @@ impl Window {
return None;
}
+ #[inline]
pub fn platform_display(&self) -> *mut libc::c_void {
unimplemented!()
}
+ #[inline]
pub fn platform_window(&self) -> *mut libc::c_void {
unimplemented!()
}
+ #[inline]
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
self.delegate.state.resize_handler = callback;
}
@@ -723,24 +734,28 @@ impl Window {
}
}
+ #[inline]
pub fn hidpi_factor(&self) -> f32 {
unsafe {
NSWindow::backingScaleFactor(*self.window) as f32
}
}
+ #[inline]
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
unimplemented!();
}
}
impl GlContext for Window {
+ #[inline]
unsafe fn make_current(&self) -> Result<(), ContextError> {
let _: () = msg_send![*self.context, update];
self.context.makeCurrentContext();
Ok(())
}
+ #[inline]
fn is_current(&self) -> bool {
unsafe {
let current = NSOpenGLContext::currentContext(nil);
@@ -765,15 +780,18 @@ impl GlContext for Window {
symbol as *const _
}
+ #[inline]
fn swap_buffers(&self) -> Result<(), ContextError> {
unsafe { self.context.flushBuffer(); }
Ok(())
}
+ #[inline]
fn get_api(&self) -> ::Api {
::Api::OpenGl
}
+ #[inline]
fn get_pixel_format(&self) -> PixelFormat {
self.pixel_format.clone()
}
diff --git a/src/api/cocoa/monitor.rs b/src/api/cocoa/monitor.rs
index 138bbcd..600f7e9 100644
--- a/src/api/cocoa/monitor.rs
+++ b/src/api/cocoa/monitor.rs
@@ -21,6 +21,7 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
monitors
}
+#[inline]
pub fn get_primary_monitor() -> MonitorID {
let id = unsafe {
MonitorID(display::CGMainDisplayID())
@@ -37,6 +38,7 @@ impl MonitorID {
Some(format!("Monitor #{}", screen_num))
}
+ #[inline]
pub fn get_native_identifier(&self) -> NativeMonitorId {
let MonitorID(display_id) = *self;
NativeMonitorId::Numeric(display_id)