2000-09-16 00:50:59 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftcglyph.h */
|
|
|
|
/* */
|
2000-10-29 01:34:45 +02:00
|
|
|
/* FreeType abstract glyph cache (specification). */
|
2000-09-16 00:50:59 +02:00
|
|
|
/* */
|
|
|
|
/* Copyright 2000 by */
|
|
|
|
/* 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
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Important: The functions defined in this file are only used to */
|
|
|
|
/* implement an abstract glyph cache class. You need to */
|
|
|
|
/* provide additional logic to implement a complete cache. */
|
|
|
|
/* For example, see `ftcimage.h' and `ftcimage.c' which */
|
|
|
|
/* implement a FT_Glyph cache based on this code. */
|
|
|
|
/* */
|
2000-10-31 18:49:07 +01:00
|
|
|
/* NOTE: For now, each glyph set is implemented as a static hash table. */
|
|
|
|
/* It would be interesting to experiment with dynamic hashes to */
|
|
|
|
/* see whether this improves performance or not (I don't know why */
|
|
|
|
/* but something tells me it won't). */
|
2000-10-29 01:34:45 +02:00
|
|
|
/* */
|
2000-10-31 18:49:07 +01:00
|
|
|
/* In all cases, this change should not affect any derived glyph */
|
|
|
|
/* cache class. */
|
2000-10-29 01:34:45 +02:00
|
|
|
/* */
|
2000-10-12 07:05:40 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/********* *********/
|
|
|
|
/********* WARNING, THIS IS ALPHA CODE, THIS API *********/
|
|
|
|
/********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
|
|
|
|
/********* FREETYPE DEVELOPMENT TEAM *********/
|
|
|
|
/********* *********/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-09-16 00:50:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef FTCGLYPH_H
|
|
|
|
#define FTCGLYPH_H
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-09-16 00:50:59 +02:00
|
|
|
#include <freetype/cache/ftcmanag.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-09-16 00:50:59 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
/* maximum number of glyph sets per glyph cache; must be < 256 */
|
|
|
|
#define FTC_MAX_GLYPH_SETS 16
|
|
|
|
#define FTC_GSET_HASH_SIZE_DEFAULT 64
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
typedef struct FTC_GlyphSetRec_* FTC_GlyphSet;
|
2000-10-12 07:05:40 +02:00
|
|
|
typedef struct FTC_GlyphNodeRec_* FTC_GlyphNode;
|
|
|
|
typedef struct FTC_Glyph_CacheRec_* FTC_Glyph_Cache;
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
typedef struct FTC_GlyphNodeRec_
|
2000-09-16 00:50:59 +02:00
|
|
|
{
|
|
|
|
FTC_CacheNodeRec root;
|
2000-10-28 15:17:11 +02:00
|
|
|
FTC_GlyphNode gset_next; /* next in glyph set's bucket list */
|
2000-09-16 00:50:59 +02:00
|
|
|
FT_UShort glyph_index;
|
2000-10-28 15:17:11 +02:00
|
|
|
FT_UShort gset_index;
|
2000-10-12 03:22:29 +02:00
|
|
|
|
2000-09-16 00:50:59 +02:00
|
|
|
} FTC_GlyphNodeRec;
|
|
|
|
|
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
#define FTC_GLYPHNODE( x ) ( (FTC_GlyphNode)( x ) )
|
|
|
|
#define FTC_GLYPHNODE_TO_LRUNODE( n ) ( (FT_ListNode)( n ) )
|
|
|
|
#define FTC_LRUNODE_TO_GLYPHNODE( n ) ( (FTC_GlyphNode)( n ) )
|
2000-09-16 00:50:59 +02:00
|
|
|
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2000-10-28 15:17:11 +02:00
|
|
|
/* Glyph set methods. */
|
2000-10-12 07:05:40 +02:00
|
|
|
/* */
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
typedef FT_Error (*FTC_GlyphSet_InitFunc) ( FTC_GlyphSet gset,
|
|
|
|
FT_Pointer type );
|
2000-10-28 15:17:11 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
typedef void (*FTC_GlyphSet_DoneFunc) ( FTC_GlyphSet gset );
|
2000-10-12 03:22:29 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
typedef FT_Bool (*FTC_GlyphSet_CompareFunc) ( FTC_GlyphSet gset,
|
|
|
|
FT_Pointer type );
|
2000-10-12 03:22:29 +02:00
|
|
|
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
typedef FT_Error (*FTC_GlyphSet_NewNodeFunc) ( FTC_GlyphSet gset,
|
|
|
|
FT_UInt gindex,
|
|
|
|
FTC_GlyphNode* anode );
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
typedef void (*FTC_GlyphSet_DestroyNodeFunc)( FTC_GlyphNode node,
|
|
|
|
FTC_GlyphSet gset );
|
2000-10-12 03:22:29 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
typedef FT_ULong (*FTC_GlyphSet_SizeNodeFunc) ( FTC_GlyphNode node,
|
|
|
|
FTC_GlyphSet gset );
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
typedef struct FTC_GlyphSet_Class_
|
2000-09-16 00:50:59 +02:00
|
|
|
{
|
2000-10-28 15:17:11 +02:00
|
|
|
FT_UInt gset_byte_size;
|
2000-10-12 03:22:29 +02:00
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
FTC_GlyphSet_InitFunc init;
|
|
|
|
FTC_GlyphSet_DoneFunc done;
|
|
|
|
FTC_GlyphSet_CompareFunc compare;
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
FTC_GlyphSet_NewNodeFunc new_node;
|
|
|
|
FTC_GlyphSet_SizeNodeFunc size_node;
|
|
|
|
FTC_GlyphSet_DestroyNodeFunc destroy_node;
|
2000-10-12 03:22:29 +02:00
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
} FTC_GlyphSet_Class;
|
2000-09-16 00:50:59 +02:00
|
|
|
|
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
typedef struct FTC_GlyphSetRec_
|
2000-09-16 00:50:59 +02:00
|
|
|
{
|
2000-10-28 15:17:11 +02:00
|
|
|
FTC_Glyph_Cache cache;
|
|
|
|
FTC_Manager manager;
|
|
|
|
FT_Memory memory;
|
|
|
|
FTC_GlyphSet_Class* clazz;
|
|
|
|
FT_UInt hash_size;
|
|
|
|
FTC_GlyphNode* buckets;
|
|
|
|
FT_UInt gset_index; /* index in parent cache */
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
} FTC_GlyphSetRec;
|
2000-09-16 00:50:59 +02:00
|
|
|
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/* the abstract glyph cache class */
|
|
|
|
typedef struct FTC_Glyph_Cache_Class_
|
2000-09-16 00:50:59 +02:00
|
|
|
{
|
2000-10-28 15:17:11 +02:00
|
|
|
FTC_Cache_Class root;
|
|
|
|
FTC_GlyphSet_Class* gset_class;
|
2000-10-12 03:22:29 +02:00
|
|
|
|
2000-09-16 00:50:59 +02:00
|
|
|
} FTC_Glyph_Cache_Class;
|
|
|
|
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/* the abstract glyph cache object */
|
2000-09-16 00:50:59 +02:00
|
|
|
typedef struct FTC_Glyph_CacheRec_
|
|
|
|
{
|
2000-10-28 15:17:11 +02:00
|
|
|
FTC_CacheRec root;
|
2000-10-31 18:49:07 +01:00
|
|
|
FT_Lru gsets_lru; /* static sets lru list */
|
|
|
|
FTC_GlyphSet last_gset; /* small cache :-) */
|
2000-09-16 00:50:59 +02:00
|
|
|
|
|
|
|
} FTC_Glyph_CacheRec;
|
|
|
|
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* These functions are exported so that they can be called from */
|
2000-10-31 18:49:07 +01:00
|
|
|
/* user-provided cache classes; otherwise, they are really part of the */
|
2000-10-12 07:05:40 +02:00
|
|
|
/* cache sub-system internals. */
|
|
|
|
/* */
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
FT_EXPORT_FUNC( void ) FTC_GlyphNode_Init( FTC_GlyphNode node,
|
|
|
|
FTC_GlyphSet gset,
|
|
|
|
FT_UInt gindex );
|
2000-10-12 03:22:29 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
#define FTC_GlyphNode_Ref( n ) \
|
|
|
|
FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count++
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
#define FTC_GlyphNode_Unref( n ) \
|
|
|
|
FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count--
|
2000-09-16 00:50:59 +02:00
|
|
|
|
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
FT_EXPORT_DEF( void ) FTC_GlyphNode_Destroy( FTC_GlyphNode node,
|
|
|
|
FTC_Glyph_Cache cache );
|
2000-10-28 09:26:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error ) FTC_Glyph_Cache_Init( FTC_Glyph_Cache cache );
|
2000-10-28 09:26:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
FT_EXPORT_DEF( void ) FTC_Glyph_Cache_Done( FTC_Glyph_Cache cache );
|
2000-09-16 00:50:59 +02:00
|
|
|
|
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error ) FTC_GlyphSet_New( FTC_Glyph_Cache cache,
|
|
|
|
FT_Pointer type,
|
|
|
|
FTC_GlyphSet* aset );
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error ) FTC_GlyphSet_Lookup_Node(
|
|
|
|
FTC_GlyphSet gset,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FTC_GlyphNode* anode );
|
2000-09-16 00:50:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
#endif /* FTCGLYPH_H */
|
2000-09-16 00:50:59 +02:00
|
|
|
|
2000-10-31 18:49:07 +01:00
|
|
|
|
2000-09-16 00:50:59 +02:00
|
|
|
/* END */
|