2000-09-19 03:11:11 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftcglyph.c */
|
|
|
|
/* */
|
2000-10-12 07:05:40 +02:00
|
|
|
/* FreeType Glyph Image (FT_Glyph) cache (body). */
|
2000-09-19 03:11:11 +02:00
|
|
|
/* */
|
2001-06-28 19:49:10 +02:00
|
|
|
/* Copyright 2000-2001 by */
|
2000-09-19 03:11:11 +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
|
|
|
|
#include FT_CACHE_INTERNAL_GLYPH_H
|
|
|
|
#include FT_ERRORS_H
|
|
|
|
#include FT_LIST_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
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
|
|
|
#include "ftcerror.h"
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** GLYPH NODES *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
|
|
|
#define FTC_GSET_HASH( gset, gindex ) \
|
|
|
|
( (FT_UFast)( ( (gset)->hash << 16 ) | ( (gindex) & 0xFFFF ) ) )
|
2001-10-26 18:58:27 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
/* create a new glyph node, setting its cache index and ref count */
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_glyph_node_init( FTC_GlyphNode gnode,
|
|
|
|
FT_UInt gindex,
|
|
|
|
FTC_GlyphSet gset )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
gnode->gset = gset;
|
|
|
|
gnode->node.hash = FTC_GSET_HASH( gset, gindex );
|
|
|
|
gset->num_glyphs++;
|
2000-10-12 07:05:40 +02:00
|
|
|
}
|
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
/* Important: This function is called from the cache manager to */
|
|
|
|
/* destroy a given cache node during `cache compression'. The */
|
2000-10-29 01:34:45 +02:00
|
|
|
/* second argument is always `cache.cache_data'. Thus be */
|
2000-10-28 09:26:59 +02:00
|
|
|
/* certain that the function FTC_Glyph_Cache_New() does indeed */
|
2000-10-29 01:34:45 +02:00
|
|
|
/* set its `cache_data' field correctly, otherwise bad things */
|
2000-10-12 07:05:40 +02:00
|
|
|
/* will happen! */
|
2000-09-19 03:11:11 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
2001-12-05 02:22:05 +01:00
|
|
|
ftc_glyph_node_done( FTC_GlyphNode gnode )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_GlyphSet gset = gnode->gset;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
if ( --gset->num_glyphs <= 0 )
|
2001-12-05 02:22:05 +01:00
|
|
|
FT_LruList_Remove( gset->gcache->gset_lru, (FT_LruNode)gset );
|
2000-09-19 03:11:11 +02:00
|
|
|
}
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
2000-10-29 01:34:45 +02:00
|
|
|
/***** GLYPH SETS *****/
|
2000-10-12 07:05:40 +02:00
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_glyph_set_init( FTC_GlyphSet gset,
|
2001-12-05 02:22:05 +01:00
|
|
|
FT_LruList lru )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FTC_GlyphCache gcache = lru->user_data;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
gset->gcache = gcache;
|
|
|
|
gset->num_glyphs = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-19 03:11:11 +02:00
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_glyph_set_done( FTC_GlyphSet gset )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
/* for now, nothing to be done here */
|
2001-12-05 02:22:05 +01:00
|
|
|
FT_UNUSED( gset );
|
2000-09-19 03:11:11 +02:00
|
|
|
}
|
|
|
|
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
2001-10-26 18:58:27 +02:00
|
|
|
/***** GLYPH CACHES *****/
|
2000-09-19 03:11:11 +02:00
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-10-12 07:05:40 +02:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
2001-12-05 02:22:05 +01:00
|
|
|
ftc_glyph_cache_done( FTC_GlyphCache gcache )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
/* remove all nodes in the cache */
|
|
|
|
ftc_cache_done( &gcache->cache );
|
|
|
|
|
|
|
|
/* simply delete all remaining glyph sets */
|
|
|
|
if ( gcache->gset_lru )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_LruList_Destroy( gcache->gset_lru );
|
|
|
|
gcache->gset_lru = NULL;
|
2000-09-19 03:11:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_glyph_cache_init( FTC_GlyphCache gcache,
|
|
|
|
FT_LruList_Class gset_class )
|
2000-09-19 03:11:11 +02:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_Error error;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
|
|
|
error = ftc_cache_init( FTC_CACHE( gcache ) );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2001-10-26 18:58:27 +02:00
|
|
|
|
|
|
|
error = FT_LruList_New( gset_class, 0, gcache,
|
|
|
|
gcache->cache.memory,
|
|
|
|
&gcache->gset_lru );
|
|
|
|
Exit:
|
2000-09-19 03:11:11 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2001-10-26 18:58:27 +02:00
|
|
|
ftc_glyph_cache_lookup( FTC_GlyphCache gcache,
|
|
|
|
FTC_GlyphQuery query,
|
|
|
|
FTC_GlyphNode *anode )
|
2000-11-06 20:29:06 +01:00
|
|
|
{
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_LruNode node;
|
|
|
|
FT_Error error;
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
error = FT_LruList_Lookup( gcache->gset_lru, query, &node );
|
|
|
|
if ( !error )
|
2000-11-06 20:29:06 +01:00
|
|
|
{
|
2001-12-05 02:22:05 +01:00
|
|
|
FTC_GlyphSet gset = (FTC_GlyphSet)node;
|
2001-10-26 18:58:27 +02:00
|
|
|
FT_UFast hash = FTC_GSET_HASH( gset, query->gindex );
|
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
error = ftc_cache_lookup_node( FTC_CACHE( gcache ), hash, query,
|
|
|
|
FTC_NODE_P( anode ) );
|
2000-11-06 20:29:06 +01:00
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-11-10 23:43:37 +01:00
|
|
|
|
2000-09-19 03:11:11 +02:00
|
|
|
/* END */
|