Commit 83c5e354 authored by Alexander Larsson's avatar Alexander Larsson

wayland: Add custom create_similar_image implementation

The fallback method is used on other backends, but it caused
problems for wayland when it tried to create a surface for
the root window.
parent eac7dce1
......@@ -9316,6 +9316,7 @@ gdk_window_create_similar_image_surface (GdkWindow * window,
int height,
int scale)
{
GdkWindowImplClass *impl_class;
cairo_surface_t *window_surface, *surface;
GdkDisplay *display;
GdkScreen *screen;
......@@ -9329,17 +9330,23 @@ gdk_window_create_similar_image_surface (GdkWindow * window,
window = gdk_screen_get_root_window (screen);
}
window_surface = gdk_window_ref_impl_surface (window);
if (scale == 0)
scale = gdk_window_get_scale_factor (window);
surface =
cairo_surface_create_similar_image (window_surface,
format,
width,
height);
impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
cairo_surface_destroy (window_surface);
if (impl_class->create_similar_image_surface)
surface = impl_class->create_similar_image_surface (window, format, width, height);
else
{
window_surface = gdk_window_ref_impl_surface (window);
surface =
cairo_surface_create_similar_image (window_surface,
format,
width,
height);
cairo_surface_destroy (window_surface);
}
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_set_device_scale (surface, scale, scale);
......
......@@ -51,6 +51,11 @@ struct _GdkWindowImplClass
cairo_surface_t *
(* ref_cairo_surface) (GdkWindow *window);
cairo_surface_t *
(* create_similar_image_surface) (GdkWindow * window,
cairo_format_t format,
int width,
int height);
void (* show) (GdkWindow *window,
gboolean already_mapped);
......
......@@ -746,6 +746,14 @@ gdk_wayland_window_ref_cairo_surface (GdkWindow *window)
return impl->cairo_surface;
}
static cairo_surface_t *
gdk_wayland_window_create_similar_image_surface (GdkWindow * window,
cairo_format_t format,
int width,
int height)
{
return cairo_image_surface_create (format, width, height);
}
static gboolean
gdk_window_impl_wayland_begin_paint_region (GdkWindow *window,
......@@ -1989,6 +1997,7 @@ _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
object_class->finalize = gdk_window_impl_wayland_finalize;
impl_class->ref_cairo_surface = gdk_wayland_window_ref_cairo_surface;
impl_class->create_similar_image_surface = gdk_wayland_window_create_similar_image_surface;
impl_class->show = gdk_wayland_window_show;
impl_class->hide = gdk_wayland_window_hide;
impl_class->withdraw = gdk_window_wayland_withdraw;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment