Add #[inline] attributes
This commit is contained in:
parent
3820d307a3
commit
aa9cb99929
23 changed files with 384 additions and 3 deletions
|
|
@ -71,6 +71,7 @@ enum Context {
|
|||
pub struct WindowWrapper(pub winapi::HWND, pub winapi::HDC);
|
||||
|
||||
impl Drop for WindowWrapper {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
user32::DestroyWindow(self.0);
|
||||
|
|
@ -84,6 +85,7 @@ pub struct WindowProxy {
|
|||
}
|
||||
|
||||
impl WindowProxy {
|
||||
#[inline]
|
||||
pub fn wakeup_event_loop(&self) {
|
||||
unsafe {
|
||||
user32::PostMessageA(self.hwnd, *WAKEUP_MSG_ID, 0, 0);
|
||||
|
|
@ -119,12 +121,14 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn show(&self) {
|
||||
unsafe {
|
||||
user32::ShowWindow(self.window.0, winapi::SW_SHOW);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn hide(&self) {
|
||||
unsafe {
|
||||
user32::ShowWindow(self.window.0, winapi::SW_HIDE);
|
||||
|
|
@ -158,6 +162,7 @@ impl Window {
|
|||
}
|
||||
|
||||
/// See the docs in the crate root file.
|
||||
#[inline]
|
||||
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
||||
|
||||
|
|
@ -172,6 +177,7 @@ impl Window {
|
|||
}
|
||||
|
||||
/// See the docs in the crate root file.
|
||||
#[inline]
|
||||
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
||||
|
||||
|
|
@ -196,11 +202,13 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||
WindowProxy { hwnd: self.window.0 }
|
||||
}
|
||||
|
||||
/// See the docs in the crate root file.
|
||||
#[inline]
|
||||
pub fn poll_events(&self) -> PollEventsIterator {
|
||||
PollEventsIterator {
|
||||
window: self,
|
||||
|
|
@ -208,12 +216,14 @@ impl Window {
|
|||
}
|
||||
|
||||
/// See the docs in the crate root file.
|
||||
#[inline]
|
||||
pub fn wait_events(&self) -> WaitEventsIterator {
|
||||
WaitEventsIterator {
|
||||
window: self,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||
// What should this return on win32?
|
||||
// It could be GetDC(NULL), but that requires a ReleaseDC()
|
||||
|
|
@ -221,13 +231,16 @@ impl Window {
|
|||
ptr::null_mut()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn platform_window(&self) -> *mut libc::c_void {
|
||||
self.window.0 as *mut libc::c_void
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_cursor(&self, _cursor: MouseCursor) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
|
@ -297,6 +310,7 @@ impl Window {
|
|||
res
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn hidpi_factor(&self) -> f32 {
|
||||
1.0
|
||||
}
|
||||
|
|
@ -322,6 +336,7 @@ impl Window {
|
|||
}
|
||||
|
||||
impl GlContext for Window {
|
||||
#[inline]
|
||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||
match self.context {
|
||||
Context::Wgl(ref c) => c.make_current(),
|
||||
|
|
@ -329,6 +344,7 @@ impl GlContext for Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_current(&self) -> bool {
|
||||
match self.context {
|
||||
Context::Wgl(ref c) => c.is_current(),
|
||||
|
|
@ -336,6 +352,7 @@ impl GlContext for Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
|
||||
match self.context {
|
||||
Context::Wgl(ref c) => c.get_proc_address(addr),
|
||||
|
|
@ -343,6 +360,7 @@ impl GlContext for Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||
match self.context {
|
||||
Context::Wgl(ref c) => c.swap_buffers(),
|
||||
|
|
@ -350,6 +368,7 @@ impl GlContext for Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_api(&self) -> Api {
|
||||
match self.context {
|
||||
Context::Wgl(ref c) => c.get_api(),
|
||||
|
|
@ -357,6 +376,7 @@ impl GlContext for Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_pixel_format(&self) -> PixelFormat {
|
||||
match self.context {
|
||||
Context::Wgl(ref c) => c.get_pixel_format(),
|
||||
|
|
@ -372,6 +392,7 @@ pub struct PollEventsIterator<'a> {
|
|||
impl<'a> Iterator for PollEventsIterator<'a> {
|
||||
type Item = Event;
|
||||
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<Event> {
|
||||
self.window.events_receiver.try_recv().ok()
|
||||
}
|
||||
|
|
@ -384,12 +405,14 @@ pub struct WaitEventsIterator<'a> {
|
|||
impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||
type Item = Event;
|
||||
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<Event> {
|
||||
self.window.events_receiver.recv().ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Window {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
// we don't call MakeCurrent(0, 0) because we are not sure that the context
|
||||
|
|
|
|||
|
|
@ -151,16 +151,19 @@ pub fn get_primary_monitor() -> MonitorID {
|
|||
|
||||
impl MonitorID {
|
||||
/// See the docs if the crate root file.
|
||||
#[inline]
|
||||
pub fn get_name(&self) -> Option<String> {
|
||||
Some(self.readable_name.clone())
|
||||
}
|
||||
|
||||
/// See the docs of the crate root file.
|
||||
#[inline]
|
||||
pub fn get_native_identifier(&self) -> NativeMonitorId {
|
||||
NativeMonitorId::Name(self.monitor_name.clone())
|
||||
}
|
||||
|
||||
/// See the docs if the crate root file.
|
||||
#[inline]
|
||||
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||
// TODO: retreive the dimensions every time this is called
|
||||
self.dimensions
|
||||
|
|
@ -168,6 +171,7 @@ impl MonitorID {
|
|||
|
||||
/// This is a Win32-only function for `MonitorID` that returns the system name of the adapter
|
||||
/// device.
|
||||
#[inline]
|
||||
pub fn get_adapter_name(&self) -> &[winapi::WCHAR] {
|
||||
&self.adapter_name
|
||||
}
|
||||
|
|
@ -175,6 +179,7 @@ impl MonitorID {
|
|||
/// This is a Win32-only function for `MonitorID` that returns the position of the
|
||||
/// monitor on the desktop.
|
||||
/// A window that is positionned at these coordinates will overlap the monitor.
|
||||
#[inline]
|
||||
pub fn get_position(&self) -> (u32, u32) {
|
||||
self.position
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue