From 62bafe2130db5aaf32bd46091581086ae435e4cf Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 21 Sep 2015 13:15:43 +0200 Subject: Remove BuilderAttribs --- src/platform/linux/api_dispatch.rs | 20 ++++++++++---------- src/platform/linux/mod.rs | 11 ++++++++--- 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src/platform/linux') diff --git a/src/platform/linux/api_dispatch.rs b/src/platform/linux/api_dispatch.rs index 0fae6a0..46c58bb 100644 --- a/src/platform/linux/api_dispatch.rs +++ b/src/platform/linux/api_dispatch.rs @@ -6,14 +6,16 @@ pub use api::x11::{WaitEventsIterator, PollEventsIterator};*/ use std::collections::VecDeque; use std::sync::Arc; -use BuilderAttribs; use ContextError; use CreationError; use CursorState; use Event; +use GlAttributes; use GlContext; use MouseCursor; use PixelFormat; +use PixelFormatRequirements; +use WindowAttributes; use libc; use api::wayland; @@ -161,28 +163,26 @@ impl<'a> Iterator for WaitEventsIterator<'a> { } impl Window { - pub fn new(builder: BuilderAttribs) -> Result { - let window = builder.window; - let pf_reqs = builder.pf_reqs; - let opengl = builder.opengl; - + pub fn new(window: &WindowAttributes, pf_reqs: &PixelFormatRequirements, + opengl: &GlAttributes<&Window>) -> Result + { match *BACKEND { Backend::Wayland => { - let opengl = opengl.map_sharing(|w| match w { + let opengl = opengl.clone().map_sharing(|w| match w { &Window::Wayland(ref w) => w, _ => panic!() // TODO: return an error }); - wayland::Window::new(&window, &pf_reqs, &opengl).map(Window::Wayland) + wayland::Window::new(window, pf_reqs, &opengl).map(Window::Wayland) }, Backend::X(ref connec) => { - let opengl = opengl.map_sharing(|w| match w { + let opengl = opengl.clone().map_sharing(|w| match w { &Window::X(ref w) => w, _ => panic!() // TODO: return an error }); - x11::Window::new(connec, &window, &pf_reqs, &opengl).map(Window::X) + x11::Window::new(connec, window, pf_reqs, &opengl).map(Window::X) }, Backend::Error(ref error) => Err(CreationError::NoBackendAvailable(Box::new(error.clone()))) diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index 3525ce5..f5d663b 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -1,11 +1,12 @@ #![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))] use Api; -use BuilderAttribs; use ContextError; use CreationError; +use GlAttributes; use GlContext; use PixelFormat; +use PixelFormatRequirements; use libc; use api::osmesa::{self, OsMesaContext}; @@ -25,8 +26,12 @@ pub type MonitorID = (); // TODO: hack to make things work pub struct HeadlessContext(OsMesaContext); impl HeadlessContext { - pub fn new(builder: BuilderAttribs) -> Result { - match OsMesaContext::new(builder) { + pub fn new(dimensions: (u32, u32), pf_reqs: &PixelFormatRequirements, + opengl: &GlAttributes<&HeadlessContext>) -> Result + { + let opengl = opengl.clone().map_sharing(|c| &c.0); + + match OsMesaContext::new(dimensions, pf_reqs, &opengl) { Ok(c) => return Ok(HeadlessContext(c)), Err(osmesa::OsMesaCreationError::NotSupported) => (), Err(osmesa::OsMesaCreationError::CreationError(e)) => return Err(e), -- cgit v1.2.3