Add #[inline] attributes

This commit is contained in:
Pierre Krieger 2015-09-21 14:42:05 +02:00
parent 3820d307a3
commit aa9cb99929
23 changed files with 384 additions and 3 deletions

View file

@ -10,32 +10,39 @@ pub struct HeadlessContext(Window);
impl HeadlessContext {
/// See the docs in the crate root file.
#[inline]
pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
Window::new(builder).map(|w| HeadlessContext(w))
}
}
impl GlContext for HeadlessContext {
#[inline]
unsafe fn make_current(&self) -> Result<(), ContextError> {
self.0.make_current()
}
#[inline]
fn is_current(&self) -> bool {
self.0.is_current()
}
#[inline]
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
self.0.get_proc_address(addr)
}
#[inline]
fn swap_buffers(&self) -> Result<(), ContextError> {
self.0.swap_buffers()
}
#[inline]
fn get_api(&self) -> Api {
self.0.get_api()
}
#[inline]
fn get_pixel_format(&self) -> PixelFormat {
self.0.get_pixel_format()
}

View file

@ -59,6 +59,7 @@ pub enum WindowProxy {
}
impl WindowProxy {
#[inline]
pub fn wakeup_event_loop(&self) {
match self {
&WindowProxy::X(ref wp) => wp.wakeup_event_loop(),
@ -77,6 +78,7 @@ pub enum MonitorID {
None,
}
#[inline]
pub fn get_available_monitors() -> VecDeque<MonitorID> {
match *BACKEND {
Backend::Wayland => wayland::get_available_monitors()
@ -91,6 +93,7 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
}
}
#[inline]
pub fn get_primary_monitor() -> MonitorID {
match *BACKEND {
Backend::Wayland => MonitorID::Wayland(wayland::get_primary_monitor()),
@ -100,6 +103,7 @@ pub fn get_primary_monitor() -> MonitorID {
}
impl MonitorID {
#[inline]
pub fn get_name(&self) -> Option<String> {
match self {
&MonitorID::X(ref m) => m.get_name(),
@ -108,6 +112,7 @@ impl MonitorID {
}
}
#[inline]
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
match self {
&MonitorID::X(ref m) => m.get_native_identifier(),
@ -116,6 +121,7 @@ impl MonitorID {
}
}
#[inline]
pub fn get_dimensions(&self) -> (u32, u32) {
match self {
&MonitorID::X(ref m) => m.get_dimensions(),
@ -136,6 +142,7 @@ pub enum PollEventsIterator<'a> {
impl<'a> Iterator for PollEventsIterator<'a> {
type Item = Event;
#[inline]
fn next(&mut self) -> Option<Event> {
match self {
&mut PollEventsIterator::X(ref mut it) => it.next(),
@ -154,6 +161,7 @@ pub enum WaitEventsIterator<'a> {
impl<'a> Iterator for WaitEventsIterator<'a> {
type Item = Event;
#[inline]
fn next(&mut self) -> Option<Event> {
match self {
&mut WaitEventsIterator::X(ref mut it) => it.next(),
@ -163,6 +171,7 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
}
impl Window {
#[inline]
pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
opengl: &GlAttributes<&Window>) -> Result<Window, CreationError>
{
@ -189,6 +198,7 @@ impl Window {
}
}
#[inline]
pub fn set_title(&self, title: &str) {
match self {
&Window::X(ref w) => w.set_title(title),
@ -196,6 +206,7 @@ impl Window {
}
}
#[inline]
pub fn show(&self) {
match self {
&Window::X(ref w) => w.show(),
@ -203,6 +214,7 @@ impl Window {
}
}
#[inline]
pub fn hide(&self) {
match self {
&Window::X(ref w) => w.hide(),
@ -210,6 +222,7 @@ impl Window {
}
}
#[inline]
pub fn get_position(&self) -> Option<(i32, i32)> {
match self {
&Window::X(ref w) => w.get_position(),
@ -217,6 +230,7 @@ impl Window {
}
}
#[inline]
pub fn set_position(&self, x: i32, y: i32) {
match self {
&Window::X(ref w) => w.set_position(x, y),
@ -224,6 +238,7 @@ impl Window {
}
}
#[inline]
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
match self {
&Window::X(ref w) => w.get_inner_size(),
@ -231,6 +246,7 @@ impl Window {
}
}
#[inline]
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
match self {
&Window::X(ref w) => w.get_outer_size(),
@ -238,6 +254,7 @@ impl Window {
}
}
#[inline]
pub fn set_inner_size(&self, x: u32, y: u32) {
match self {
&Window::X(ref w) => w.set_inner_size(x, y),
@ -245,6 +262,7 @@ impl Window {
}
}
#[inline]
pub fn create_window_proxy(&self) -> WindowProxy {
match self {
&Window::X(ref w) => WindowProxy::X(w.create_window_proxy()),
@ -252,6 +270,7 @@ impl Window {
}
}
#[inline]
pub fn poll_events(&self) -> PollEventsIterator {
match self {
&Window::X(ref w) => PollEventsIterator::X(w.poll_events()),
@ -259,6 +278,7 @@ impl Window {
}
}
#[inline]
pub fn wait_events(&self) -> WaitEventsIterator {
match self {
&Window::X(ref w) => WaitEventsIterator::X(w.wait_events()),
@ -266,6 +286,7 @@ impl Window {
}
}
#[inline]
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
match self {
&mut Window::X(ref mut w) => w.set_window_resize_callback(callback),
@ -273,6 +294,7 @@ impl Window {
}
}
#[inline]
pub fn set_cursor(&self, cursor: MouseCursor) {
match self {
&Window::X(ref w) => w.set_cursor(cursor),
@ -280,6 +302,7 @@ impl Window {
}
}
#[inline]
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
match self {
&Window::X(ref w) => w.set_cursor_state(state),
@ -287,6 +310,7 @@ impl Window {
}
}
#[inline]
pub fn hidpi_factor(&self) -> f32 {
match self {
&Window::X(ref w) => w.hidpi_factor(),
@ -294,6 +318,7 @@ impl Window {
}
}
#[inline]
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
match self {
&Window::X(ref w) => w.set_cursor_position(x, y),
@ -301,6 +326,7 @@ impl Window {
}
}
#[inline]
pub fn platform_display(&self) -> *mut libc::c_void {
match self {
&Window::X(ref w) => w.platform_display(),
@ -308,6 +334,7 @@ impl Window {
}
}
#[inline]
pub fn platform_window(&self) -> *mut libc::c_void {
match self {
&Window::X(ref w) => w.platform_window(),
@ -317,6 +344,7 @@ impl Window {
}
impl GlContext for Window {
#[inline]
unsafe fn make_current(&self) -> Result<(), ContextError> {
match self {
&Window::X(ref w) => w.make_current(),
@ -324,6 +352,7 @@ impl GlContext for Window {
}
}
#[inline]
fn is_current(&self) -> bool {
match self {
&Window::X(ref w) => w.is_current(),
@ -331,6 +360,7 @@ impl GlContext for Window {
}
}
#[inline]
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
match self {
&Window::X(ref w) => w.get_proc_address(addr),
@ -338,6 +368,7 @@ impl GlContext for Window {
}
}
#[inline]
fn swap_buffers(&self) -> Result<(), ContextError> {
match self {
&Window::X(ref w) => w.swap_buffers(),
@ -345,6 +376,7 @@ impl GlContext for Window {
}
}
#[inline]
fn get_api(&self) -> ::Api {
match self {
&Window::X(ref w) => w.get_api(),
@ -352,6 +384,7 @@ impl GlContext for Window {
}
}
#[inline]
fn get_pixel_format(&self) -> PixelFormat {
match self {
&Window::X(ref w) => w.get_pixel_format(),

View file

@ -59,6 +59,7 @@ pub struct Window(win32::Window);
impl Window {
/// See the docs in the crate root file.
#[inline]
pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements,
opengl: &GlAttributes<&Window>) -> Result<Window, CreationError>
{
@ -70,12 +71,14 @@ impl Window {
impl Deref for Window {
type Target = win32::Window;
#[inline]
fn deref(&self) -> &win32::Window {
&self.0
}
}
impl DerefMut for Window {
#[inline]
fn deref_mut(&mut self) -> &mut win32::Window {
&mut self.0
}
@ -114,6 +117,7 @@ impl HeadlessContext {
}
impl GlContext for HeadlessContext {
#[inline]
unsafe fn make_current(&self) -> Result<(), ContextError> {
match self {
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.make_current(),
@ -121,6 +125,7 @@ impl GlContext for HeadlessContext {
}
}
#[inline]
fn is_current(&self) -> bool {
match self {
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.is_current(),
@ -128,6 +133,7 @@ impl GlContext for HeadlessContext {
}
}
#[inline]
fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
match self {
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.get_proc_address(addr),
@ -135,6 +141,7 @@ impl GlContext for HeadlessContext {
}
}
#[inline]
fn swap_buffers(&self) -> Result<(), ContextError> {
match self {
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.swap_buffers(),
@ -142,6 +149,7 @@ impl GlContext for HeadlessContext {
}
}
#[inline]
fn get_api(&self) -> Api {
match self {
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.get_api(),
@ -149,6 +157,7 @@ impl GlContext for HeadlessContext {
}
}
#[inline]
fn get_pixel_format(&self) -> PixelFormat {
match self {
&HeadlessContext::HiddenWindow(ref ctxt) => ctxt.get_pixel_format(),