diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-06-05 11:00:33 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-06-05 11:00:33 +0200 |
| commit | 5be3fbf913210a8b81fe101c3927c141432fa724 (patch) | |
| tree | b79a0e6844573483dda34751ea47b60e130db308 /src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H | |
| parent | 5dfa51a8201ce0111220575956d2fb0db989fe90 (diff) | |
Improve re-use of client/compositor shared memory by Wayland buffers
Diffstat (limited to 'src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H')
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H index b6697df40..81a3dbf8f 100644 --- a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H @@ -1,7 +1,7 @@ // // Definition of class Fl_Wayland_Graphics_Driver. // -// Copyright 2021-2022 by Bill Spitzak and others. +// Copyright 2021-2023 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -22,37 +22,10 @@ #ifndef FL_WAYLAND_GRAPHICS_DRIVER_H #define FL_WAYLAND_GRAPHICS_DRIVER_H - -/* Implementation note about buffers FLTK uses to support display graphics under Wayland. - - Each window is associated to an FLTK-defined object of type struct wld_window - containing itself an FLTK-defined struct fl_wld_buffer object holding all graphics data. - Among members of this latter structure are: - - struct wl_buffer wl_buffer - is a Wayland-defined type for a graphics buffer able to be attached to a wl_surface; - - void *data - points to the beginning of the memory zone where wl_buffer stores its graphics data; - - unsigned char *draw_buffer - contains a graphics buffer to which all Cairo drawings are directed; - draw_buffer and data both have the same organization called CAIRO_FORMAT_ARGB32 in Cairo parlance - and WL_SHM_FORMAT_ARGB8888 in Wayland parlance which means BGRA byte order. - - int width - gives the pixel width of the graphics buffer; - - int stride - gives the stride of this buffer; - - size_t data_size - gives the total buffer size in bytes (thus, data_size / stride gives the buffer height); - - struct wl_callback *cb - is used to synchronize drawing with the compositor during progressive drawing. - - When a graphics scene is to be committed, the data_size bytes of draw_buffer are copied by memcpy() - starting at data, and wl_buffer is attached to the wl_surface which is committed for display - by wl_surface_commit(). - */ - - #include "../Cairo/Fl_Cairo_Graphics_Driver.H" #include <stdint.h> // for uint32_t +#include <wayland-client.h> // for wl_list + struct fl_wld_buffer { struct wl_buffer *wl_buffer; @@ -64,19 +37,19 @@ struct fl_wld_buffer { struct wl_callback *cb; bool draw_buffer_needs_commit; cairo_t *cairo_; + struct wl_shm_pool *shm_pool; + struct wl_list link; // links all buffers from the same wl_shm_pool }; -struct wld_window; class Fl_Wayland_Graphics_Driver : public Fl_Cairo_Graphics_Driver { private: struct fl_wld_buffer *buffer_; public: - struct wld_shm_pool_data { // attached to wl_shm_pool objects + struct wld_shm_pool_data { // one record attached to each wl_shm_pool object char *pool_memory; // start of mmap'ed memory encapsulated by the wl_shm_pool int pool_size; // size of encapsulated memory - int use_count; // nber of active wl_buffer objects in this wl_shm_pool - bool destroyed; // true after the wl_shm_pool was destroyed + struct wl_list buffers; // to list of fl_wld_buffer's from this pool }; Fl_Wayland_Graphics_Driver(); static const uint32_t wld_format; |
