forked from AuroraMiddleware/gtk
Make set_cairo_surface_size a vfunc on GdkWindowImpl
Note the special implementation of this method on GdkOffscreenWindow that makes sure its current surface is not destroyed.
This commit is contained in:
parent
a472d1a400
commit
eca2af5230
@ -495,10 +495,6 @@ void _gdk_display_pointer_info_foreach (GdkDisplay *display,
|
||||
void _gdk_window_invalidate_for_expose (GdkWindow *window,
|
||||
cairo_region_t *region);
|
||||
|
||||
gboolean _gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
|
||||
int x, int y);
|
||||
GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
|
||||
|
@ -597,6 +597,18 @@ gdk_offscreen_window_translate (GdkWindow *window,
|
||||
_gdk_window_add_damage (window, area);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_offscreen_window_resize_cairo_surface (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
/* No-op. The surface gets resized in
|
||||
* gdk_offscreen_window_move_resize_internal().
|
||||
*/
|
||||
return surface;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_offscreen_window_set_embedder:
|
||||
* @window: a #GdkWindow
|
||||
@ -700,4 +712,5 @@ gdk_offscreen_window_impl_iface_init (GdkWindowImplIface *iface)
|
||||
iface->get_root_coords = gdk_offscreen_window_get_root_coords;
|
||||
iface->get_device_state = gdk_offscreen_window_get_device_state;
|
||||
iface->destroy = gdk_offscreen_window_destroy;
|
||||
iface->resize_cairo_surface = gdk_offscreen_window_resize_cairo_surface;
|
||||
}
|
||||
|
@ -1018,14 +1018,17 @@ recompute_visible_regions_internal (GdkWindowObject *private,
|
||||
recompute_visible_regions_internal (private->parent, TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
if (private->cairo_surface &&
|
||||
(!gdk_window_has_impl (private) ||
|
||||
!_gdk_windowing_set_cairo_surface_size (private->cairo_surface,
|
||||
private->width,
|
||||
private->height)))
|
||||
if (private->cairo_surface && gdk_window_has_impl (private))
|
||||
{
|
||||
gdk_window_drop_cairo_surface (private);
|
||||
GdkWindowImplIface *iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl);
|
||||
|
||||
private->cairo_surface = iface->resize_cairo_surface (private->impl,
|
||||
private->cairo_surface,
|
||||
private->width,
|
||||
private->height);
|
||||
}
|
||||
else if (private->cairo_surface)
|
||||
gdk_window_drop_cairo_surface (private);
|
||||
}
|
||||
|
||||
/* Call this when private has changed in one or more of these ways:
|
||||
|
@ -141,6 +141,11 @@ struct _GdkWindowImplIface
|
||||
void (* destroy) (GdkWindow *window,
|
||||
gboolean recursing,
|
||||
gboolean foreign_destroy);
|
||||
|
||||
cairo_surface_t * (* resize_cairo_surface) (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height);
|
||||
};
|
||||
|
||||
/* Interface Functions */
|
||||
|
@ -32,15 +32,6 @@ typedef struct {
|
||||
CGContextRef cg_context;
|
||||
} GdkQuartzCairoSurfaceData;
|
||||
|
||||
gboolean
|
||||
_gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
/* This is not supported with quartz surfaces. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_quartz_cairo_surface_destroy (void *data)
|
||||
{
|
||||
|
@ -1086,6 +1086,18 @@ _gdk_quartz_window_destroy (GdkWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_windowing_window_destroy_foreign (GdkWindow *window)
|
||||
{
|
||||
@ -2986,6 +2998,7 @@ gdk_window_impl_iface_init (GdkWindowImplIface *iface)
|
||||
iface->queue_antiexpose = _gdk_quartz_window_queue_antiexpose;
|
||||
iface->translate = _gdk_quartz_window_translate;
|
||||
iface->destroy = _gdk_quartz_window_destroy;
|
||||
iface->resize_cairo_surface = gdk_window_quartz_resize_cairo_surface;
|
||||
}
|
||||
|
||||
|
||||
|
@ -228,15 +228,6 @@ gdk_win32_ref_cairo_surface (GdkDrawable *drawable)
|
||||
return impl->cairo_surface;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
// Do nothing. The surface size is determined by the DC
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HGDIOBJ
|
||||
gdk_win32_drawable_get_handle (GdkDrawable *drawable)
|
||||
{
|
||||
|
@ -744,6 +744,18 @@ _gdk_win32_window_destroy (GdkWindow *window,
|
||||
gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_windowing_window_destroy_foreign (GdkWindow *window)
|
||||
{
|
||||
@ -3299,6 +3311,7 @@ gdk_window_impl_iface_init (GdkWindowImplIface *iface)
|
||||
iface->queue_antiexpose = _gdk_win32_window_queue_antiexpose;
|
||||
iface->translate = _gdk_win32_window_translate;
|
||||
iface->destroy = _gdk_win32_window_destroy;
|
||||
iface->resize_cairo_surface = gdk_win32_window_resize_cairo_surface;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -194,15 +194,6 @@ gdk_x11_cairo_surface_destroy (void *data)
|
||||
impl->cairo_surface = NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_xlib_surface_set_size (surface, width, height);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_x11_create_cairo_surface (GdkDrawable *drawable,
|
||||
int width,
|
||||
|
@ -1028,6 +1028,17 @@ _gdk_x11_window_destroy (GdkWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_window_x11_resize_cairo_surface (GdkWindow *window,
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
cairo_xlib_surface_set_size (surface, width, height);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_windowing_window_destroy_foreign (GdkWindow *window)
|
||||
{
|
||||
@ -5514,6 +5525,7 @@ gdk_window_impl_iface_init (GdkWindowImplIface *iface)
|
||||
iface->queue_antiexpose = _gdk_x11_window_queue_antiexpose;
|
||||
iface->translate = _gdk_x11_window_translate;
|
||||
iface->destroy = _gdk_x11_window_destroy;
|
||||
iface->resize_cairo_surface = gdk_window_x11_resize_cairo_surface;
|
||||
}
|
||||
|
||||
static Bool
|
||||
|
Loading…
Reference in New Issue
Block a user