summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Image_Surface.H3
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx2
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx4
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx10
4 files changed, 13 insertions, 6 deletions
diff --git a/FL/Fl_Image_Surface.H b/FL/Fl_Image_Surface.H
index fcd9db430..da2f5e761 100644
--- a/FL/Fl_Image_Surface.H
+++ b/FL/Fl_Image_Surface.H
@@ -117,6 +117,9 @@ protected:
of class Fl_Image_Surface_Driver for the plaform.
*/
static Fl_Image_Surface_Driver *newImageSurfaceDriver(int w, int h, int high_res, Fl_Offscreen off);
+public:
+ /** Returns pointer to the associated Fl_Image_Surface object */
+ Fl_Image_Surface *image_surface() { return image_surface_; }
};
/**
diff --git a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
index 3fa9c7094..f35ae8543 100644
--- a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
@@ -70,7 +70,6 @@ struct fl_wld_buffer *Fl_Wayland_Graphics_Driver::create_shm_buffer(int width, i
wl_shm_pool_set_user_data(pool, pool_data);
}
buffer = (struct fl_wld_buffer*)calloc(1, sizeof(struct fl_wld_buffer));
- buffer->draw_buffer.stride = stride;
buffer->wl_buffer = wl_shm_pool_create_buffer(pool, chunk_offset, width, height, stride, Fl_Wayland_Graphics_Driver::wld_format);
// add this buffer to head of list of current pool's buffers
wl_list_insert(&pool_data->buffers, &buffer->link);
@@ -152,6 +151,7 @@ void Fl_Wayland_Graphics_Driver::buffer_commit(struct wld_window *window,
void Fl_Wayland_Graphics_Driver::cairo_init(struct fl_wld_draw_buffer *buffer, int width, int height, int stride, cairo_format_t format) {
buffer->data_size = stride * height;
+ buffer->stride = stride;
buffer->buffer = new uchar[buffer->data_size];
buffer->width = width;
cairo_surface_t *surf = cairo_image_surface_create_for_data(buffer->buffer, format,
diff --git a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx
index 42de33854..1f20d69ef 100644
--- a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx
@@ -33,9 +33,9 @@ Fl_Wayland_Image_Surface_Driver::Fl_Wayland_Image_Surface_Driver(int w, int h, i
h = int(h * d);
}
struct fl_wld_draw_buffer *off_ = (struct fl_wld_draw_buffer*)calloc(1, sizeof(struct fl_wld_draw_buffer));
- off_->stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, w);
offscreen = (Fl_Offscreen)off_;
- Fl_Wayland_Graphics_Driver::cairo_init(off_, w, h, off_->stride, CAIRO_FORMAT_RGB24);
+ Fl_Wayland_Graphics_Driver::cairo_init(off_, w, h,
+ cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, w), CAIRO_FORMAT_RGB24);
}
driver(new Fl_Wayland_Graphics_Driver());
if (d != 1 && high_res) driver()->scale(d);
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 764a4e8df..204a058ca 100644
--- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -1495,9 +1495,13 @@ void Fl_Wayland_Screen_Driver::get_system_colors()
Fl_RGB_Image *Fl_Wayland_Screen_Driver::read_win_rectangle(int X, int Y, int w, int h, Fl_Window *win,
bool ignore, bool *p_ignore) {
struct wld_window* xid = win ? fl_wl_xid(win) : NULL;
- struct fl_wld_draw_buffer *buffer = win ? &xid->buffer->draw_buffer :
- (struct fl_wld_draw_buffer *)
- (((Fl_Image_Surface*)Fl_Surface_Device::surface())->offscreen());//to check
+ if (win && (!xid || !xid->buffer)) return NULL;
+ struct fl_wld_draw_buffer *buffer;
+ if (win) buffer = &xid->buffer->draw_buffer;
+ else {
+ Fl_Image_Surface_Driver *dr = (Fl_Image_Surface_Driver*)Fl_Surface_Device::surface();
+ buffer = (struct fl_wld_draw_buffer *)dr->image_surface()->offscreen();
+ }
float s = win ?
Fl_Wayland_Window_Driver::driver(win)->wld_scale() * scale(win->screen_num()) :
Fl_Surface_Device::surface()->driver()->scale();