# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1615589621 0 # Node ID 77686ad495bacf4a9f2a6aa83eb46fbc67cf3eab # Parent 9ae60d8f4ea32cb2a56e4d4f2b9f1f32f762c8a9 GTK3/4: Optimizing dirty list management. Keep list as short as possible. diff -r 9ae60d8f4ea3 -r 77686ad495ba gtk3/dw.c --- a/gtk3/dw.c Fri Mar 12 22:07:33 2021 +0000 +++ b/gtk3/dw.c Fri Mar 12 22:53:41 2021 +0000 @@ -1510,6 +1510,9 @@ DWExpose exp; int (*exposefunc)(HWND, DWExpose *, void *) = work.func; + /* Remove the currently drawn widget from the dirty list */ + _dw_dirty_list = g_list_remove(_dw_dirty_list, widget); + exp.x = exp.y = 0; exp.width = gtk_widget_get_allocated_width(widget); exp.height = gtk_widget_get_allocated_height(widget); diff -r 9ae60d8f4ea3 -r 77686ad495ba gtk4/dw.c --- a/gtk4/dw.c Fri Mar 12 22:07:33 2021 +0000 +++ b/gtk4/dw.c Fri Mar 12 22:53:41 2021 +0000 @@ -835,7 +835,7 @@ cairo_t *wincr = g_object_get_data(G_OBJECT(widget), "_dw_cr"); cairo_surface_t *surface = g_object_get_data(G_OBJECT(widget), "_dw_cr_surface"); - if(width == -1 && height == -1 && g_list_find(_dw_dirty_list, widget) == NULL) + if(width == -1 && height == -1 && !wincr && g_list_find(_dw_dirty_list, widget) == NULL) _dw_dirty_list = g_list_append(_dw_dirty_list, widget); if(width == -1) @@ -854,7 +854,11 @@ g_object_set_data(G_OBJECT(widget), "_dw_width", GINT_TO_POINTER(width)); g_object_set_data(G_OBJECT(widget), "_dw_height", GINT_TO_POINTER(height)); } +#ifdef DW_USE_CACHED_CR return wincr; +#else + return NULL; +#endif } static gint _dw_expose_event(GtkWidget *widget, cairo_t *cr, int width, int height, gpointer data) @@ -868,19 +872,15 @@ _dw_cairo_update(widget, width, height); + /* Remove the currently drawn widget from the dirty list */ + _dw_dirty_list = g_list_remove(_dw_dirty_list, widget); + exp.x = exp.y = 0; exp.width = width; exp.height = height; -#ifdef DW_USE_CACHED_CR g_object_set_data(G_OBJECT(widget), "_dw_cr", (gpointer)cr); -#endif retval = exposefunc((HWND)widget, &exp, data); -#ifdef DW_USE_CACHED_CR g_object_set_data(G_OBJECT(widget), "_dw_cr", NULL); -#endif - - /* Remove the currently drawn widget from the dirty list */ - _dw_dirty_list = g_list_remove(_dw_dirty_list, widget); /* Copy the cached image to the output surface */ cairo_set_source_surface(cr, g_object_get_data(G_OBJECT(widget), "_dw_cr_surface"), 0, 0);