diff options
author | John Harper <jsh@eazel.com> | 2001-03-02 23:58:14 +0000 |
---|---|---|
committer | John Harper <jsh@src.gnome.org> | 2001-03-02 23:58:14 +0000 |
commit | 6ab518bc39438b1abb14022e4c7c225c37cb1025 (patch) | |
tree | 7b493d154ada68ed19a83b6071ec41c84226f0f3 /libnautilus-extensions/nautilus-icon-canvas-item.c | |
parent | 15ebdc1143d9fa561087d83c3e3d782958facf0a (diff) | |
download | nautilus-6ab518bc39438b1abb14022e4c7c225c37cb1025.tar.gz |
reviewed by: Darin Adler <darin@eazel.com>
2001-03-02 John Harper <jsh@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>
Work to cache smooth-text-layout objects. This increases the
speed of aa rendering so that there's no noticeable difference
when compared with non-aa mode (e.g. when dragging windows over
the top of the nautilus window)
* libnautilus-extensions/nautilus-smooth-text-layout-cache.c,
libnautilus-extensions/nautilus-smooth-text-layout-cache.h: new
class, a cache for the NautilusSmoothTextLayout objects
* libnautilus-extensions/nautilus-icon-canvas-item.c
(nautilus_icon_canvas_item_initialize_class): allocate a
NautilusSmoothTextLayoutCache for all canvas items. It will be
freed on program exit
(draw_or_measure_label_text_aa): use the layout cache when
rendering text
* libnautilus-extensions/Makefile.am: added layout cache files
* libnautilus-extensions/nautilus-glyph.c,
libnautilus-extensions/nautilus-glyph.c,
libnautilus-extensions/nautilus-smooth-text-layout.c,
libnautilus-extensions/nautilus-smooth-text-layout.c
(nautilus_glyph_compare, nautilus_smooth_text_layout_compare):
new functions, only defined when NAUTILUS_OMIT_SELF_CHECK isn't
#define'd. Used by the cache's self test code
* libnautilus-extensions/nautilus-lib-self-check-functions.h:
added nautilus_self_check_smooth_text_layout_cache to the list
Diffstat (limited to 'libnautilus-extensions/nautilus-icon-canvas-item.c')
-rw-r--r-- | libnautilus-extensions/nautilus-icon-canvas-item.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/libnautilus-extensions/nautilus-icon-canvas-item.c b/libnautilus-extensions/nautilus-icon-canvas-item.c index 8345fa0fc..399cade1d 100644 --- a/libnautilus-extensions/nautilus-icon-canvas-item.c +++ b/libnautilus-extensions/nautilus-icon-canvas-item.c @@ -52,6 +52,7 @@ #include "nautilus-icon-factory.h" #include "nautilus-theme.h" #include "nautilus-smooth-text-layout.h" +#include "nautilus-smooth-text-layout-cache.h" /* Comment this out if the new smooth fonts code give you problems * This isnt meant to be permanent. Its just a precaution. @@ -222,6 +223,14 @@ static gboolean icon_canvas_item_is_smooth (const NautilusIconCa NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconCanvasItem, nautilus_icon_canvas_item, GNOME_TYPE_CANVAS_ITEM) +static NautilusSmoothTextLayoutCache *layout_cache; + +static void +free_layout_cache (void) +{ + gtk_object_unref (GTK_OBJECT (layout_cache)); +} + /* Class initialization function for the icon canvas item. */ static void nautilus_icon_canvas_item_initialize_class (NautilusIconCanvasItemClass *class) @@ -229,6 +238,11 @@ nautilus_icon_canvas_item_initialize_class (NautilusIconCanvasItemClass *class) GtkObjectClass *object_class; GnomeCanvasItemClass *item_class; + if (layout_cache == NULL) { + layout_cache = nautilus_smooth_text_layout_cache_new (); + g_atexit (free_layout_cache); + } + object_class = GTK_OBJECT_CLASS (class); item_class = GNOME_CANVAS_ITEM_CLASS (class); @@ -1357,7 +1371,7 @@ draw_or_measure_label_text_aa (NautilusIconCanvasItem *item, GnomeCanvasItem *canvas_item; int max_text_width; int icon_width, text_left, box_left; - NautilusSmoothTextLayout *smooth_text_layout; + const NautilusSmoothTextLayout *smooth_text_layout; char **pieces; const char *text_piece; int i; @@ -1449,13 +1463,13 @@ draw_or_measure_label_text_aa (NautilusIconCanvasItem *item, text_piece = " "; } - smooth_text_layout = nautilus_smooth_text_layout_new (text_piece, - strlen (text_piece), - details->smooth_font, - details->smooth_font_size, - TRUE); - nautilus_smooth_text_layout_set_line_spacing (smooth_text_layout, LABEL_LINE_SPACING); - nautilus_smooth_text_layout_set_line_wrap_width (smooth_text_layout, max_text_width); + smooth_text_layout = nautilus_smooth_text_layout_cache_render (layout_cache, + text_piece, + strlen (text_piece), + details->smooth_font, + details->smooth_font_size, + TRUE, LABEL_LINE_SPACING, + max_text_width); /* Draw text if we are not in user rename mode */ if (destination_pixbuf != NULL && !details->is_renaming) { |