2000-08-23 19:32:42 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
2000-08-24 18:29:15 +02:00
|
|
|
/* ftcmanag.c */
|
2000-08-23 19:32:42 +02:00
|
|
|
/* */
|
2000-08-24 18:29:15 +02:00
|
|
|
/* FreeType Cache Manager (body). */
|
2000-08-23 19:32:42 +02:00
|
|
|
/* */
|
2002-03-30 17:41:09 +01:00
|
|
|
/* Copyright 2000-2001, 2002 by */
|
2000-08-23 19:32:42 +02:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_CACHE_H
|
2003-12-19 22:23:58 +01:00
|
|
|
#include FT_CACHE_INTERNAL_MANAGER_H
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
2001-10-07 15:30:26 +02:00
|
|
|
#include FT_SIZES_H
|
2000-08-23 13:22:30 +02:00
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "ftcerror.h"
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_cache
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
#define FTC_LRU_GET_MANAGER( lru ) ( (FTC_Manager)(lru)->user_data )
|
2000-08-23 19:32:42 +02:00
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
static FT_Error
|
|
|
|
ftc_scaler_lookup_size( FTC_Manager manager,
|
|
|
|
FTC_Scaler scaler,
|
|
|
|
FT_Size *asize )
|
|
|
|
{
|
|
|
|
FT_Face face;
|
|
|
|
FT_Size size = NULL;
|
|
|
|
FT_Error error;
|
2000-08-29 18:50:01 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
error = FTC_Manager_LookupFace( manager, scaler->face_id, &face );
|
|
|
|
if ( error ) goto Exit;
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
error = FT_New_Size( face, &size );
|
|
|
|
if ( error ) goto Exit;
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_Activate_Size( size );
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
if ( scaler->pixel )
|
|
|
|
error = FT_Set_Pixel_Sizes( face, scaler->width, scaler->height );
|
|
|
|
else
|
|
|
|
error = FT_Set_Char_Size( face, scaler->width, scaler->height,
|
|
|
|
scaler->x_res, scaler->y_res );
|
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
FT_Done_Size( size );
|
|
|
|
size = NULL;
|
|
|
|
}
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
Exit:
|
|
|
|
*asize = size;
|
|
|
|
return error;
|
|
|
|
}
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
|
|
|
|
typedef struct FTC_SizeNodeRec_
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_MruNodeRec node;
|
|
|
|
FT_Size size;
|
|
|
|
FTC_ScalerRec scaler;
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
} FTC_SizeNodeRec, *FTC_SizeNode;
|
2001-10-26 18:58:27 +02:00
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_CALLBACK_DEF( void )
|
|
|
|
ftc_size_node_done( FTC_SizeNode node )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_Size size = node->size;
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
if ( size )
|
|
|
|
FT_Done_Size( size );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
FT_CALLBACK_DEF( FT_Bool )
|
2003-12-19 22:23:58 +01:00
|
|
|
ftc_size_node_compare( FTC_SizeNode node,
|
|
|
|
FTC_Scaler scaler )
|
2001-12-05 02:22:05 +01:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_Scaler scaler0 = &node->scaler;
|
|
|
|
|
|
|
|
return FTC_SCALER_COMPARE( scaler0, scaler );
|
2001-12-05 02:22:05 +01:00
|
|
|
}
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
|
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
|
|
|
ftc_size_node_init( FTC_SizeNode node,
|
|
|
|
FTC_Scaler scaler,
|
|
|
|
FTC_Manager manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
node->scaler = scaler[0];
|
|
|
|
|
|
|
|
return ftc_scaler_lookup_size( manager, scaler, &node->size );
|
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
|
|
|
ftc_size_node_reset( FTC_SizeNode node,
|
|
|
|
FTC_Scaler scaler,
|
|
|
|
FTC_Manager manager )
|
|
|
|
{
|
|
|
|
FT_Done_Size( node->size );
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
node->scaler = scaler[0];
|
|
|
|
|
|
|
|
return ftc_scaler_lookup_size( manager, scaler, &node->size );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
static const FTC_MruListClassRec ftc_size_list_class =
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
sizeof( FTC_SizeNodeRec ),
|
|
|
|
(FTC_MruNode_CompareFunc) ftc_size_node_compare,
|
|
|
|
(FTC_MruNode_InitFunc) ftc_size_node_init,
|
|
|
|
(FTC_MruNode_ResetFunc) ftc_size_node_reset,
|
|
|
|
(FTC_MruNode_DoneFunc) ftc_size_node_done
|
2001-10-26 18:58:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
/* helper function used by ftc_face_node_done */
|
|
|
|
static FT_Bool
|
|
|
|
ftc_size_node_compare_faceid( FTC_SizeNode node,
|
|
|
|
FTC_FaceID face_id )
|
|
|
|
{
|
|
|
|
return FT_BOOL( node->scaler.face_id == face_id );
|
|
|
|
}
|
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_Manager_LookupSize( FTC_Manager manager,
|
|
|
|
FTC_Scaler scaler,
|
|
|
|
FT_Size *asize )
|
2001-12-05 16:59:33 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_SizeNode node;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
if ( asize == NULL )
|
2001-12-05 16:59:33 +01:00
|
|
|
return FTC_Err_Bad_Argument;
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
*asize = NULL;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
if ( !manager )
|
|
|
|
return FTC_Err_Invalid_Cache_Handle;
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
error = FTC_MruList_Lookup( &manager->sizes,
|
|
|
|
scaler,
|
|
|
|
(FTC_MruNode*) &node );
|
2001-12-05 16:59:33 +01:00
|
|
|
if ( !error )
|
2003-12-19 22:23:58 +01:00
|
|
|
*asize = node->size;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
2003-12-19 22:23:58 +01:00
|
|
|
/***** FACE MRU IMPLEMENTATION *****/
|
2001-10-26 18:58:27 +02:00
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
typedef struct FTC_FaceNodeRec_
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_MruNodeRec node;
|
|
|
|
FTC_FaceID face_id;
|
|
|
|
FT_Face face;
|
|
|
|
|
|
|
|
} FTC_FaceNodeRec, *FTC_FaceNode;
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2003-12-19 22:23:58 +01:00
|
|
|
ftc_face_node_init( FTC_FaceNode node,
|
|
|
|
FTC_FaceID face_id,
|
|
|
|
FTC_Manager manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_Error error;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
node->face_id = face_id;
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
error = manager->request_face( face_id,
|
|
|
|
manager->library,
|
|
|
|
manager->request_data,
|
|
|
|
&node->face );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
/* destroy initial size object; it will be re-created later */
|
|
|
|
if ( node->face->size )
|
|
|
|
FT_Done_Size( node->face->size );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
return error;
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( void )
|
2003-12-19 22:23:58 +01:00
|
|
|
ftc_face_node_done( FTC_FaceNode node,
|
|
|
|
FTC_Manager manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_Memory memory = manager->memory;
|
2000-08-23 13:22:30 +02:00
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
/* we must begin by removing all scalers for the target face */
|
|
|
|
/* from the manager's list */
|
|
|
|
FTC_MruList_RemoveSelection(
|
|
|
|
& manager->sizes,
|
|
|
|
(FTC_MruNode_CompareFunc) ftc_size_node_compare_faceid,
|
|
|
|
node->face_id );
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
/* all right, we can discard the face now */
|
|
|
|
FT_Done_Face( node->face );
|
|
|
|
node->face = NULL;
|
|
|
|
node->face_id = NULL;
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_FREE( node );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Bool )
|
2003-12-19 22:23:58 +01:00
|
|
|
ftc_face_node_compare( FTC_FaceNode node,
|
|
|
|
FTC_FaceID face_id )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
return FT_BOOL( node->face_id == face_id );
|
2000-08-23 19:32:42 +02:00
|
|
|
}
|
2000-08-23 13:22:30 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
static const FTC_MruListClassRec ftc_face_list_class =
|
2001-12-05 16:59:33 +01:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
sizeof( FTC_FaceNodeRec),
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
(FTC_MruNode_CompareFunc) ftc_face_node_compare,
|
|
|
|
(FTC_MruNode_InitFunc) ftc_face_node_init,
|
|
|
|
(FTC_MruNode_ResetFunc) NULL,
|
|
|
|
(FTC_MruNode_DoneFunc) ftc_face_node_done
|
|
|
|
};
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
/* documentation is in ftcache.h */
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2001-12-16 09:17:33 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_Manager_LookupFace( FTC_Manager manager,
|
|
|
|
FTC_FaceID face_id,
|
|
|
|
FT_Face *aface )
|
2001-12-05 16:59:33 +01:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_Error error;
|
|
|
|
FTC_FaceNode node;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
if ( aface == NULL )
|
|
|
|
return FTC_Err_Bad_Argument;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
*aface = NULL;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
if ( !manager )
|
|
|
|
return FTC_Err_Invalid_Cache_Handle;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
error = FTC_MruList_Lookup( &manager->faces,
|
|
|
|
face_id,
|
|
|
|
(FTC_MruNode*) &node );
|
|
|
|
if ( !error )
|
|
|
|
*aface = node->face;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** CACHE MANAGER ROUTINES *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-08-23 13:22:30 +02:00
|
|
|
|
|
|
|
|
2001-06-28 19:49:10 +02:00
|
|
|
/* documentation is in ftcache.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FTC_Manager_New( FT_Library library,
|
|
|
|
FT_UInt max_faces,
|
|
|
|
FT_UInt max_sizes,
|
|
|
|
FT_ULong max_bytes,
|
|
|
|
FTC_Face_Requester requester,
|
|
|
|
FT_Pointer req_data,
|
|
|
|
FTC_Manager *amanager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
|
|
|
FT_Error error;
|
2000-08-24 18:29:15 +02:00
|
|
|
FT_Memory memory;
|
2000-08-23 13:22:30 +02:00
|
|
|
FTC_Manager manager = 0;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( !library )
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return FTC_Err_Invalid_Library_Handle;
|
2000-08-24 18:29:15 +02:00
|
|
|
|
|
|
|
memory = library->memory;
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW( manager ) )
|
2000-08-23 13:22:30 +02:00
|
|
|
goto Exit;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( max_faces == 0 )
|
2000-09-19 03:11:11 +02:00
|
|
|
max_faces = FTC_MAX_FACES_DEFAULT;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( max_sizes == 0 )
|
2000-09-19 03:11:11 +02:00
|
|
|
max_sizes = FTC_MAX_SIZES_DEFAULT;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
if ( max_bytes == 0 )
|
|
|
|
max_bytes = FTC_MAX_BYTES_DEFAULT;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
manager->library = library;
|
2003-12-19 22:23:58 +01:00
|
|
|
manager->memory = memory;
|
2001-10-26 18:58:27 +02:00
|
|
|
manager->max_weight = max_bytes;
|
2001-10-29 11:45:57 +01:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
manager->request_face = requester;
|
|
|
|
manager->request_data = req_data;
|
2001-10-07 15:30:26 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_MruList_Init( &manager->faces,
|
|
|
|
&ftc_face_list_class,
|
|
|
|
max_faces,
|
|
|
|
manager,
|
|
|
|
memory );
|
|
|
|
|
|
|
|
FTC_MruList_Init( &manager->sizes,
|
|
|
|
&ftc_size_list_class,
|
|
|
|
max_sizes,
|
|
|
|
manager,
|
|
|
|
memory );
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
*amanager = manager;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2001-06-28 19:49:10 +02:00
|
|
|
/* documentation is in ftcache.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FTC_Manager_Done( FTC_Manager manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2000-08-24 18:29:15 +02:00
|
|
|
FT_Memory memory;
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
FT_UInt idx;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( !manager || !manager->library )
|
|
|
|
return;
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
memory = manager->memory;
|
2000-08-24 18:29:15 +02:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
/* now discard all caches */
|
2003-12-19 22:23:58 +01:00
|
|
|
for (idx = manager->num_caches; idx-- > 0; )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
FTC_Cache cache = manager->caches[idx];
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
if ( cache )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
cache->clazz.cache_done( cache );
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( cache );
|
2003-12-19 22:23:58 +01:00
|
|
|
manager->caches[idx] = NULL;
|
2000-09-19 03:11:11 +02:00
|
|
|
}
|
|
|
|
}
|
2003-12-19 22:23:58 +01:00
|
|
|
manager->num_caches = 0;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
/* discard faces and sizes */
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_MruList_Done( &manager->sizes );
|
|
|
|
FTC_MruList_Done( &manager->faces );
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
manager->library = NULL;
|
|
|
|
manager->memory = NULL;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( manager );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 19:49:10 +02:00
|
|
|
/* documentation is in ftcache.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FTC_Manager_Reset( FTC_Manager manager )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2001-12-05 02:22:05 +01:00
|
|
|
if ( manager )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_MruList_Reset( &manager->sizes );
|
|
|
|
FTC_MruList_Reset( &manager->faces );
|
2000-09-19 03:11:11 +02:00
|
|
|
}
|
2000-10-31 23:13:54 +01:00
|
|
|
/* XXX: FIXME: flush the caches? */
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
#ifdef FT_DEBUG_ERROR
|
2001-12-20 18:49:10 +01:00
|
|
|
|
|
|
|
FT_EXPORT_DEF( void )
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_Manager_Check( FTC_Manager manager )
|
|
|
|
{
|
|
|
|
FTC_Node node, first;
|
2003-12-19 22:23:58 +01:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
first = manager->nodes_list;
|
|
|
|
|
|
|
|
/* check node weights */
|
2001-12-05 02:22:05 +01:00
|
|
|
if ( first )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
FT_ULong weight = 0;
|
2003-12-19 22:23:58 +01:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
node = first;
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
do
|
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_Cache cache = manager->caches + node->cache_index;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
if ( (FT_UInt)node->cache_index >= manager->num_caches )
|
|
|
|
FT_ERROR(( "FTC_Manager_Check: invalid node (cache index = %ld\n",
|
|
|
|
node->cache_index ));
|
2001-12-05 16:59:33 +01:00
|
|
|
else
|
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
weight += cache->clazz.node_weight( node, cache );
|
2001-12-05 16:59:33 +01:00
|
|
|
}
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
node = node->mru_next;
|
2001-12-20 18:49:10 +01:00
|
|
|
|
|
|
|
} while ( node != first );
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( weight != manager->cur_weight )
|
2001-12-20 18:49:10 +01:00
|
|
|
FT_ERROR(( "FTC_Manager_Check: invalid weight %ld instead of %ld\n",
|
|
|
|
manager->cur_weight, weight ));
|
2001-10-26 18:58:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check circular list */
|
2001-12-05 02:22:05 +01:00
|
|
|
if ( first )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
|
|
|
FT_UFast count = 0;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
node = first;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
node = node->mru_next;
|
2001-12-20 18:49:10 +01:00
|
|
|
|
|
|
|
} while ( node != first );
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( count != manager->num_nodes )
|
2001-12-05 02:22:05 +01:00
|
|
|
FT_ERROR((
|
2001-12-20 18:49:10 +01:00
|
|
|
"FTC_Manager_Check: invalid cache node count %d instead of %d\n",
|
2001-12-05 02:22:05 +01:00
|
|
|
manager->num_nodes, count ));
|
2001-10-26 18:58:27 +02:00
|
|
|
}
|
|
|
|
}
|
2001-12-20 18:49:10 +01:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
#endif /* FT_DEBUG_ERROR */
|
2001-10-26 18:58:27 +02:00
|
|
|
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/* `Compress' the manager's data, i.e., get rid of old cache nodes */
|
2000-09-19 03:11:11 +02:00
|
|
|
/* that are not referenced anymore in order to limit the total */
|
2000-10-12 07:05:40 +02:00
|
|
|
/* memory used by the cache. */
|
2001-06-28 19:49:10 +02:00
|
|
|
|
|
|
|
/* documentation is in ftcmanag.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FTC_Manager_Compress( FTC_Manager manager )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_Node node, first;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( !manager )
|
|
|
|
return;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
first = manager->nodes_list;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
#ifdef FT_DEBUG_ERROR
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_Manager_Check( manager );
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_ERROR(( "compressing, weight = %ld, max = %ld, nodes = %d\n",
|
2001-12-05 02:22:05 +01:00
|
|
|
manager->cur_weight, manager->max_weight,
|
|
|
|
manager->num_nodes ));
|
2001-10-26 18:58:27 +02:00
|
|
|
#endif
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( manager->cur_weight < manager->max_weight || first == NULL )
|
|
|
|
return;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
/* go to last node - it's a circular list */
|
|
|
|
node = first->mru_prev;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
FTC_Node prev = node->mru_prev;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
prev = ( node == first ) ? NULL : node->mru_prev;
|
|
|
|
|
|
|
|
if ( node->ref_count <= 0 )
|
|
|
|
ftc_node_destroy( node, manager );
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
node = prev;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
} while ( node && manager->cur_weight > manager->max_weight );
|
|
|
|
}
|
2000-09-19 03:11:11 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
/* documentation is in ftcmanag.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2003-12-19 22:23:58 +01:00
|
|
|
FTC_Manager_RegisterCache( FTC_Manager manager,
|
|
|
|
FTC_CacheClass clazz,
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_Cache *acache )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_Error error = FTC_Err_Invalid_Argument;
|
|
|
|
FTC_Cache cache = NULL;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
if ( manager && clazz && acache )
|
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_Memory memory = manager->memory;
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
if ( manager->num_caches >= FTC_MAX_CACHES )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
error = FTC_Err_Too_Many_Caches;
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_ERROR(( "%s: too many registered caches\n",
|
|
|
|
"FTC_Manager_Register_Cache" ));
|
2000-09-19 03:11:11 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( !FT_ALLOC( cache, clazz->cache_size ) )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
cache->manager = manager;
|
|
|
|
cache->memory = memory;
|
|
|
|
cache->clazz = clazz[0];
|
|
|
|
cache->org_class = clazz;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
/* THIS IS VERY IMPORTANT! IT WILL WRETCH THE MANAGER */
|
|
|
|
/* IF IT IS NOT SET CORRECTLY */
|
2003-12-19 22:23:58 +01:00
|
|
|
cache->index = manager->num_caches;
|
2000-09-19 03:11:11 +02:00
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
error = clazz->cache_init( cache );
|
|
|
|
if ( error )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
clazz->cache_done( cache );
|
|
|
|
FT_FREE( cache );
|
|
|
|
goto Exit;
|
2001-10-26 18:58:27 +02:00
|
|
|
}
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
manager->caches[ manager->num_caches++ ] = cache;
|
2001-10-26 18:58:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
*acache = cache;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
FT_EXPORT_DEF( FT_UInt )
|
|
|
|
FTC_Manager_FlushN( FTC_Manager manager,
|
|
|
|
FT_UInt count )
|
|
|
|
{
|
|
|
|
FTC_Node first = manager->nodes_list;
|
|
|
|
FTC_Node node;
|
|
|
|
FT_UInt result;
|
|
|
|
|
|
|
|
/* try to remove "count" nodes from the list */
|
|
|
|
if ( first == NULL ) /* empty list! */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* go to last node - it's a circular list */
|
|
|
|
node = first->mru_prev;
|
|
|
|
for ( result = 0; result < count; )
|
|
|
|
{
|
|
|
|
FTC_Node prev = node->mru_prev;
|
|
|
|
|
|
|
|
|
|
|
|
/* don't touch locked nodes */
|
|
|
|
if ( node->ref_count <= 0 )
|
|
|
|
{
|
|
|
|
ftc_node_destroy( node, manager );
|
|
|
|
result++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( prev == manager->nodes_list )
|
|
|
|
break;
|
|
|
|
|
|
|
|
node = prev;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FTC_Manager_RemoveFaceID( FTC_Manager manager,
|
|
|
|
FTC_FaceID face_id )
|
|
|
|
{
|
|
|
|
FT_UInt nn;
|
|
|
|
|
|
|
|
/* this will remove all FTC_SizeNode that correspond to
|
|
|
|
* the face_id as well
|
|
|
|
*/
|
|
|
|
FTC_MruList_RemoveSelection( &manager->faces, NULL, face_id );
|
|
|
|
|
|
|
|
for ( nn = 0; nn < manager->num_caches; nn++ )
|
|
|
|
FTC_Cache_RemoveFaceID( manager->caches[nn], face_id );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
/* documentation is in ftcmanag.h */
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2001-12-20 18:49:10 +01:00
|
|
|
FT_EXPORT_DEF( void )
|
2001-12-05 16:59:33 +01:00
|
|
|
FTC_Node_Unref( FTC_Node node,
|
|
|
|
FTC_Manager manager )
|
2001-10-26 18:58:27 +02:00
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
if ( node && (FT_UInt)node->cache_index < manager->num_caches )
|
2001-10-26 18:58:27 +02:00
|
|
|
node->ref_count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
/* END */
|