Mercurial > dwindows
comparison gtk4/dw.c @ 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 | d7688c3ec43f |
children | b3efaae95735 |
comparison
equal
deleted
inserted
replaced
2364:9ae60d8f4ea3 | 2365:77686ad495ba |
---|---|
833 cairo_t *_dw_cairo_update(GtkWidget *widget, int width, int height) | 833 cairo_t *_dw_cairo_update(GtkWidget *widget, int width, int height) |
834 { | 834 { |
835 cairo_t *wincr = g_object_get_data(G_OBJECT(widget), "_dw_cr"); | 835 cairo_t *wincr = g_object_get_data(G_OBJECT(widget), "_dw_cr"); |
836 cairo_surface_t *surface = g_object_get_data(G_OBJECT(widget), "_dw_cr_surface"); | 836 cairo_surface_t *surface = g_object_get_data(G_OBJECT(widget), "_dw_cr_surface"); |
837 | 837 |
838 if(width == -1 && height == -1 && g_list_find(_dw_dirty_list, widget) == NULL) | 838 if(width == -1 && height == -1 && !wincr && g_list_find(_dw_dirty_list, widget) == NULL) |
839 _dw_dirty_list = g_list_append(_dw_dirty_list, widget); | 839 _dw_dirty_list = g_list_append(_dw_dirty_list, widget); |
840 | 840 |
841 if(width == -1) | 841 if(width == -1) |
842 width = gtk_widget_get_width(widget); | 842 width = gtk_widget_get_width(widget); |
843 if(height == -1) | 843 if(height == -1) |
852 /* Save the cairo context for use in the drawing functions */ | 852 /* Save the cairo context for use in the drawing functions */ |
853 g_object_set_data(G_OBJECT(widget), "_dw_cr_surface", (gpointer)surface); | 853 g_object_set_data(G_OBJECT(widget), "_dw_cr_surface", (gpointer)surface); |
854 g_object_set_data(G_OBJECT(widget), "_dw_width", GINT_TO_POINTER(width)); | 854 g_object_set_data(G_OBJECT(widget), "_dw_width", GINT_TO_POINTER(width)); |
855 g_object_set_data(G_OBJECT(widget), "_dw_height", GINT_TO_POINTER(height)); | 855 g_object_set_data(G_OBJECT(widget), "_dw_height", GINT_TO_POINTER(height)); |
856 } | 856 } |
857 #ifdef DW_USE_CACHED_CR | |
857 return wincr; | 858 return wincr; |
859 #else | |
860 return NULL; | |
861 #endif | |
858 } | 862 } |
859 | 863 |
860 static gint _dw_expose_event(GtkWidget *widget, cairo_t *cr, int width, int height, gpointer data) | 864 static gint _dw_expose_event(GtkWidget *widget, cairo_t *cr, int width, int height, gpointer data) |
861 { | 865 { |
862 int retval = FALSE; | 866 int retval = FALSE; |
865 { | 869 { |
866 DWExpose exp; | 870 DWExpose exp; |
867 int (*exposefunc)(HWND, DWExpose *, void *) = g_object_get_data(G_OBJECT(widget), "_dw_expose_func"); | 871 int (*exposefunc)(HWND, DWExpose *, void *) = g_object_get_data(G_OBJECT(widget), "_dw_expose_func"); |
868 | 872 |
869 _dw_cairo_update(widget, width, height); | 873 _dw_cairo_update(widget, width, height); |
874 | |
875 /* Remove the currently drawn widget from the dirty list */ | |
876 _dw_dirty_list = g_list_remove(_dw_dirty_list, widget); | |
870 | 877 |
871 exp.x = exp.y = 0; | 878 exp.x = exp.y = 0; |
872 exp.width = width; | 879 exp.width = width; |
873 exp.height = height; | 880 exp.height = height; |
874 #ifdef DW_USE_CACHED_CR | |
875 g_object_set_data(G_OBJECT(widget), "_dw_cr", (gpointer)cr); | 881 g_object_set_data(G_OBJECT(widget), "_dw_cr", (gpointer)cr); |
876 #endif | |
877 retval = exposefunc((HWND)widget, &exp, data); | 882 retval = exposefunc((HWND)widget, &exp, data); |
878 #ifdef DW_USE_CACHED_CR | |
879 g_object_set_data(G_OBJECT(widget), "_dw_cr", NULL); | 883 g_object_set_data(G_OBJECT(widget), "_dw_cr", NULL); |
880 #endif | |
881 | |
882 /* Remove the currently drawn widget from the dirty list */ | |
883 _dw_dirty_list = g_list_remove(_dw_dirty_list, widget); | |
884 | 884 |
885 /* Copy the cached image to the output surface */ | 885 /* Copy the cached image to the output surface */ |
886 cairo_set_source_surface(cr, g_object_get_data(G_OBJECT(widget), "_dw_cr_surface"), 0, 0); | 886 cairo_set_source_surface(cr, g_object_get_data(G_OBJECT(widget), "_dw_cr_surface"), 0, 0); |
887 cairo_rectangle(cr, 0, 0, width, height); | 887 cairo_rectangle(cr, 0, 0, width, height); |
888 cairo_fill(cr); | 888 cairo_fill(cr); |