Skip to content

Commit 662e552

Browse files
committed
Add "how it works" section to README
1 parent 04ae5e1 commit 662e552

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ Next, you create a [`Context`] and [`Surface`] from that window, and can now cal
88

99
Note that Softbuffer only provides the `&mut [...]` buffer, it does not provide any rendering primitives for drawing rectangles, circles, curves and so on. For that, you'll want to use a crate like [`tiny-skia`](https://docs.rs/tiny-skia/) or [`vello_cpu`](https://docs.rs/vello_cpu/).
1010

11+
## How it works
12+
13+
Most platforms have a compositor of some sort (WindowServer on macOS, Desktop Window Manager on
14+
Windows, the Wayland compositor, etc). This is a separate process that applications communicate
15+
with over IPC, and it is responsible for taking the various surfaces that applications send to it
16+
and mash ("composite") them together in the right way to render the user's desktop on the
17+
connected monitors.
18+
19+
The role of Softbuffer then is to create a shared memory region (i.e. [`Buffer`]) that can be
20+
written to from the CPU, and then handed to the compositor (in [`Buffer::present`]). Softbuffer
21+
keeps a set of buffers around per surface to implement double-buffering (depending on platform
22+
requirements).
23+
24+
Softbuffer strives to present buffers in a zero-copy manner. One interesting wrinkle here is that
25+
the compositor is often GPU-accelerated, so on platforms without a unified memory architecture,
26+
some copying is inherently necessary (though when possible, it is done in hardware using DMA).
27+
1128
## Platform support:
1229

1330
Some, but not all, platforms supported in [raw-window-handle](https://crates.io/crates/raw-window-handle) are supported

0 commit comments

Comments
 (0)