diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-03-06 15:13:56 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-03-25 18:42:08 +0900 |
commit | 38b5c8cf45e53ced9fd617332cdaf3a87601d451 (patch) | |
tree | 9855e9adbbc7661af342af43c26964dcfa8a2d63 /gtk/gtkwidgetprivate.h | |
parent | 82ae7b77cafad6c9370eb2d6ec56b14731147928 (diff) | |
download | gtk+-38b5c8cf45e53ced9fd617332cdaf3a87601d451.tar.gz |
Cache heights-for-range-of-widths instead of height for every width.
This patch optimizes window resizes by assuming that if a widget
has the same height at a width of 50 as with a width of 150, the
height for width 100 will also be the same.
The patch also further optimizes the cache allocator, now there
are 2 pointer arrays of up to a maximum of 5 requests, the arrays
will only be allocated if a request is ever made in that orientation
and the array will be sparse until each request is made (i.e. if a
label can only wrap to 3 lines, there will only be 3 out of a
possible 5 SizeRequest structures allocated to cache it).
Diffstat (limited to 'gtk/gtkwidgetprivate.h')
-rw-r--r-- | gtk/gtkwidgetprivate.h | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 9dfec658e2..7d298c6471 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -29,12 +29,13 @@ G_BEGIN_DECLS -/* With GtkWidget, a widget may be requested - * its width for 2 or maximum 3 heights in one resize - * (Note this define is limited by the bitfield sizes - * defined on the SizeRequestCache structure). +/* Cache as many ranges of height-for-width + * (or width-for-height) as can be rational + * for a said widget to have, if a label can + * only wrap to 3 lines, only 3 caches will + * ever be allocated for it. */ -#define GTK_SIZE_REQUEST_CACHED_SIZES (2) +#define GTK_SIZE_REQUEST_CACHED_SIZES (5) typedef struct { gint minimum_size; @@ -43,26 +44,24 @@ typedef struct { typedef struct { - /* the size this request is for */ - gint for_size; + gint lower_for_size; /* The minimum for_size with the same result */ + gint upper_for_size; /* The maximum for_size with the same result */ CachedSize cached_size; } SizeRequest; typedef struct { - SizeRequest widths[GTK_SIZE_REQUEST_CACHED_SIZES]; - SizeRequest heights[GTK_SIZE_REQUEST_CACHED_SIZES]; - - guint cached_widths : 2; - guint cached_heights : 2; - guint last_cached_width : 2; - guint last_cached_height : 2; -} ContextualSizes; - -typedef struct { - ContextualSizes *sizes; - - CachedSize cached_width; - CachedSize cached_height; + SizeRequest **widths; + SizeRequest **heights; + + CachedSize cached_width; + CachedSize cached_height; + + guint cached_widths : 3; + guint cached_heights : 3; + guint last_cached_width : 3; + guint last_cached_height : 3; + guint cached_base_width : 1; + guint cached_base_height : 1; } SizeRequestCache; void _gtk_widget_set_visible_flag (GtkWidget *widget, @@ -114,6 +113,7 @@ gboolean _gtk_widget_get_translation_to_window (GtkWidget *widget, GdkWindow *window, int *x, int *y); +void _gtk_widget_free_cached_sizes (GtkWidget *widget); G_END_DECLS |