From bf7d53006cbe1ba6a52a4d4f286183c2f29ddcee Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sat, 9 Dec 2023 10:38:05 +0100 Subject: Complete and update documentation of Wayland buffers --- documentation/src/wayland.dox | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'documentation') diff --git a/documentation/src/wayland.dox b/documentation/src/wayland.dox index 8daef2c95..45f779827 100644 --- a/documentation/src/wayland.dox +++ b/documentation/src/wayland.dox @@ -529,20 +529,20 @@ This happens when classes \c Fl_PostScript_File_Device and \c Fl_Printer are use Wayland uses buffers, objects of type struct wl_buffer, to draw to surfaces. In principle, one or more buffers can be associated to a surface, and functions \c wl_surface_attach() and \c wl_surface_commit() are called to first attach one such buffer to the surface and then inform the -compositor to map this buffer on the display. Wayland buffers can use various +compositor to map this buffer's graphics content on the display. Wayland buffers can use various memory layouts. FLTK uses WL_SHM_FORMAT_ARGB8888, which is the same layout as what Cairo calls CAIRO_FORMAT_ARGB32. FLTK calls function \c Fl_Wayland_Window_Driver::make_current() before drawing to any Fl_Window. Member \c buffer of this Fl_Window's struct wld_window (see \ref wld_window) is NULL when the window has just been created or resized. In that case, FLTK calls -\c Fl_Wayland_Graphics_Driver::create_wld_buffer() which calls -\c create_shm_buffer() and \c cairo_init() to create -- a Wayland buffer; -- a Cairo image surface. +\c Fl_Wayland_Graphics_Driver::create_wld_buffer() which +returns a pointer to a struct wld_buffer containing +- a Wayland buffer, member \c wl_buffer; +- a Cairo image surface, created by a call to \c Fl_Wayland_Graphics_Driver::cairo_init(). Each of these two objects encapsulates a byte array of the same size and the same memory layout -destined to contain the Fl_Window's graphics. The Cairo surface object is where FLTK draws. +destined to contain the Fl_Window's graphics. The Cairo image surface object is where FLTK draws. The Wayland buffer is what Wayland maps on the display. FLTK copies the Cairo surface's byte array to the Wayland buffer's byte array before beginning the mapping operation. If \c width and \c height are a window's dimensions in pixels, @@ -552,10 +552,11 @@ If \c width and \c height are a window's dimensions in pixels, \endcode give \c size, the common size of both byte arrays. +The effective creation of the \c wl_buffer object is delayed until function +\c Fl_Wayland_Graphics_Driver::buffer_commit() gets called. Section \ref wayland-buffer-factory below details how FLTK creates \c wl_buffer objects. -FLTK associates to each surface a -struct Fl_Wayland_Graphics_Driver::wld_buffer (see \ref wld_buffer) containing +The struct Fl_Wayland_Graphics_Driver::wld_buffer (see \ref wld_buffer) contains a pointer to the byte array of the Cairo image surface (member \c draw_buffer.buffer), information about the Wayland buffer (members \c wl_buffer and \c data), the common size of the Cairo surface's and Wayland buffer's byte arrays (member \c draw_buffer.data_size), and other information. A pointer to this @@ -574,20 +575,21 @@ FLTK has computed a damaged region. If that region is not null, surface to the Wayland buffer and calls function \c wl_surface_damage_buffer() for these parts to inform the compositor of what parts of the surface need its attention. -