graphics: Move PixelFormat out of gl module

This commit is contained in:
Victor Brekenfeld 2018-11-22 12:20:31 +01:00
parent 079ad953a4
commit 9a82de6fae
7 changed files with 35 additions and 28 deletions

View File

@ -7,7 +7,10 @@ use super::error::*;
use backend::drm::{Device, Surface};
use backend::egl::native::{Backend, NativeDisplay, NativeSurface};
use backend::egl::{EGLContext, EGLSurface};
use backend::graphics::gl::{GLGraphicsBackend, PixelFormat};
#[cfg(feature = "renderer_gl")]
use backend::graphics::gl::GLGraphicsBackend;
#[cfg(feature = "renderer_gl")]
use backend::graphics::PixelFormat;
use backend::graphics::{CursorBackend, SwapBuffersError};
pub struct EglSurface<
@ -91,6 +94,7 @@ where
}
}
#[cfg(feature = "renderer_gl")]
impl<B: Backend<Surface = <D as Device>::Surface> + 'static, D: Device + NativeDisplay<B> + 'static>
GLGraphicsBackend for EglSurface<B, D>
where

View File

@ -1,7 +1,7 @@
//! EGL context related structs
use super::{error::*, ffi, native, EGLSurface};
use backend::graphics::gl::PixelFormat;
use backend::graphics::PixelFormat;
use nix::libc::{c_int, c_void};
use slog;
use std::{

View File

@ -337,6 +337,7 @@ impl EGLDisplay {
context: &EGLContext<B, N>,
display: *mut wl_display,
) -> EGLDisplay {
#[cfg(feature = "renderer_gl")]
let gl = gl_ffi::Gles2::load_with(|s| unsafe { context.get_proc_address(s) as *const _ });
EGLDisplay {

View File

@ -0,0 +1,22 @@
/// Describes the pixel format of a framebuffer
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PixelFormat {
/// is the format hardware accelerated
pub hardware_accelerated: bool,
/// number of bits used for colors
pub color_bits: u8,
/// number of bits used for alpha channel
pub alpha_bits: u8,
/// number of bits used for depth channel
pub depth_bits: u8,
/// number of bits used for stencil buffer
pub stencil_bits: u8,
/// is stereoscopy enabled
pub stereoscopy: bool,
/// is double buffering enabled
pub double_buffer: bool,
/// number of samples used for multisampling if enabled
pub multisampling: Option<u16>,
/// is srgb enabled
pub srgb: bool,
}

View File

@ -1,6 +1,6 @@
use nix::libc::c_void;
use super::SwapBuffersError;
use super::{SwapBuffersError, PixelFormat};
#[cfg_attr(feature = "cargo-clippy", allow(clippy))]
#[allow(missing_docs)]
@ -10,29 +10,6 @@ pub(crate) mod ffi {
pub use self::ffi::Gles2;
/// Describes the pixel format of the main framebuffer
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PixelFormat {
/// is the format hardware accelerated
pub hardware_accelerated: bool,
/// number of bits used for colors
pub color_bits: u8,
/// number of bits used for alpha channel
pub alpha_bits: u8,
/// number of bits used for depth channel
pub depth_bits: u8,
/// number of bits used for stencil buffer
pub stencil_bits: u8,
/// is stereoscopy enabled
pub stereoscopy: bool,
/// is double buffering enabled
pub double_buffer: bool,
/// number of samples used for multisampling if enabled
pub multisampling: Option<u16>,
/// is srgb enabled
pub srgb: bool,
}
/// Trait that describes objects that have an OpenGL context
/// and can be used to render upon
pub trait GLGraphicsBackend {

View File

@ -8,6 +8,9 @@ pub use self::errors::*;
mod cursor;
pub use self::cursor::*;
mod format;
pub use self::format::*;
#[cfg(feature = "renderer_gl")]
pub mod gl;
#[cfg(feature = "renderer_glium")]

View File

@ -6,8 +6,8 @@ use backend::{
EGLDisplay, EGLGraphicsBackend, EGLSurface,
},
graphics::{
gl::{GLGraphicsBackend, PixelFormat},
CursorBackend, SwapBuffersError,
gl::GLGraphicsBackend,
CursorBackend, SwapBuffersError, PixelFormat,
},
input::{
Axis, AxisSource, Event as BackendEvent, InputBackend, InputHandler, KeyState, KeyboardKeyEvent,