Mercurial > dwindows
changeset 2365:77686ad495ba
GTK3/4: Optimizing dirty list management. Keep list as short as possible.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 12 Mar 2021 22:53:41 +0000 |
parents | 9ae60d8f4ea3 |
children | b3efaae95735 |
files | gtk3/dw.c gtk4/dw.c |
diffstat | 2 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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);