diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-08-20 09:10:55 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-08-20 09:10:55 +0200 |
| commit | 442faf9462ecc6e28373500bc3ecda958054f134 (patch) | |
| tree | 010b83f32229dce4a8fb62bbac2a4771bd1c1d1a /src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx | |
| parent | 3384776f8e4b88da17b8418ddb3c9d752551bb6f (diff) | |
Create class function Fl_Wayland_Graphics_Driver::custom_offscreen()
Diffstat (limited to 'src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx')
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx index 6d8b22a3d..d5e1315a6 100644 --- a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx @@ -17,6 +17,7 @@ #include "Fl_Wayland_Graphics_Driver.H" #include "Fl_Wayland_Screen_Driver.H" #include "Fl_Wayland_Window_Driver.H" +#include <FL/Fl_Image_Surface.H> #include <sys/mman.h> #include <unistd.h> // for close() #include <errno.h> @@ -224,8 +225,21 @@ void Fl_Wayland_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_O cairo_restore(cairo_); } +const cairo_user_data_key_t Fl_Wayland_Graphics_Driver::key = {}; -struct Fl_Wayland_Graphics_Driver::draw_buffer *Fl_Wayland_Graphics_Driver::offscreen_buffer( +struct +Fl_Wayland_Graphics_Driver::draw_buffer *Fl_Wayland_Graphics_Driver::offscreen_buffer( Fl_Offscreen offscreen) { - return (struct draw_buffer*)cairo_get_user_data((cairo_t*)offscreen, NULL); + return (struct draw_buffer*)cairo_get_user_data((cairo_t*)offscreen, &key); +} + + +Fl_Image_Surface *Fl_Wayland_Graphics_Driver::custom_offscreen(int w, int h, + struct Fl_Wayland_Graphics_Driver::wld_buffer **p_off) { + struct Fl_Wayland_Graphics_Driver::wld_buffer *off = + Fl_Wayland_Graphics_Driver::create_shm_buffer(w, h); + *p_off = off; + memset(off->draw_buffer.buffer, 0, off->draw_buffer.data_size); + cairo_set_user_data(off->draw_buffer.cairo_, &key, &off->draw_buffer, NULL); + return new Fl_Image_Surface(w, h, 0, (Fl_Offscreen)off->draw_buffer.cairo_); } |
