Commit graph

15 commits

Author SHA1 Message Date
John Nunley
0bcd2e22a2
breaking: Use raw-window-handle version 0.6
Signed-off-by: John Nunley <dev@notgull.net>
Co-Authored-By: dAxpeDDa <daxpedda@gmail.com>
2023-10-26 19:15:51 -07:00
Ian Douglas Scott
edc5c76180 examples: Avoid dividing index to get x, y; calculate index from x, y
Division is more expensive than multiplication, and this doesn't seem to
be optimize away, so iterating over `(0..height)` and `(0..width)`
provides better performance.

It's good to have the example show the best way to write code using
softbuffer, and this helps when using examples as a benchmark. This will
also be needed if Softbuffer supports formats where `stride` isn't just
`width * pixel_size`, and needs alignment.
2023-04-11 12:21:50 -07:00
Ian Douglas Scott
a09e4cf679
Owned pixel buffer for no-copy presentation
This is based on the API that will be used for no-copy presentation. But
wraps it in `set_buffer`.

This also fixes the Wayland buffer code to set `self.width` and
`self.height` on resize, and set the length of the shared memory file
when the buffer is created.

Co-authored-by: jtnunley <jtnunley01@gmail.com>
2023-04-06 10:30:59 +03:00
Ian Douglas Scott
dce6cbc111 Update windows-sys dependency, and winit dev dependency
Using the latest `winit` version in examples fixes resizing behavior on
Wayland, so the workaround for that in the `winit` example is also
removed here.
2023-02-20 10:22:34 -08:00
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
Ian Douglas Scott
cdfae58510 wayland: Reuse buffers and pools; check buffer release
Also updates `winit` example to redraw on resize, which seems to be
necessary.

With this resizing seems to be entirely smooth, without visual
corruption from it overwriting the buffer the server is displaying.
2022-12-20 16:14:10 -07: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
dc6fc474be Added better error handling 2022-01-16 09:01:02 -06:00
David Johnson
d89a0c92aa Added windows support and made example render something fancier 2022-01-16 08:03:20 -06:00
David Johnson
a36b11a934 X11 implementation no longer has an extraneous copy to deal with xlib's lifetime requirements 2022-01-15 08:33:24 -06:00
David Johnson
384f2dc9a3 Added X11 support 2022-01-15 08:17:17 -06:00