my window server is userspace-based and allows applications to create & manipulate components via messages. Now I'm facing a little bit of a design issue of which I'm not sure if theres a better solution than the one I've currently devised.
I want a component (I call it canvas) where the client program is capable of drawing anything onto it. So, the client only has a buffer where it writes 32bit RGBA, then notifies the window server that changes were made (maybe also via shared memory to increase performance) and the server can blit it right from the buffer. The thing I mostly have problems with, is that when the canvas is being resized due to layouting, the buffer might not be sufficient/could be shrinked.
Steps in the entire process would then be:
- client requests canvas component
- window server creates canvas component and allocates a buffer of this initial size, say 200x100
- this buffers memory is shared with the client so it can write there (say it is page-wise memory, to avoid the client of tangling with the servers memory)
- when the window server resizes the canvas component for any reason (either a layout manager taking effect or the client requested it himself), the buffer must be resized accordingly. the window server now keeps the old buffer though, and notifies the client about the new buffer with a message
- only when the client responds with a message saying that it acknowledges the new buffer, the old one is deleted and the new one used for blitting
- the client can not mess with the window servers memory due to page-wise buffers
- there is never a state where a visually unappealing rendering happens (due to empty borders in the buffer)
- no memory access failures due to the old buffer being still available until acknowledged
- updating the canvas is blocked until the client responds to acknowledge the new buffer
Anyone have a different approach for this?
Greets, friends.