Split GraphicsContext into Context and Surface
A `Context` is created with a display handle, and a `Surface` is created with a `&Context` and a window handle. Thus multiple windows can be created from the same context without duplicating anything that can be shared. This API is broadly similar to `wgpu` or `glutin`. On Wayland, the `Context` contains the `EventQueue`, which is shared between windows, and the `WlShm` global. On X11, `Context::new` checks for the availability of XShm, and contains a bool representing that as well as the `XCBConnection`. The shared context data is stored within the window in an `Arc`. On other platforms, the display isn't used and `Context` is empty. This does however test that the display handle has the right type on those platforms and fail otherwise. Previously the code didn't test that. Closes https://github.com/rust-windowing/softbuffer/issues/37.
This commit is contained in:
parent
3b33bbb0f5
commit
129069996e
11 changed files with 298 additions and 158 deletions
10
src/error.rs
10
src/error.rs
|
|
@ -5,14 +5,20 @@ use thiserror::Error;
|
|||
#[derive(Error, Debug)]
|
||||
#[non_exhaustive]
|
||||
pub enum SoftBufferError {
|
||||
#[error(
|
||||
"The provided display returned an unsupported platform: {human_readable_display_platform_name}."
|
||||
)]
|
||||
UnsupportedDisplayPlatform {
|
||||
human_readable_display_platform_name: &'static str,
|
||||
display_handle: RawDisplayHandle,
|
||||
},
|
||||
#[error(
|
||||
"The provided window returned an unsupported platform: {human_readable_window_platform_name}, {human_readable_display_platform_name}."
|
||||
)]
|
||||
UnsupportedPlatform {
|
||||
UnsupportedWindowPlatform {
|
||||
human_readable_window_platform_name: &'static str,
|
||||
human_readable_display_platform_name: &'static str,
|
||||
window_handle: RawWindowHandle,
|
||||
display_handle: RawDisplayHandle,
|
||||
},
|
||||
|
||||
#[error("The provided window handle is null.")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue