changed the FTC_Manager_New function to accept "max_faces" and "max_sizes" parameters fixed some bugs. the cache manager is now tested and validated (now, it's time for the glyph image cache)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
diff --git a/include/freetype/ftcache.h b/include/freetype/ftcache.h
index 37ec8ad..7be5199 100644
--- a/include/freetype/ftcache.h
+++ b/include/freetype/ftcache.h
@@ -154,6 +154,12 @@
* <Input>
* library :: the parent FreeType library handle to use
*
+ * max_faces :: maximum number of faces to keep alive in manager
+ * use 0 for defaults
+ *
+ * max_sizes :: maximum number of sizes to keep alive in manager
+ * use 0 for defaults
+ *
* requester :: an application-provided callback used to translate
* face IDs into real FT_Face objects
*
@@ -169,6 +175,8 @@
**************************************************************************/
FT_EXPORT_DEF( FT_Error ) FTC_Manager_New( FT_Library library,
+ FT_UInt max_faces,
+ FT_UInt max_sizes,
FTC_Face_Requester requester,
FT_Pointer req_data,
FTC_Manager* amanager );
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index 3a9a0d3..d0c4399 100644
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -104,15 +104,17 @@
FTC_SizeRequest* size_req = (FTC_SizeRequest*)node->key;
FT_Size size;
FT_Error error;
+ FT_Face face = size_req->face;
FT_UNUSED( lru );
node->root.data = 0;
- error = FT_New_Size( size_req->face, &size );
+ error = FT_New_Size( face, &size );
if ( !error )
{
- error = FT_Set_Pixel_Sizes( size_req->face,
+ face->size = size;
+ error = FT_Set_Pixel_Sizes( face,
size_req->width,
size_req->height );
if ( error )
@@ -200,6 +202,8 @@
FT_EXPORT_FUNC( FT_Error ) FTC_Manager_New( FT_Library library,
+ FT_UInt max_faces,
+ FT_UInt max_sizes,
FTC_Face_Requester requester,
FT_Pointer req_data,
FTC_Manager* amanager )
@@ -211,9 +215,15 @@
if ( ALLOC( manager, sizeof ( *manager ) ) )
goto Exit;
+
+ if (max_faces == 0)
+ max_faces = FTC_MAX_FACES;
+
+ if (max_sizes == 0)
+ max_sizes = FTC_MAX_SIZES;
error = FT_Lru_New( &ftc_face_lru_class,
- FTC_MAX_FACES,
+ max_faces,
manager,
memory,
1, /* pre_alloc = TRUE */
@@ -222,7 +232,7 @@
goto Exit;
error = FT_Lru_New( &ftc_size_lru_class,
- FTC_MAX_SIZES,
+ max_sizes,
manager,
memory,
1, /* pre_alloc = TRUE */
diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c
index e4e60a9..1c1cc61 100644
--- a/src/cache/ftlru.c
+++ b/src/cache/ftlru.c
@@ -159,6 +159,7 @@
node = lru->elements.tail;
lru_node = (FT_LruNode)node;
+ found = lru_node;
if ( clazz->flush_element )
error = clazz->flush_element( lru, lru_node, key );
@@ -185,6 +186,8 @@
FT_List_Insert( &lru->free_nodes, node );
else
FREE( lru_node );
+
+ found = 0;
}
}
else