Commit graph

92 commits

Author SHA1 Message Date
Ian Douglas Scott
e667df2da6 Update drm and nix dependencies 2023-10-13 08:42:30 -07:00
Ian Douglas Scott
36618b63eb
Merge pull request #149 from rust-windowing/update-wayland
wayland: Update to wayland-client 0.31
2023-09-09 16:42:57 -07:00
Benoît Cortier
908408ba80
fix(web): optimize and fix present_with_damage (#150)
Co-authored-by: daxpedda <daxpedda@gmail.com>
2023-09-09 17:30:38 +02:00
Ian Douglas Scott
a9d7e159e0 wayland: Update to wayland-client 0.31
Updates `rust-version` from 1.64 to 1.65.
2023-09-07 19:12:01 -07:00
Simon Hausmann
9b44f2eaea
bugfix: Fix length of returned buffer on x11 when using the wire-transferred buffer
total_len() computes the number of bytes, while the wire Vec holds u32.
2023-09-06 08:05:17 -07:00
Ian Douglas Scott
1770b331bf orbital: Use syscall::MAP_SHARED for mapping
This seems to be required to work correctly since
https://gitlab.redox-os.org/redox-os/orbital/-/merge_requests/51.

Orbclient had a similar change:
9097e71c9a.
2023-08-16 18:59:40 -07:00
John Nunley
ac0b7f5e14
feat: Add a DRM/KMS backend
This adds a DRM/KMS based backend to the system, as per #42. This system finds a CRTC and a connector, then uses that to create a frame buffer and a DUMB buffer that it can render to.

There's much more to do, and is left as an exercise for anyone with a significant DRM-based use case to pick up and fix.

Signed-off-by: John Nunley <dev@notgull.net>
2023-08-12 13:39:13 -07:00
John Nunley
2689cec2ca
bugfix: Mark fetch as unsupported on Windows for now
This fetch function has been broken and is probably unsound. This also
fixes the flakey Windows CI that we've been dealing with.

Signed-off-by: John Nunley <dev@notgull.net>
2023-08-10 19:28:04 -07:00
Ian Douglas Scott
e10c360929 cg: Require non-zero width/height; panic instead of segfault
Fixes https://github.com/rust-windowing/softbuffer/issues/124.
2023-07-24 18:24:23 -07:00
Fenhl
1f326b2199
bugfix: Reintroduce Error trait impl for SoftBufferError 2023-07-12 18:43:49 -07:00
John Nunley
abb7a4e9ac
version: Use fastrand v2.0.0 2023-07-03 07:59:34 -07:00
John Nunley
3404953bdb
m: Use tiny-xlib instead of x11-dl
My new tiny-xlib crate takes up a fraction of the space that the x11-dl crate uses, supports
feature-based static linking and involves less of Xlib's ridiculous surface.
2023-07-02 15:08:01 -07:00
dAxpeDDa
6c78268502 Implement OffscreenCanvas support 2023-06-05 01:39:28 +02:00
John Nunley
7b089d46b2
Remove the thiserror dependency (#116) 2023-06-03 07:08:35 -07:00
Ian Douglas Scott
1e7b9213d2 Merge remote-tracking branch 'origin/master' into damage 2023-06-02 15:03:10 -07:00
John Nunley
44248477be
feat: Add a function for retrieving the window contents
This function is useful for testing the window contents in certain cases. In addition,
this means that we can now have reliable tests for softbuffer's actual functionality.

Signed-off-by: John Nunley <jtnunley01@gmail.com>
Co-authored-by: dAxpeDDa <daxpedda@gmail.com>
2023-06-01 20:09:30 -07:00
Ian Douglas Scott
591a40c0a6 Fix doc link 2023-05-30 15:36:14 -07:00
Ian Douglas Scott
a147a15d45 Use u32/NonZeroU32 for Rect, and return error if out of range 2023-05-30 15:27:59 -07:00
Ian Douglas Scott
199a016f44 Merge remote-tracking branch 'origin/master' into damage 2023-05-30 14:25:45 -07:00
daxpedda
fcda747ddf
Add from_canvas() to Surface for Wasm (#76)
Co-authored-by: Toniman575 <toniman575@gmail.com>
2023-05-08 15:43:34 +02:00
daxpedda
d7888ef806
Implement present_with_damage for Web (#101) 2023-04-27 10:19:29 -07:00
Ian Douglas Scott
29b3f4a978 Add a Buffer::age() method
Fixes https://github.com/rust-windowing/softbuffer/issues/90.
2023-04-26 15:04:20 -07:00
Ian Douglas Scott
c1d6716eec Add a Buffer::present_with_damage() method
Supported on Wayland, X11, and Win32.

Fixes https://github.com/rust-windowing/softbuffer/issues/39.

try_for_each
2023-04-26 11:58:11 -07:00
Luna
5efa5d8898 x11: Assert that size >= buffer_size 2023-04-24 20:31:39 -03:00
Luna
c68f41bf10 x11: Limit returned shm buffer size 2023-04-24 19:37:41 -03:00
John Nunley
92e8eb7d22
Don't use the borrowing trick under Windows (#89) 2023-04-07 17:31:21 -07:00
John Nunley
885c76bf02
m: Don't use the borrowing trick under X11 (#86) 2023-04-07 11:54:50 -07:00
jtnunley
74a3357ce8 Use the SwResultExt trait in more places 2023-04-06 11:09:47 -07:00
John Nunley
379910cb8e
Merge pull request #77 from daxpedda/wasm-atomics
Fix multi-threaded Wasm
2023-04-06 10:40:23 -07:00
Ian Douglas Scott
7a687105e3 Update windows-sys and image 2023-04-06 08:37:57 -07:00
dAxpeDDa
c0af587718
Fix multi-threaded Wasm 2023-04-06 17:35:14 +02: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
Ashley Wulber
0bdbf1a752
fix: update width and height when resizing buffer 2023-01-22 22:23:44 -05:00
Simon Hausmann
4c6631c764 mac: retain the NSWindow to ensure that the call to retrieving the backing scale factor in set_buffer works 2023-01-15 17:04:57 +01:00
Simon Hausmann
2832a6e42b mac: Fix layer scale not being updated when contents is updated and window is on a new screen
cc #67
2023-01-15 09:12:28 +01:00
John Nunley
33a4c3741b
m: Cache document in web frontend (#66) 2023-01-14 05:48:44 +00: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
Jeremy Soller
c0142e9faf
Merge pull request #59 from thedjinn/disable-calayer-actions
Disable CALayer fade action when setting buffers
2023-01-06 09:06:51 -07:00
Ian Douglas Scott
165a15e92c wayland: Seal memfd to prevent shrinking
I believe this should be possible wherever `memfd_create` is available.

Sealing isn't required, but Wayland doesn't allow a client to shrink an
shm pool, so there's no reason we should shrink the file. And if we mmap
the file, this prevents a `SIGBUS` if the compositor (incorrectly)
shrunk it.

So we might as well do this.
2023-01-06 07:52:59 -08:00
John Nunley
a6042f664d
x11: Implement image transfer using the MIT-SHM extension (#46)
* Implement shared memory transfer for X11

* Change to x11rb

* Fix leak + review from psychon

* Add waits to prevent illegal writes to SHM

* @ids1024 code review
2023-01-05 19:27:54 -08:00
Emil Loer
b72055d122
Disable CALayer fade action when setting buffers
This commit fixes a bug in the Core Graphics backend that causes a new
buffer not be shown immediately but instead use a quarter second fade
transition. This happens because the CALayer has a default action
associated with a change in the layer contents.

The problem was mitigated by wrapping the contents change in a
transaction and disabling all actions for the duration of this
transaction.
2023-01-05 22:17:10 +01:00
Jeremy Soller
13853fe967
Merge pull request #54 from ids1024/bsd
Add support and CI tests for BSDs
2023-01-04 07:04:37 -07:00
Jeremy Soller
c374c9ebcb
Merge pull request #55 from ids1024/wayland-buffer
wayland: Block dispatching if back buffer isn't released
2023-01-04 07:01:37 -07:00
Ian Douglas Scott
a90c7bca04 Use cfg_aliases crate to make Wayland/X #[cfg(..)] less redundant 2023-01-03 12:45:18 -08:00
Ian Douglas Scott
4f6542ceaa Add support and CI tests for BSDs
This adds a fallback using `shm_open`/`shm_unlink` for platforms where
`memfd_create` doesn't exist. This seems to be how this is normally
handled, though it's a bit ugly.

This also builds the wayland/x11 code for NetBSD/OpenBSD/DragonFlyBSD.

Add CI builds for FreeBSD and NetBSD. We would need some kind of
virtualisation though to actually run tests on such targets.

I've tested the `shm_open` logic on Linux, but haven't run it on any
BSDs.
2023-01-03 12:45:15 -08:00
i509VCB
4aac1d2860
detail platform specific behavior of set_buffer on Wayland 2023-01-01 13:52:47 -06:00
Ian Douglas Scott
aad40343bc wayland: Block dispatching if back buffer isn't released
https://github.com/rust-windowing/softbuffer/issues/41

If `set_buffer` can just be called in a loop without waiting for buffers
to be released or a frame callback, but can also be called in other
ways, I don't know if there's a better solution than blocking.

Should fix https://github.com/rust-windowing/softbuffer/issues/48. The
animation example could probably be implemented better, but this is at
least better.

I guess it should be documented that `set_buffer` may block? I don't
know how this compares to other backends.
2022-12-27 15:42:28 -08:00
Ian Douglas Scott
fc1bba64ab Rename SwBufError back to SoftBufferError
This seems to be the last thing left over from the `swbuf` rename.
2022-12-27 12:57:26 -08:00
John Nunley
3eeafad834
x11: Add XCB support to the X11 backend (#52) 2022-12-27 09:14:54 -08:00
Mads Marquart
ff5824b6a5 Avoid a bit of unsafe in Windows backend 2022-12-23 04:20:01 +01:00