Commit graph

9 commits

Author SHA1 Message Date
Ian Douglas Scott
129069996e 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.
2023-01-06 21:36:53 -08:00
David Johnson
9023b096d7 Updated rest of the code to use softbuffer name instead of swbuf 2022-12-22 18:43:54 -06:00
John Nunley
5674886dfa
Add reformat to the CI (#21) 2022-12-22 12:35:18 -08:00
Simon Hausmann
fbc48512ef Modify the fruit example to show any logical vs. physical pixel mismatches
Resize the window to the physical size of the image.
If softbuffer scales the contents incorrectly, only parts
of the fruit basket will be visible.
2022-12-21 07:40:47 +01:00
Jeremy Soller
9b8641fc07 Make new function take both a HasRawWindowHandle and a HasRawDisplayHandle object 2022-12-20 13:40:54 -07:00
Jeremy Soller
99d63063b6 Take a reference to a window in GraphicsContext::new, like glutin and wgpu 2022-12-20 13:40:54 -07:00
Jeremy Soller
939bcc44d8
Fork to swbuf 2022-12-20 07:07:57 -07:00
Liam Murphy
d735510f72 Add web support
A limitation of this implementation is that it can't coexist with anything which creates a canvas context other than `CanvasRenderingContext2D`, since only one context can exist per canvas.
2022-02-12 20:24:18 +11:00
David Johnson
a23b7f9876 Added fruit example to show a more recognizable image for debugging 2022-01-18 22:07:17 -06:00