Al-Qurtas-Islamic-bank-The-.../src/cache/ftcsbits.c

430 lines
12 KiB
C
Raw Normal View History

/****************************************************************************
*
* ftcsbits.c
*
* FreeType sbits manager (body).
*
2022-01-11 10:54:10 +01:00
* Copyright (C) 2000-2022 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-12-08 17:17:16 +01:00
#include <freetype/ftcache.h>
#include "ftcsbits.h"
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/fterrors.h>
#include "ftccback.h"
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"
#undef FT_COMPONENT
#define FT_COMPONENT cache
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** SBIT CACHE NODES *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static FT_Error
ftc_sbit_copy_bitmap( FTC_SBit sbit,
FT_Bitmap* bitmap,
FT_Memory memory )
{
FT_Error error;
FT_Int pitch = bitmap->pitch;
FT_ULong size;
if ( pitch < 0 )
pitch = -pitch;
size = (FT_ULong)pitch * bitmap->rows;
if ( !FT_QALLOC( sbit->buffer, size ) )
FT_MEM_COPY( sbit->buffer, bitmap->buffer, size );
return error;
}
FT_LOCAL_DEF( void )
ftc_snode_free( FTC_Node ftcsnode,
FTC_Cache cache )
{
FTC_SNode snode = (FTC_SNode)ftcsnode;
FTC_SBit sbit = snode->sbits;
FT_UInt count = snode->count;
FT_Memory memory = cache->memory;
for ( ; count > 0; sbit++, count-- )
FT_FREE( sbit->buffer );
FTC_GNode_Done( FTC_GNODE( snode ), cache );
FT_FREE( snode );
}
FT_LOCAL_DEF( void )
FTC_SNode_Free( FTC_SNode snode,
FTC_Cache cache )
{
ftc_snode_free( FTC_NODE( snode ), cache );
}
2005-05-23 23:33:02 +02:00
/*
* This function tries to load a small bitmap within a given FTC_SNode.
* Note that it returns a non-zero error code _only_ in the case of
* out-of-memory condition. For all other errors (e.g., corresponding
* to a bad font file), this function will mark the sbit as `unavailable'
* and return a value of 0.
2005-05-23 23:33:02 +02:00
*
* You should also read the comment within the @ftc_snode_compare
* function below to see how out-of-memory is handled during a lookup.
2005-05-23 23:33:02 +02:00
*/
static FT_Error
ftc_snode_load( FTC_SNode snode,
FTC_Manager manager,
FT_UInt gindex,
FT_ULong *asize )
{
FT_Error error;
FTC_GNode gnode = FTC_GNODE( snode );
FTC_Family family = gnode->family;
FT_Face face;
FTC_SBit sbit;
FTC_SFamilyClass clazz;
if ( gindex - gnode->gindex >= snode->count )
{
FT_ERROR(( "ftc_snode_load: invalid glyph index" ));
return FT_THROW( Invalid_Argument );
}
sbit = snode->sbits + ( gindex - gnode->gindex );
clazz = (FTC_SFamilyClass)family->clazz;
error = clazz->family_load_glyph( family, gindex, manager, &face );
if ( error )
goto BadGlyph;
{
FT_Int temp;
FT_GlyphSlot slot = face->glyph;
FT_Bitmap* bitmap = &slot->bitmap;
FT_Pos xadvance, yadvance; /* FT_GlyphSlot->advance.{x|y} */
2000-10-31 21:42:18 +01:00
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
{
FT_TRACE0(( "ftc_snode_load:"
" glyph loaded didn't return a bitmap\n" ));
goto BadGlyph;
}
2000-10-31 21:42:18 +01:00
/* Check whether our values fit into 8/16-bit containers! */
/* If this is not the case, our bitmap is too large */
/* and we will leave it as `missing' with sbit.buffer = 0 */
#define CHECK_CHAR( d ) ( temp = (FT_Char)d, (FT_Int) temp == (FT_Int) d )
#define CHECK_BYTE( d ) ( temp = (FT_Byte)d, (FT_UInt)temp == (FT_UInt)d )
#define CHECK_SHRT( d ) ( temp = (FT_Short)d, (FT_Int)temp == (FT_Int) d )
/* horizontal advance in pixels */
xadvance = ( slot->advance.x + 32 ) >> 6;
yadvance = ( slot->advance.y + 32 ) >> 6;
if ( !CHECK_BYTE( bitmap->rows ) ||
!CHECK_BYTE( bitmap->width ) ||
!CHECK_SHRT( bitmap->pitch ) ||
!CHECK_CHAR( slot->bitmap_left ) ||
!CHECK_CHAR( slot->bitmap_top ) ||
!CHECK_CHAR( xadvance ) ||
!CHECK_CHAR( yadvance ) )
{
FT_TRACE2(( "ftc_snode_load:"
" glyph too large for small bitmap cache\n"));
goto BadGlyph;
}
sbit->width = (FT_Byte)bitmap->width;
sbit->height = (FT_Byte)bitmap->rows;
sbit->pitch = (FT_Short)bitmap->pitch;
sbit->left = (FT_Char)slot->bitmap_left;
sbit->top = (FT_Char)slot->bitmap_top;
sbit->xadvance = (FT_Char)xadvance;
sbit->yadvance = (FT_Char)yadvance;
sbit->format = (FT_Byte)bitmap->pixel_mode;
2022-04-01 08:50:33 +02:00
sbit->max_grays = (FT_Byte)( bitmap->num_grays - 1 );
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
/* take the bitmap ownership */
sbit->buffer = bitmap->buffer;
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
else
{
/* copy the bitmap into a new buffer -- ignore error */
error = ftc_sbit_copy_bitmap( sbit, bitmap, manager->memory );
}
/* now, compute size */
if ( asize )
*asize = (FT_ULong)FT_ABS( sbit->pitch ) * sbit->height;
} /* glyph loading successful */
/* ignore the errors that might have occurred -- */
/* we mark unloaded glyphs with `sbit.buffer == 0' */
/* and `width == 255', `height == 0' */
/* */
if ( error && FT_ERR_NEQ( error, Out_Of_Memory ) )
{
BadGlyph:
sbit->width = 255;
sbit->height = 0;
sbit->buffer = NULL;
error = FT_Err_Ok;
if ( asize )
*asize = 0;
}
return error;
}
FT_LOCAL_DEF( FT_Error )
FTC_SNode_New( FTC_SNode *psnode,
FTC_GQuery gquery,
FTC_Cache cache )
{
FT_Memory memory = cache->memory;
FT_Error error;
FTC_SNode snode = NULL;
FT_UInt gindex = gquery->gindex;
FTC_Family family = gquery->family;
FTC_SFamilyClass clazz = FTC_CACHE_SFAMILY_CLASS( cache );
FT_UInt total;
FT_UInt node_count;
total = clazz->family_get_count( family, cache->manager );
if ( total == 0 || gindex >= total )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( !FT_QNEW( snode ) )
{
FT_UInt count, start;
start = gindex - ( gindex % FTC_SBIT_ITEMS_PER_NODE );
count = total - start;
if ( count > FTC_SBIT_ITEMS_PER_NODE )
count = FTC_SBIT_ITEMS_PER_NODE;
FTC_GNode_Init( FTC_GNODE( snode ), start, family );
snode->count = count;
for ( node_count = 0; node_count < count; node_count++ )
{
snode->sbits[node_count].width = 255;
snode->sbits[node_count].height = 0;
snode->sbits[node_count].buffer = NULL;
}
error = ftc_snode_load( snode,
cache->manager,
gindex,
NULL );
if ( error )
{
FTC_SNode_Free( snode, cache );
snode = NULL;
}
}
Exit:
*psnode = snode;
return error;
}
FT_LOCAL_DEF( FT_Error )
* src/cache/ftcbasic.c (ftc_basic_family_compare, ftc_basic_family_init, ftc_basic_family_get_count, ftc_basic_family_load_bitmap, ftc_basic_family_load_glyph, ftc_basic_gnode_compare_faceid): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. (ftc_basic_image_family_class, ftc_basic_image_cache_class, ftc_basic_sbit_family_class, ftc_basic_sbit_cache_class): Remove casts. * src/cache/ftccback.h: Adjust parameters and return types to prototypes given in header files from include/freetype/cache. * src/cache/ftcimage.c (ftc_inode_free, ftc_inode_new, ftc_inode_weight): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. * src/cache/ftcsbits.c (ftc_snode_free, ftc_snode_new, ftc_snode_weight, ftc_snode_compare): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. * src/cache/ftccmap.c (ftc_cmap_node_free, ftc_cmap_node_new, ftc_cmap_node_weight, ftc_cmap_node_compare, ftc_cmap_node_remove_faceid): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. (ftc_cmap_cache_class): Remove casts. * src/cache/ftcglyph.c (ftc_gnode_compare, ftc_gcache_init, ftc_gcache_done): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. * src/cache/ftcmanag.c (ftc_size_node_done, ftc_size_node_compare, ftc_size_node_init, ftc_size_node_reset, ftc_size_node_compare_faceid, ftc_face_node_init, ftc_face_node_done, ftc_face_node_compare: Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. (ftc_size_list_class, ftc_face_list_class): Remove casts. * src/autohint/ahmodule.c (ft_autohinter_init, ft_autohinter_done): Use FT_Module as parameter and do a cast to FT_AutoHinter locally. (autohint_module_class): Remove casts. * src/base/ftglyph.c (ft_bitmap_glyph_init, ft_bitmap_glyph_copy, ft_bitmap_glyph_done, ft_bitmap_glyph_bbox, ft_outline_glyph_init, ft_outline_glyph_done, ft_outline_glyph_copy, ft_outline_glyph_transform, ft_outline_glyph_bbox, ft_outline_glyph_prepare): Use FT_Glyph as parameter and do a cast to FT_XXXGlyph locally. Use FT_CALLBACK_DEF throughout. (ft_bitmap_glyph_class, ft_outline_glyph_class): Remove casts. * src/bdf/bdfdrivr.c (bdf_cmap_init, bdf_cmap_done, bdf_cmap_char_index, bdf_cmap_char_next): Use FT_CMap as parameter and do a cast to BDF_CMap locally. (bdf_cmap_class): Remove casts.
2004-05-17 11:25:04 +02:00
ftc_snode_new( FTC_Node *ftcpsnode,
FT_Pointer ftcgquery,
FTC_Cache cache )
{
* src/cache/ftcbasic.c (ftc_basic_family_compare, ftc_basic_family_init, ftc_basic_family_get_count, ftc_basic_family_load_bitmap, ftc_basic_family_load_glyph, ftc_basic_gnode_compare_faceid): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. (ftc_basic_image_family_class, ftc_basic_image_cache_class, ftc_basic_sbit_family_class, ftc_basic_sbit_cache_class): Remove casts. * src/cache/ftccback.h: Adjust parameters and return types to prototypes given in header files from include/freetype/cache. * src/cache/ftcimage.c (ftc_inode_free, ftc_inode_new, ftc_inode_weight): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. * src/cache/ftcsbits.c (ftc_snode_free, ftc_snode_new, ftc_snode_weight, ftc_snode_compare): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. * src/cache/ftccmap.c (ftc_cmap_node_free, ftc_cmap_node_new, ftc_cmap_node_weight, ftc_cmap_node_compare, ftc_cmap_node_remove_faceid): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. (ftc_cmap_cache_class): Remove casts. * src/cache/ftcglyph.c (ftc_gnode_compare, ftc_gcache_init, ftc_gcache_done): Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. * src/cache/ftcmanag.c (ftc_size_node_done, ftc_size_node_compare, ftc_size_node_init, ftc_size_node_reset, ftc_size_node_compare_faceid, ftc_face_node_init, ftc_face_node_done, ftc_face_node_compare: Adjust parameters and return types to prototypes given in header files from include/freetype/cache. Use casts to proper types locally. (ftc_size_list_class, ftc_face_list_class): Remove casts. * src/autohint/ahmodule.c (ft_autohinter_init, ft_autohinter_done): Use FT_Module as parameter and do a cast to FT_AutoHinter locally. (autohint_module_class): Remove casts. * src/base/ftglyph.c (ft_bitmap_glyph_init, ft_bitmap_glyph_copy, ft_bitmap_glyph_done, ft_bitmap_glyph_bbox, ft_outline_glyph_init, ft_outline_glyph_done, ft_outline_glyph_copy, ft_outline_glyph_transform, ft_outline_glyph_bbox, ft_outline_glyph_prepare): Use FT_Glyph as parameter and do a cast to FT_XXXGlyph locally. Use FT_CALLBACK_DEF throughout. (ft_bitmap_glyph_class, ft_outline_glyph_class): Remove casts. * src/bdf/bdfdrivr.c (bdf_cmap_init, bdf_cmap_done, bdf_cmap_char_index, bdf_cmap_char_next): Use FT_CMap as parameter and do a cast to BDF_CMap locally. (bdf_cmap_class): Remove casts.
2004-05-17 11:25:04 +02:00
FTC_SNode *psnode = (FTC_SNode*)ftcpsnode;
FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
return FTC_SNode_New( psnode, gquery, cache );
}
FT_LOCAL_DEF( FT_Offset )
ftc_snode_weight( FTC_Node ftcsnode,
FTC_Cache cache )
{
FTC_SNode snode = (FTC_SNode)ftcsnode;
FT_UInt count = snode->count;
FTC_SBit sbit = snode->sbits;
FT_Int pitch;
FT_Offset size;
FT_UNUSED( cache );
FT_ASSERT( snode->count <= FTC_SBIT_ITEMS_PER_NODE );
/* the node itself */
size = sizeof ( *snode );
for ( ; count > 0; count--, sbit++ )
{
if ( sbit->buffer )
{
pitch = sbit->pitch;
if ( pitch < 0 )
pitch = -pitch;
2000-10-31 21:42:18 +01:00
/* add the size of a given glyph image */
size += (FT_Offset)pitch * sbit->height;
}
}
return size;
}
#if 0
FT_LOCAL_DEF( FT_Offset )
FTC_SNode_Weight( FTC_SNode snode )
{
return ftc_snode_weight( FTC_NODE( snode ), NULL );
}
#endif /* 0 */
FT_LOCAL_DEF( FT_Bool )
ftc_snode_compare( FTC_Node ftcsnode,
FT_Pointer ftcgquery,
[cache] Notice if a cache query induced the node list change. Some node comparators (comparing the cache node content and the properties specified by the query) can flush the cache node to prevent the cache inflation. The change may invalidate the pointers to the node obtained before the node comparison, so the change should be noticed to the caller. The problem caused by the cache node changing is reported by Harsha, see Savannah bug #31923. * src/cache/ftccache.h (FTC_Node_CompareFunc): Add new argument `FT_Bool* list_changed' to indicate the change of the cached nodes to the caller. (FTC_CACHE_LOOKUP_CMP): Watch the change of the cached nodes by `_list_changed'. (FTC_CACHE_TRYLOOP_END): Take new macro argument `_list_changed' and update it when FTC_Manager_FlushN() flushes any nodes. * src/cache/ftccback.h (ftc_snode_compare): Updated to fit with new FTC_Node_CompareFunc type. (ftc_gnode_compare): Ditto. * src/cache/ftcbasic.c: Include FT_INTERNAL_OBJECTS_H to use TRUE/FALSE macros. (ftc_basic_gnode_compare_faceid): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway, it is always FALSE. * src/cache/ftccmap.c: Include FT_INTERNAL_OBJECTS_H to use TRUE/FALSE macros. (ftc_cmap_node_compare): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway, it is always FALSE. (ftc_cmap_node_remove_faceid): Ditto. * src/cache/ftccache.c (FTC_Cache_NewNode): Pass a NULL pointer to FTC_CACHE_TRYLOOP_END(), because the result is not needed. (FTC_Cache_Lookup): Watch the change of the cache nodes by `list_changed'. (FTC_Cache_RemoveFaceID): Ditto. * src/cache/ftcglyph.c: Include FT_INTERNAL_OBJECTS_H to use TRUE/FALSE macros. (ftc_gnode_compare): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway, it is always FALSE. (FTC_GNode_Compare): New argument `FT_Bool* list_changed' to be passed to ftc_gnode_compare(). * src/cache/ftcglyph.h (FTC_GNode_Compare): Ditto. * src/cache/ftcsbits.c (ftc_snode_compare): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway. It is updated by FTC_CACHE_TRYLOOP(). (FTC_SNode_Compare): New argument `FT_Bool* list_changed' to be passed to ftc_snode_compare(). * src/cache/ftcsbits.h (FTC_SNode_Compare): Ditto.
2011-01-09 14:49:07 +01:00
FTC_Cache cache,
FT_Bool* list_changed )
{
FTC_SNode snode = (FTC_SNode)ftcsnode;
FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
FTC_GNode gnode = FTC_GNODE( snode );
FT_UInt gindex = gquery->gindex;
FT_Bool result;
[cache] Notice if a cache query induced the node list change. Some node comparators (comparing the cache node content and the properties specified by the query) can flush the cache node to prevent the cache inflation. The change may invalidate the pointers to the node obtained before the node comparison, so the change should be noticed to the caller. The problem caused by the cache node changing is reported by Harsha, see Savannah bug #31923. * src/cache/ftccache.h (FTC_Node_CompareFunc): Add new argument `FT_Bool* list_changed' to indicate the change of the cached nodes to the caller. (FTC_CACHE_LOOKUP_CMP): Watch the change of the cached nodes by `_list_changed'. (FTC_CACHE_TRYLOOP_END): Take new macro argument `_list_changed' and update it when FTC_Manager_FlushN() flushes any nodes. * src/cache/ftccback.h (ftc_snode_compare): Updated to fit with new FTC_Node_CompareFunc type. (ftc_gnode_compare): Ditto. * src/cache/ftcbasic.c: Include FT_INTERNAL_OBJECTS_H to use TRUE/FALSE macros. (ftc_basic_gnode_compare_faceid): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway, it is always FALSE. * src/cache/ftccmap.c: Include FT_INTERNAL_OBJECTS_H to use TRUE/FALSE macros. (ftc_cmap_node_compare): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway, it is always FALSE. (ftc_cmap_node_remove_faceid): Ditto. * src/cache/ftccache.c (FTC_Cache_NewNode): Pass a NULL pointer to FTC_CACHE_TRYLOOP_END(), because the result is not needed. (FTC_Cache_Lookup): Watch the change of the cache nodes by `list_changed'. (FTC_Cache_RemoveFaceID): Ditto. * src/cache/ftcglyph.c: Include FT_INTERNAL_OBJECTS_H to use TRUE/FALSE macros. (ftc_gnode_compare): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway, it is always FALSE. (FTC_GNode_Compare): New argument `FT_Bool* list_changed' to be passed to ftc_gnode_compare(). * src/cache/ftcglyph.h (FTC_GNode_Compare): Ditto. * src/cache/ftcsbits.c (ftc_snode_compare): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway. It is updated by FTC_CACHE_TRYLOOP(). (FTC_SNode_Compare): New argument `FT_Bool* list_changed' to be passed to ftc_snode_compare(). * src/cache/ftcsbits.h (FTC_SNode_Compare): Ditto.
2011-01-09 14:49:07 +01:00
if (list_changed)
*list_changed = FALSE;
result = FT_BOOL( gnode->family == gquery->family &&
gindex - gnode->gindex < snode->count );
if ( result )
{
/* check if we need to load the glyph bitmap now */
FTC_SBit sbit = snode->sbits + ( gindex - gnode->gindex );
2005-05-23 23:33:02 +02:00
/*
* The following code illustrates what to do when you want to
* perform operations that may fail within a lookup function.
2005-05-23 23:33:02 +02:00
*
* Here, we want to load a small bitmap on-demand; we thus
* need to call the `ftc_snode_load' function which may return
* a non-zero error code only when we are out of memory (OOM).
2005-05-23 23:33:02 +02:00
*
* The correct thing to do is to use @FTC_CACHE_TRYLOOP and
* @FTC_CACHE_TRYLOOP_END in order to implement a retry loop
* that is capable of flushing the cache incrementally when
* an OOM errors occur.
2005-05-23 23:33:02 +02:00
*
* However, we need to `lock' the node before this operation to
* prevent it from being flushed within the loop.
2005-05-23 23:33:02 +02:00
*
* When we exit the loop, we unlock the node, then check the `error'
* variable. If it is non-zero, this means that the cache was
* completely flushed and that no usable memory was found to load
* the bitmap.
2005-05-23 23:33:02 +02:00
*
* We then prefer to return a value of 0 (i.e., NO MATCH). This
* ensures that the caller will try to allocate a new node.
* This operation consequently _fail_ and the lookup function
* returns the appropriate OOM error code.
2005-05-23 23:33:02 +02:00
*
* Note that `buffer == NULL && width == 255' is a hack used to
* tag `unavailable' bitmaps in the array. We should never try
* to load these.
2005-05-23 23:33:02 +02:00
*
*/
if ( !sbit->buffer && sbit->width == 255 )
{
FT_ULong size;
FT_Error error;
2005-05-23 23:33:02 +02:00
ftcsnode->ref_count++; /* lock node to prevent flushing */
/* in retry loop */
FTC_CACHE_TRYLOOP( cache )
{
error = ftc_snode_load( snode, cache->manager, gindex, &size );
}
FTC_CACHE_TRYLOOP_END( list_changed )
ftcsnode->ref_count--; /* unlock the node */
if ( error )
result = 0;
else
cache->manager->cur_weight += size;
}
}
return result;
}
#ifdef FTC_INLINE
FT_LOCAL_DEF( FT_Bool )
FTC_SNode_Compare( FTC_SNode snode,
FTC_GQuery gquery,
[cache] Notice if a cache query induced the node list change. Some node comparators (comparing the cache node content and the properties specified by the query) can flush the cache node to prevent the cache inflation. The change may invalidate the pointers to the node obtained before the node comparison, so the change should be noticed to the caller. The problem caused by the cache node changing is reported by Harsha, see Savannah bug #31923. * src/cache/ftccache.h (FTC_Node_CompareFunc): Add new argument `FT_Bool* list_changed' to indicate the change of the cached nodes to the caller. (FTC_CACHE_LOOKUP_CMP): Watch the change of the cached nodes by `_list_changed'. (FTC_CACHE_TRYLOOP_END): Take new macro argument `_list_changed' and update it when FTC_Manager_FlushN() flushes any nodes. * src/cache/ftccback.h (ftc_snode_compare): Updated to fit with new FTC_Node_CompareFunc type. (ftc_gnode_compare): Ditto. * src/cache/ftcbasic.c: Include FT_INTERNAL_OBJECTS_H to use TRUE/FALSE macros. (ftc_basic_gnode_compare_faceid): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway, it is always FALSE. * src/cache/ftccmap.c: Include FT_INTERNAL_OBJECTS_H to use TRUE/FALSE macros. (ftc_cmap_node_compare): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway, it is always FALSE. (ftc_cmap_node_remove_faceid): Ditto. * src/cache/ftccache.c (FTC_Cache_NewNode): Pass a NULL pointer to FTC_CACHE_TRYLOOP_END(), because the result is not needed. (FTC_Cache_Lookup): Watch the change of the cache nodes by `list_changed'. (FTC_Cache_RemoveFaceID): Ditto. * src/cache/ftcglyph.c: Include FT_INTERNAL_OBJECTS_H to use TRUE/FALSE macros. (ftc_gnode_compare): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway, it is always FALSE. (FTC_GNode_Compare): New argument `FT_Bool* list_changed' to be passed to ftc_gnode_compare(). * src/cache/ftcglyph.h (FTC_GNode_Compare): Ditto. * src/cache/ftcsbits.c (ftc_snode_compare): New argument `FT_Bool* list_changed' to indicate the change of the cache nodes, anyway. It is updated by FTC_CACHE_TRYLOOP(). (FTC_SNode_Compare): New argument `FT_Bool* list_changed' to be passed to ftc_snode_compare(). * src/cache/ftcsbits.h (FTC_SNode_Compare): Ditto.
2011-01-09 14:49:07 +01:00
FTC_Cache cache,
FT_Bool* list_changed )
{
2011-01-13 10:33:04 +01:00
return ftc_snode_compare( FTC_NODE( snode ), gquery,
cache, list_changed );
}
#endif
/* END */