forked from AuroraMiddleware/gtk
surface: Remove queue_antiexpose()
... and its implementation in the X11 backend. GDK does lots of work trying to reduce the region in expose events so that when the server sends multiple expose events, touching the same area we can make sure to only redraw stuff once. However: (1) this is only relevant of there's tons of delay and multiple expose events get sent (2) we coalesce multiple events into a single expose event anyway (3) we do this on the frame clock But most importantly: (4) Since the invention of compositing, servers caches all contents anyway
This commit is contained in:
parent
63edf43e86
commit
c4ecc3f4f7
@ -2415,9 +2415,6 @@ gdk_surface_process_updates_internal (GdkSurface *surface)
|
||||
/* Clip to part visible in impl surface */
|
||||
cairo_region_intersect (expose_region, surface->clip_region);
|
||||
|
||||
if (impl_class->queue_antiexpose)
|
||||
impl_class->queue_antiexpose (surface, expose_region);
|
||||
|
||||
impl_class->process_updates_recurse (surface, expose_region);
|
||||
|
||||
gdk_surface_append_old_updated_area (surface, surface->active_update_area);
|
||||
|
@ -112,13 +112,6 @@ struct _GdkSurfaceImplClass
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
|
||||
/* Called before processing updates for a surface. This gives the windowing
|
||||
* layer a chance to save the region for later use in avoiding duplicate
|
||||
* exposes.
|
||||
*/
|
||||
void (* queue_antiexpose) (GdkSurface *surface,
|
||||
cairo_region_t *update_area);
|
||||
|
||||
/* Called to do the windowing system specific part of gdk_surface_destroy(),
|
||||
*
|
||||
* surface: The window being destroyed
|
||||
|
@ -1966,9 +1966,6 @@ gdk_x11_display_finalize (GObject *object)
|
||||
|
||||
_gdk_x11_cursor_display_finalize (GDK_DISPLAY (display_x11));
|
||||
|
||||
/* Empty the event queue */
|
||||
_gdk_x11_display_free_translate_queue (GDK_DISPLAY (display_x11));
|
||||
|
||||
/* Get rid of pending streams */
|
||||
g_slist_free_full (display_x11->streams, g_object_unref);
|
||||
|
||||
|
@ -105,9 +105,6 @@ struct _GdkX11Display
|
||||
/* X ID hashtable */
|
||||
GHashTable *xid_ht;
|
||||
|
||||
/* translation queue */
|
||||
GQueue *translate_queue;
|
||||
|
||||
/* streams reading selections */
|
||||
GSList *streams;
|
||||
|
||||
|
@ -17,196 +17,15 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkrectangle.h"
|
||||
#include "gdkprivate-x11.h"
|
||||
#include "gdkscreen-x11.h"
|
||||
#include "gdkdisplay-x11.h"
|
||||
#include "gdksurface-x11.h"
|
||||
|
||||
|
||||
typedef struct _GdkSurfaceQueueItem GdkSurfaceQueueItem;
|
||||
typedef struct _GdkSurfaceParentPos GdkSurfaceParentPos;
|
||||
|
||||
struct _GdkSurfaceQueueItem
|
||||
{
|
||||
GdkSurface *surface;
|
||||
gulong serial;
|
||||
cairo_region_t *antiexpose_area;
|
||||
};
|
||||
|
||||
static Bool
|
||||
expose_serial_predicate (Display *xdisplay,
|
||||
XEvent *xev,
|
||||
XPointer arg)
|
||||
{
|
||||
gulong *serial = (gulong *)arg;
|
||||
|
||||
if (xev->xany.type == Expose || xev->xany.type == GraphicsExpose)
|
||||
*serial = MIN (*serial, xev->xany.serial);
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Find oldest possible serial for an outstanding expose event
|
||||
*/
|
||||
static gulong
|
||||
find_current_serial (Display *xdisplay)
|
||||
{
|
||||
XEvent xev;
|
||||
gulong serial = NextRequest (xdisplay);
|
||||
|
||||
XSync (xdisplay, False);
|
||||
|
||||
XCheckIfEvent (xdisplay, &xev, expose_serial_predicate, (XPointer)&serial);
|
||||
|
||||
return serial;
|
||||
}
|
||||
|
||||
static void
|
||||
queue_delete_link (GQueue *queue,
|
||||
GList *link)
|
||||
{
|
||||
if (queue->tail == link)
|
||||
queue->tail = link->prev;
|
||||
|
||||
queue->head = g_list_remove_link (queue->head, link);
|
||||
g_list_free_1 (link);
|
||||
queue->length--;
|
||||
}
|
||||
|
||||
static void
|
||||
queue_item_free (GdkSurfaceQueueItem *item)
|
||||
{
|
||||
if (item->surface)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (item->surface),
|
||||
(gpointer *)&(item->surface));
|
||||
}
|
||||
|
||||
cairo_region_destroy (item->antiexpose_area);
|
||||
g_free (item);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_x11_display_free_translate_queue (GdkDisplay *display)
|
||||
{
|
||||
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
|
||||
|
||||
if (display_x11->translate_queue)
|
||||
{
|
||||
g_queue_foreach (display_x11->translate_queue, (GFunc)queue_item_free, NULL);
|
||||
g_queue_free (display_x11->translate_queue);
|
||||
display_x11->translate_queue = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_queue (GdkSurface *surface,
|
||||
GdkSurfaceQueueItem *new_item)
|
||||
{
|
||||
GdkX11Display *display_x11 = GDK_X11_DISPLAY (GDK_SURFACE_DISPLAY (surface));
|
||||
|
||||
if (!display_x11->translate_queue)
|
||||
display_x11->translate_queue = g_queue_new ();
|
||||
|
||||
/* Keep length of queue finite by, if it grows too long,
|
||||
* figuring out the latest relevant serial and discarding
|
||||
* irrelevant queue items.
|
||||
*/
|
||||
if (display_x11->translate_queue->length >= 64)
|
||||
{
|
||||
gulong serial = find_current_serial (GDK_SURFACE_XDISPLAY (surface));
|
||||
GList *tmp_list = display_x11->translate_queue->head;
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
GdkSurfaceQueueItem *item = tmp_list->data;
|
||||
GList *next = tmp_list->next;
|
||||
|
||||
/* an overflow-safe (item->serial < serial) */
|
||||
if (item->serial - serial > (gulong) G_MAXLONG)
|
||||
{
|
||||
queue_delete_link (display_x11->translate_queue, tmp_list);
|
||||
queue_item_free (item);
|
||||
}
|
||||
|
||||
tmp_list = next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Catch the case where someone isn't processing events and there
|
||||
* is an event stuck in the event queue with an old serial:
|
||||
* If we can't reduce the queue length by the above method,
|
||||
* discard anti-expose items. (We can't discard translate
|
||||
* items
|
||||
*/
|
||||
if (display_x11->translate_queue->length >= 64)
|
||||
{
|
||||
GList *tmp_list = display_x11->translate_queue->head;
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
GdkSurfaceQueueItem *item = tmp_list->data;
|
||||
GList *next = tmp_list->next;
|
||||
|
||||
queue_delete_link (display_x11->translate_queue, tmp_list);
|
||||
queue_item_free (item);
|
||||
|
||||
tmp_list = next;
|
||||
}
|
||||
}
|
||||
|
||||
new_item->surface = surface;
|
||||
new_item->serial = NextRequest (GDK_SURFACE_XDISPLAY (surface));
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (surface),
|
||||
(gpointer *)&(new_item->surface));
|
||||
|
||||
g_queue_push_tail (display_x11->translate_queue, new_item);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_x11_surface_queue_antiexpose (GdkSurface *surface,
|
||||
cairo_region_t *area)
|
||||
{
|
||||
GdkSurfaceQueueItem *item = g_new (GdkSurfaceQueueItem, 1);
|
||||
item->antiexpose_area = cairo_region_reference (area);
|
||||
|
||||
gdk_surface_queue (surface, item);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_x11_surface_process_expose (GdkSurface *surface,
|
||||
gulong serial,
|
||||
GdkRectangle *area)
|
||||
{
|
||||
cairo_region_t *invalidate_region = cairo_region_create_rectangle (area);
|
||||
GdkX11Display *display_x11 = GDK_X11_DISPLAY (GDK_SURFACE_DISPLAY (surface));
|
||||
|
||||
if (display_x11->translate_queue)
|
||||
{
|
||||
GList *tmp_list = display_x11->translate_queue->head;
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
GdkSurfaceQueueItem *item = tmp_list->data;
|
||||
GList *next = tmp_list->next;
|
||||
|
||||
/* an overflow-safe (serial < item->serial) */
|
||||
if (serial - item->serial > (gulong) G_MAXLONG)
|
||||
{
|
||||
if (item->surface == surface)
|
||||
cairo_region_subtract (invalidate_region, item->antiexpose_area);
|
||||
}
|
||||
else
|
||||
{
|
||||
queue_delete_link (display_x11->translate_queue, tmp_list);
|
||||
queue_item_free (item);
|
||||
}
|
||||
tmp_list = next;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cairo_region_is_empty (invalidate_region))
|
||||
_gdk_surface_invalidate_for_expose (surface, invalidate_region);
|
||||
|
@ -83,15 +83,6 @@ void _gdk_x11_surface_process_expose (GdkSurface *window,
|
||||
gulong serial,
|
||||
GdkRectangle *area);
|
||||
|
||||
void _gdk_x11_surface_queue_antiexpose (GdkSurface *window,
|
||||
cairo_region_t *area);
|
||||
void _gdk_x11_surface_translate (GdkSurface *window,
|
||||
cairo_region_t *area,
|
||||
gint dx,
|
||||
gint dy);
|
||||
|
||||
void _gdk_x11_display_free_translate_queue (GdkDisplay *display);
|
||||
|
||||
cairo_region_t* _gdk_x11_xwindow_get_shape (Display *xdisplay,
|
||||
Window window,
|
||||
gint scale,
|
||||
|
@ -4894,7 +4894,6 @@ gdk_surface_impl_x11_class_init (GdkSurfaceImplX11Class *klass)
|
||||
impl_class->get_device_state = gdk_surface_x11_get_device_state;
|
||||
impl_class->shape_combine_region = gdk_surface_x11_shape_combine_region;
|
||||
impl_class->input_shape_combine_region = gdk_surface_x11_input_shape_combine_region;
|
||||
impl_class->queue_antiexpose = _gdk_x11_surface_queue_antiexpose;
|
||||
impl_class->destroy = gdk_x11_surface_destroy;
|
||||
impl_class->beep = gdk_x11_surface_beep;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user