ref: 35db73220cc614150f56c2777ed611a0a2524665
parent: 98d2701c58f805861e22a0a3c03e7ad984abb96e
author: David Turner <[email protected]>
date: Thu Aug 24 08:39:40 EDT 2000
- 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 !!
--- 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:
--- 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)
--- 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;
--- 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;
--- 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. */
--- 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. */
--- 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. */