#ifndef FL_WAYLAND_GRAPHICS_DRIVER_H
#define FL_WAYLAND_GRAPHICS_DRIVER_H
#include "../Cairo/Fl_Cairo_Graphics_Driver.H"
#include <stdint.h>
#include <wayland-client.h>
class Fl_Wayland_Graphics_Driver : public Fl_Cairo_Graphics_Driver {
public:
struct draw_buffer {
unsigned char *buffer;
cairo_t *cairo_;
size_t data_size; int stride;
int width;
};
struct wld_buffer {
struct draw_buffer draw_buffer;
struct wl_list link; struct wl_buffer *wl_buffer;
void *data;
struct wl_shm_pool *shm_pool;
bool draw_buffer_needs_commit;
bool in_use; bool released; };
struct wld_shm_pool_data { char *pool_memory; size_t pool_size; struct wl_list buffers; };
static const uint32_t wld_format;
static struct wl_shm_pool *current_pool;
static FL_EXPORT const struct wl_callback_listener *p_surface_frame_listener;
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen osrc,
int srcx, int srcy) FL_OVERRIDE;
void cache_size(Fl_Image *img, int &width, int &height) FL_OVERRIDE;
static struct wld_buffer *create_wld_buffer(int width, int height, bool with_shm = true);
static void create_shm_buffer(wld_buffer *buffer);
static void buffer_release(struct wld_window *window);
static void buffer_commit(struct wld_window *window, cairo_region_t *r = NULL);
static void cairo_init(struct draw_buffer *buffer, int width, int height, int stride,
cairo_format_t format);
static FL_EXPORT struct draw_buffer *offscreen_buffer(Fl_Offscreen);
static const cairo_user_data_key_t key;
static Fl_Image_Surface *custom_offscreen(int w, int h, struct wld_buffer **buffer);
};
#endif