Conversation
0bebf35 to
268a4bd
Compare
|
match event {
Event::RedrawRequested => {
let surface = Surface::new(&context, my_window);
/* .. */
drop(surface);
}
}If the latter, we should move some of the allocations out of |
|
I'm assuming one would keep the |
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 #37.
268a4bd to
1290699
Compare
notgull
left a comment
There was a problem hiding this comment.
I'm wondering if it would be more idiomatic to make set_buffer take &Context as an argument. This would mean that we wouldn't need to have an Arc<Context> for Wayland and X11. This is less of a performance thing and more of an "is this more idiomatic?" thing.
LGTM otherwise
|
Maybe. Though taking a There could also be weird behavior if you passed a different context, though that probably isn't too much of an issue. (Perhaps the ideal solution would be a lifetime bound on |
* On MacOS, the contents scale is updated when set_buffer() is called, to adapt when the window is on a new screen (#68). * **Breaking:** Split the `GraphicsContext` type into `Context` and `Surface` (#64). * On Web, cache the document in the `Context` type (#66). * **Breaking:** Introduce a new "owned buffer" for no-copy presentation (#65). * Enable support for multi-threaded WASM (#77). * Fix buffer resizing on X11 (#69). * Add a set of functions for handling buffer damage (#99). * Add a `fetch()` function for getting the window contents (#104). * Bump MSRV to 1.64 (#81).
WIP implementation of #37. Currently compiles on Linux, and splits parts of Wayland code to not need duplication for multiple windows.
Seems best to start with this API change before moving on to #40.