Gdk: fix wrong user_data handling in resize_cairo_surface()

Instead of destroying the surface in the backend if this is
unable to resize, let the core code do it, and do it properly.

Based on a patch by Benjamin Otte.

https://bugzilla.gnome.org/show_bug.cgi?id=725172
This commit is contained in:
Giovanni Campagna 2014-02-26 00:02:04 +01:00
parent d5196ded2f
commit ad2f96ff48
8 changed files with 29 additions and 31 deletions

View File

@ -365,16 +365,14 @@ _gdk_broadway_window_destroy (GdkWindow *window,
impl->id);
}
static cairo_surface_t *
static gboolean
gdk_window_broadway_resize_cairo_surface (GdkWindow *window,
cairo_surface_t *surface,
gint width,
gint height)
{
/* Image surfaces cannot be resized */
cairo_surface_destroy (surface);
return NULL;
return FALSE;
}
static void

View File

@ -550,7 +550,7 @@ gdk_offscreen_window_queue_antiexpose (GdkWindow *window,
return FALSE;
}
static cairo_surface_t *
static gboolean
gdk_offscreen_window_resize_cairo_surface (GdkWindow *window,
cairo_surface_t *surface,
gint width,
@ -559,7 +559,7 @@ gdk_offscreen_window_resize_cairo_surface (GdkWindow *window,
/* No-op. The surface gets resized in
* gdk_offscreen_window_move_resize_internal().
*/
return surface;
return TRUE;
}
/**

View File

@ -1003,17 +1003,17 @@ recompute_visible_regions_internal (GdkWindow *private,
}
}
if (private->cairo_surface && gdk_window_has_impl (private))
if (private->cairo_surface)
{
GdkWindowImplClass *iface = GDK_WINDOW_IMPL_GET_CLASS (private->impl);
private->cairo_surface = iface->resize_cairo_surface (private,
if (!gdk_window_has_impl (private) ||
!GDK_WINDOW_IMPL_GET_CLASS (private->impl)->resize_cairo_surface (private,
private->cairo_surface,
private->width,
private->height);
}
else if (private->cairo_surface)
private->height))
{
gdk_window_drop_cairo_surface (private);
}
}
}
/* Call this when private has changed in one or more of these ways:

View File

@ -158,7 +158,11 @@ struct _GdkWindowImplClass
*/
void (*destroy_foreign) (GdkWindow *window);
cairo_surface_t * (* resize_cairo_surface) (GdkWindow *window,
/* Resizes @surface to a new size. If successful, return %TRUE.
* If the backend cannot resize surfaces, return %FALSE and a new
* surface will be created instead.
*/
gboolean (* resize_cairo_surface) (GdkWindow *window,
cairo_surface_t *surface,
gint width,
gint height);

View File

@ -1104,16 +1104,14 @@ gdk_quartz_window_destroy (GdkWindow *window,
}
}
static cairo_surface_t *
static gboolean
gdk_window_quartz_resize_cairo_surface (GdkWindow *window,
cairo_surface_t *surface,
gint width,
gint height)
{
/* Quartz surfaces cannot be resized */
cairo_surface_destroy (surface);
return NULL;
return FALSE;
}
static void

View File

@ -1481,14 +1481,14 @@ gdk_window_wayland_destroy_foreign (GdkWindow *window)
{
}
static cairo_surface_t *
static gboolean
gdk_window_wayland_resize_cairo_surface (GdkWindow *window,
cairo_surface_t *surface,
gint width,
gint height)
{
/* cairo image surfaces cannot be resized */
return NULL;
return FALSE;
}
static cairo_region_t *

View File

@ -796,16 +796,14 @@ gdk_win32_window_destroy (GdkWindow *window,
}
}
static cairo_surface_t *
static gboolean
gdk_win32_window_resize_cairo_surface (GdkWindow *window,
cairo_surface_t *surface,
gint width,
gint height)
{
/* XXX: Make Cairo surface use DC clip */
cairo_surface_destroy (surface);
return NULL;
return FALSE;
}
static void

View File

@ -1337,7 +1337,7 @@ gdk_x11_window_destroy (GdkWindow *window,
XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
}
static cairo_surface_t *
static gboolean
gdk_window_x11_resize_cairo_surface (GdkWindow *window,
cairo_surface_t *surface,
gint width,
@ -1345,7 +1345,7 @@ gdk_window_x11_resize_cairo_surface (GdkWindow *window,
{
cairo_xlib_surface_set_size (surface, width, height);
return surface;
return TRUE;
}
static void