From 1724ba284839063e195e365664db118e92667dda Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 24 Aug 2000 12:39:40 +0000 Subject: [PATCH] - fixed an horrible FT_LOAD_RENDER bug that returned empty bitmaps !! - tested and fixed the image cache object. I'm performing a few more checks though, and we'll call the cache sub-system completed !! --- src/base/ftobjs.c | 45 +++++++++++++++++++++++--------------------- src/cache/ftcimage.c | 28 ++++++++++++++++++--------- src/cache/ftcimage.h | 6 ++++-- src/cache/ftcmanag.c | 4 ++-- src/cache/ftcmanag.h | 2 +- src/cache/ftlru.c | 2 +- src/cache/ftlru.h | 2 +- 7 files changed, 52 insertions(+), 37 deletions(-) diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index a9c9344d7..582a0a562 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1019,31 +1019,34 @@ slot->advance.y = 0; } - /* now, transform the glyph image when needed */ - if ( face->transform_flags && !( load_flags & FT_LOAD_NO_RECURSE ) ) + if ((load_flags & FT_LOAD_NO_RECURSE)==0) { - /* get renderer */ - FT_Renderer renderer = ft_lookup_glyph_renderer( slot ); + /* now, transform the glyph image when needed */ + if ( face->transform_flags ) + { + /* get renderer */ + FT_Renderer renderer = ft_lookup_glyph_renderer( slot ); - if ( renderer ) - error = renderer->clazz->transform_glyph( renderer, slot, - &face->transform_matrix, - &face->transform_delta ); - /* transform advance */ - FT_Vector_Transform( &slot->advance, &face->transform_matrix ); - } + if ( renderer ) + error = renderer->clazz->transform_glyph( renderer, slot, + &face->transform_matrix, + &face->transform_delta ); + /* transform advance */ + FT_Vector_Transform( &slot->advance, &face->transform_matrix ); + } - /* do we need to render the image now? */ - if ( !error && - slot->format != ft_glyph_format_bitmap && - slot->format != ft_glyph_format_composite && - load_flags & FT_LOAD_RENDER ) - { - error = FT_Render_Glyph( slot, - ( load_flags & FT_LOAD_MONOCHROME ) - ? ft_render_mode_mono - : ft_render_mode_normal ); + /* do we need to render the image now? */ + if ( !error && + slot->format != ft_glyph_format_bitmap && + slot->format != ft_glyph_format_composite && + load_flags & FT_LOAD_RENDER ) + { + error = FT_Render_Glyph( slot, + ( load_flags & FT_LOAD_MONOCHROME ) + ? ft_render_mode_mono + : ft_render_mode_normal ); + } } Exit: diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c index 217b11cea..a27ed3345 100644 --- a/src/cache/ftcimage.c +++ b/src/cache/ftcimage.c @@ -2,7 +2,7 @@ /* */ /* ftcimage.c */ /* */ -/* XXX */ +/* FreeType Image Cache */ /* */ /* Copyright 2000 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ @@ -448,6 +448,9 @@ error = FTC_ImageNode_New( queue->cache, &inode ); if (error) goto Exit; + + /* set the glyph and queue indices in the image node */ + FTC_IMAGENODE_SET_INDICES( inode, glyph_index, queue->index ); error = queue->clazz->init_image( queue, inode ); if (error) @@ -456,9 +459,6 @@ goto Exit; } - /* set the glyph and queue indices in the image node */ - FTC_IMAGENODE_SET_INDICES( inode, glyph_index, queue->index ); - /* insert the node at the start of our bucket list */ FT_List_Insert( bucket, (FT_ListNode)inode ); @@ -606,6 +606,7 @@ goto Exit; cache->manager = manager; + cache->memory = manager->library->memory; cache->max_bytes = max_bytes; error = FT_Lru_New( &ftc_image_queue_lru_class, @@ -653,11 +654,20 @@ FTC_ImageNode inode; *aglyph = 0; - error = FT_Lru_Lookup( cache->queues_lru, - (FT_LruKey)desc, - (FT_Pointer*)&queue ); - if (error) - goto Exit; + queue = cache->last_queue; + if ( !queue || + queue->descriptor.size.face_id != desc->size.face_id || + queue->descriptor.size.pix_width != desc->size.pix_width || + queue->descriptor.size.pix_height != desc->size.pix_height || + queue->descriptor.image_type != desc->image_type ) + { + error = FT_Lru_Lookup( cache->queues_lru, + (FT_LruKey)desc, + (FT_Pointer*)&queue ); + cache->last_queue = queue; + if (error) + goto Exit; + } error = FTC_Image_Queue_Lookup_Node( queue, gindex, &inode ); if (error) diff --git a/src/cache/ftcimage.h b/src/cache/ftcimage.h index 11eb96e5f..5ebc79f4f 100644 --- a/src/cache/ftcimage.h +++ b/src/cache/ftcimage.h @@ -2,7 +2,7 @@ /* */ /* ftcimage.h */ /* */ -/* XXX */ +/* FreeType Image Cache */ /* */ /* Copyright 2000 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ @@ -82,8 +82,10 @@ FT_ULong max_bytes; /* maximum size of cache in bytes */ FT_ULong num_bytes; /* current size of cache in bytes */ - FT_Lru queues_lru; /* static queues lru list */ + FT_Lru queues_lru; /* static queues lru list */ FT_ListRec glyphs_lru; /* global lru list of glyph images */ + + FTC_Image_Queue last_queue; /* small cache */ } FTC_Image_CacheRec; diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c index d0c439990..03ee3b89a 100644 --- a/src/cache/ftcmanag.c +++ b/src/cache/ftcmanag.c @@ -2,7 +2,7 @@ /* */ /* ftcmanag.h */ /* */ -/* XXX */ +/* FreeType Cache Manager */ /* */ /* Copyright 2000 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ @@ -317,7 +317,7 @@ if ( !error ) { /* select the size as the current one for this face */ - face->size = *asize; + face->size = size; if (asize) *asize = size; diff --git a/src/cache/ftcmanag.h b/src/cache/ftcmanag.h index fa28eb668..c2f68afed 100644 --- a/src/cache/ftcmanag.h +++ b/src/cache/ftcmanag.h @@ -2,7 +2,7 @@ /* */ /* ftcmanag.h */ /* */ -/* XXX */ +/* FreeType Cache Manager */ /* */ /* Copyright 2000 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c index 1c1cc61e3..3302bc179 100644 --- a/src/cache/ftlru.c +++ b/src/cache/ftlru.c @@ -2,7 +2,7 @@ /* */ /* ftlru.c */ /* */ -/* XXX */ +/* simple LRU list-cache */ /* */ /* Copyright 2000 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ diff --git a/src/cache/ftlru.h b/src/cache/ftlru.h index 300b72a1d..175136ba6 100644 --- a/src/cache/ftlru.h +++ b/src/cache/ftlru.h @@ -2,7 +2,7 @@ /* */ /* ftlru.h */ /* */ -/* XXX */ +/* simple LRU list-cache */ /* */ /* Copyright 2000 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */