Commit graph

2 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
Emil Loer
a78becd316
Add rectangle toggle example
This commit adds a new example that shows a XOR pattern. A rectangle can
be superimposed on the background by pressing the space bar.

This example was created to demonstrate a bug in the Core Graphics
backend that causes the buffer to fade when calling set_buffer, instead
of applying it immediately.
2023-01-05 22:16:24 +01:00