freetype2/include/freetype/cache/ftcmanag.h

245 lines
12 KiB
C
Raw Normal View History

2000-09-16 00:42:06 +02:00
/***************************************************************************/
/* */
/* ftcmanag.h */
/* */
/* FreeType Cache Manager (specification). */
/* */
/* Copyright 2000-2001 by */
2000-09-16 00:42:06 +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-10-12 07:05:40 +02:00
/*************************************************************************/
/* */
/* A cache manager is in charge of the following: */
/* */
/* - Maintain a mapping between generic FTC_FaceIDs and live FT_Face */
/* objects. The mapping itself is performed through a user-provided */
/* callback. However, the manager maintains a small cache of FT_Face */
/* and FT_Size objects in order to speed up things considerably. */
2000-10-12 07:05:40 +02:00
/* */
/* - Manage one or more cache objects. Each cache is in charge of */
/* holding a varying number of `cache nodes'. Each cache node */
2000-10-31 20:42:53 +01:00
/* represents a minimal amount of individually accessible cached */
2000-10-12 07:05:40 +02:00
/* data. For example, a cache node can be an FT_Glyph image */
/* containing a vector outline, or some glyph metrics, or anything */
/* else. */
/* */
/* Each cache node has a certain size in bytes that is added to the */
/* total amount of `cache memory' within the manager. */
/* */
/* All cache nodes are located in a global LRU list, where the oldest */
/* node is at the tail of the list. */
/* */
/* Each node belongs to a single cache, and includes a reference */
/* count to avoid destroying it (due to caching). */
/* */
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/********* *********/
/********* WARNING, THIS IS BETA CODE. *********/
2000-10-12 07:05:40 +02:00
/********* *********/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
2000-09-16 00:42:06 +02:00
#ifndef __FTCMANAG_H__
#define __FTCMANAG_H__
2000-09-16 00:42:06 +02:00
#include <ft2build.h>
#include FT_CACHE_H
#include FT_CACHE_INTERNAL_LRU_H
#include FT_CACHE_INTERNAL_CACHE_H
2000-09-16 00:42:06 +02:00
FT_BEGIN_HEADER
2000-09-16 00:42:06 +02:00
/*************************************************************************/
/* */
/* <Section> */
/* cache_subsystem */
/* */
/*************************************************************************/
#define FTC_MAX_FACES_DEFAULT 2
#define FTC_MAX_SIZES_DEFAULT 4
#define FTC_MAX_BYTES_DEFAULT 200000L /* ~200kByte by default */
2000-10-12 07:05:40 +02:00
/* maximum number of caches registered in a single manager */
#define FTC_MAX_CACHES 16
2000-09-16 00:42:06 +02:00
typedef struct FTC_FamilyEntryRec_
{
FTC_Family family;
FTC_Cache cache;
FT_UInt index;
FT_UInt link;
} FTC_FamilyEntryRec, *FTC_FamilyEntry;
#define FTC_FAMILY_ENTRY_NONE ( (FT_UInt)-1 )
typedef struct FTC_FamilyTableRec_
{
FT_UInt count;
FT_UInt size;
FTC_FamilyEntry entries;
FT_UInt free;
} FTC_FamilyTableRec, *FTC_FamilyTable;
FT_EXPORT( FT_Error )
ftc_family_table_alloc( FTC_FamilyTable table,
FT_Memory memory,
FTC_FamilyEntry *aentry );
FT_EXPORT( void )
ftc_family_table_free( FTC_FamilyTable table,
* 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-31 20:42:53 +01:00
/*************************************************************************/
/* */
/* <Struct> */
/* FTC_ManagerRec */
/* */
/* <Description> */
/* The cache manager structure. */
/* */
/* <Fields> */
/* library :: A handle to a FreeType library instance. */
/* */
/* faces_list :: The lru list of @FT_Face objects in the cache. */
2000-10-31 20:42:53 +01:00
/* */
/* sizes_list :: The lru list of @FT_Size objects in the cache. */
2000-10-31 20:42:53 +01:00
/* */
/* max_weight :: The maximum cache pool weight. */
2000-10-31 20:42:53 +01:00
/* */
/* cur_weight :: The current cache pool weight. */
2000-10-31 20:42:53 +01:00
/* */
/* num_nodes :: The current number of nodes in the manager. */
/* */
/* nodes_list :: The global lru list of all cache nodes. */
2000-10-31 20:42:53 +01:00
/* */
/* caches :: A table of installed/registered cache objects. */
/* */
/* request_data :: User-provided data passed to the requester. */
/* */
/* request_face :: User-provided function used to implement a mapping */
/* between abstract @FTC_FaceID values and real */
/* @FT_Face objects. */
/* */
/* families :: Global table of families. */
2000-10-31 20:42:53 +01:00
/* */
typedef struct FTC_ManagerRec_
{
FT_Library library;
FT_LruList faces_list;
FT_LruList sizes_list;
2000-09-16 00:42:06 +02:00
FT_ULong max_weight;
FT_ULong cur_weight;
FT_UInt num_nodes;
FTC_Node nodes_list;
2000-10-12 07:05:40 +02:00
FTC_Cache caches[FTC_MAX_CACHES];
FT_Pointer request_data;
FTC_Face_Requester request_face;
2000-10-12 07:05:40 +02:00
FTC_FamilyTableRec families;
} FTC_ManagerRec;
2000-09-16 00:42:06 +02:00
2000-10-31 20:42:53 +01:00
/*************************************************************************/
/* */
/* <Function> */
/* FTC_Manager_Compress */
/* */
/* <Description> */
/* This function is used to check the state of the cache manager if */
/* its `num_bytes' field is greater than its `max_bytes' field. It */
/* will flush as many old cache nodes as possible (ignoring cache */
/* nodes with a non-zero reference count). */
/* */
2000-11-10 23:43:37 +01:00
/* <InOut> */
2000-10-31 20:42:53 +01:00
/* manager :: A handle to the cache manager. */
/* */
/* <Note> */
/* Client applications should not call this function directly. It is */
/* normally invoked by specific cache implementations. */
/* */
/* The reason this function is exported is to allow client-specific */
/* cache classes. */
/* */
FT_EXPORT( void )
FTC_Manager_Compress( FTC_Manager manager );
/* this must be used internally for the moment */
FT_EXPORT( FT_Error )
FTC_Manager_Register_Cache( FTC_Manager manager,
FTC_Cache_Class clazz,
FTC_Cache *acache );
2000-10-31 20:42:53 +01:00
/* can be called to increment a node's reference count */
FT_EXPORT( void )
FTC_Node_Ref( FTC_Node node,
FTC_Manager manager );
2000-10-12 07:05:40 +02:00
/*************************************************************************/
/* */
/* <Function> */
/* FTC_Node_Unref */
/* */
/* <Description> */
/* Decrement a cache node's internal reference count. When the count */
/* reaches 0, it is not destroyed but becomes eligible for subsequent */
/* cache flushes. */
/* */
/* <Input> */
/* node :: The cache node handle. */
/* */
/* manager :: The cache manager handle. */
/* */
FT_EXPORT( void )
FTC_Node_Unref( FTC_Node node,
FTC_Manager manager );
2000-09-16 00:42:06 +02:00
/* */
FT_END_HEADER
2000-09-16 00:42:06 +02:00
#endif /* __FTCMANAG_H__ */
2000-09-16 00:42:06 +02:00
/* END */