Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenftcbasic.c
Go to the documentation of this file.
00001 /***************************************************************************/ 00002 /* */ 00003 /* ftcbasic.c */ 00004 /* */ 00005 /* The FreeType basic cache interface (body). */ 00006 /* */ 00007 /* Copyright 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ 00008 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 00009 /* */ 00010 /* This file is part of the FreeType project, and may only be used, */ 00011 /* modified, and distributed under the terms of the FreeType project */ 00012 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 00013 /* this file you indicate that you have read the license and */ 00014 /* understand and accept it fully. */ 00015 /* */ 00016 /***************************************************************************/ 00017 00018 00019 #include <ft2build.h> 00020 #include FT_INTERNAL_DEBUG_H 00021 #include FT_CACHE_H 00022 #include "ftcglyph.h" 00023 #include "ftcimage.h" 00024 #include "ftcsbits.h" 00025 00026 #include "ftccback.h" 00027 #include "ftcerror.h" 00028 00029 #define FT_COMPONENT trace_cache 00030 00031 00032 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS 00033 00034 /* 00035 * These structures correspond to the FTC_Font and FTC_ImageDesc types 00036 * that were defined in version 2.1.7. 00037 */ 00038 typedef struct FTC_OldFontRec_ 00039 { 00040 FTC_FaceID face_id; 00041 FT_UShort pix_width; 00042 FT_UShort pix_height; 00043 00044 } FTC_OldFontRec, *FTC_OldFont; 00045 00046 00047 typedef struct FTC_OldImageDescRec_ 00048 { 00049 FTC_OldFontRec font; 00050 FT_UInt32 flags; 00051 00052 } FTC_OldImageDescRec, *FTC_OldImageDesc; 00053 00054 00055 /* 00056 * Notice that FTC_OldImageDescRec and FTC_ImageTypeRec are nearly 00057 * identical, bit-wise. The only difference is that the `width' and 00058 * `height' fields are expressed as 16-bit integers in the old structure, 00059 * and as normal `int' in the new one. 00060 * 00061 * We are going to perform a weird hack to detect which structure is 00062 * being passed to the image and sbit caches. If the new structure's 00063 * `width' is larger than 0x10000, we assume that we are really receiving 00064 * an FTC_OldImageDesc. 00065 */ 00066 00067 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ 00068 00069 00070 /* 00071 * Basic Families 00072 * 00073 */ 00074 typedef struct FTC_BasicAttrRec_ 00075 { 00076 FTC_ScalerRec scaler; 00077 FT_UInt load_flags; 00078 00079 } FTC_BasicAttrRec, *FTC_BasicAttrs; 00080 00081 #define FTC_BASIC_ATTR_COMPARE( a, b ) \ 00082 FT_BOOL( FTC_SCALER_COMPARE( &(a)->scaler, &(b)->scaler ) && \ 00083 (a)->load_flags == (b)->load_flags ) 00084 00085 #define FTC_BASIC_ATTR_HASH( a ) \ 00086 ( FTC_SCALER_HASH( &(a)->scaler ) + 31*(a)->load_flags ) 00087 00088 00089 typedef struct FTC_BasicQueryRec_ 00090 { 00091 FTC_GQueryRec gquery; 00092 FTC_BasicAttrRec attrs; 00093 00094 } FTC_BasicQueryRec, *FTC_BasicQuery; 00095 00096 00097 typedef struct FTC_BasicFamilyRec_ 00098 { 00099 FTC_FamilyRec family; 00100 FTC_BasicAttrRec attrs; 00101 00102 } FTC_BasicFamilyRec, *FTC_BasicFamily; 00103 00104 00105 FT_CALLBACK_DEF( FT_Bool ) 00106 ftc_basic_family_compare( FTC_MruNode ftcfamily, 00107 FT_Pointer ftcquery ) 00108 { 00109 FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily; 00110 FTC_BasicQuery query = (FTC_BasicQuery)ftcquery; 00111 00112 00113 return FTC_BASIC_ATTR_COMPARE( &family->attrs, &query->attrs ); 00114 } 00115 00116 00117 FT_CALLBACK_DEF( FT_Error ) 00118 ftc_basic_family_init( FTC_MruNode ftcfamily, 00119 FT_Pointer ftcquery, 00120 FT_Pointer ftccache ) 00121 { 00122 FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily; 00123 FTC_BasicQuery query = (FTC_BasicQuery)ftcquery; 00124 FTC_Cache cache = (FTC_Cache)ftccache; 00125 00126 00127 FTC_Family_Init( FTC_FAMILY( family ), cache ); 00128 family->attrs = query->attrs; 00129 return 0; 00130 } 00131 00132 00133 FT_CALLBACK_DEF( FT_UInt ) 00134 ftc_basic_family_get_count( FTC_Family ftcfamily, 00135 FTC_Manager manager ) 00136 { 00137 FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily; 00138 FT_Error error; 00139 FT_Face face; 00140 FT_UInt result = 0; 00141 00142 00143 error = FTC_Manager_LookupFace( manager, family->attrs.scaler.face_id, 00144 &face ); 00145 00146 if ( error || !face ) 00147 return result; 00148 00149 if ( (FT_ULong)face->num_glyphs > FT_UINT_MAX || 0 > face->num_glyphs ) 00150 { 00151 FT_TRACE1(( "ftc_basic_family_get_count: too large number of glyphs " )); 00152 FT_TRACE1(( "in this face, truncated\n", face->num_glyphs )); 00153 } 00154 00155 if ( !error ) 00156 result = (FT_UInt)face->num_glyphs; 00157 00158 return result; 00159 } 00160 00161 00162 FT_CALLBACK_DEF( FT_Error ) 00163 ftc_basic_family_load_bitmap( FTC_Family ftcfamily, 00164 FT_UInt gindex, 00165 FTC_Manager manager, 00166 FT_Face *aface ) 00167 { 00168 FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily; 00169 FT_Error error; 00170 FT_Size size; 00171 00172 00173 error = FTC_Manager_LookupSize( manager, &family->attrs.scaler, &size ); 00174 if ( !error ) 00175 { 00176 FT_Face face = size->face; 00177 00178 00179 error = FT_Load_Glyph( face, gindex, 00180 family->attrs.load_flags | FT_LOAD_RENDER ); 00181 if ( !error ) 00182 *aface = face; 00183 } 00184 00185 return error; 00186 } 00187 00188 00189 FT_CALLBACK_DEF( FT_Error ) 00190 ftc_basic_family_load_glyph( FTC_Family ftcfamily, 00191 FT_UInt gindex, 00192 FTC_Cache cache, 00193 FT_Glyph *aglyph ) 00194 { 00195 FTC_BasicFamily family = (FTC_BasicFamily)ftcfamily; 00196 FT_Error error; 00197 FTC_Scaler scaler = &family->attrs.scaler; 00198 FT_Face face; 00199 FT_Size size; 00200 00201 00202 /* we will now load the glyph image */ 00203 error = FTC_Manager_LookupSize( cache->manager, 00204 scaler, 00205 &size ); 00206 if ( !error ) 00207 { 00208 face = size->face; 00209 00210 error = FT_Load_Glyph( face, gindex, family->attrs.load_flags ); 00211 if ( !error ) 00212 { 00213 if ( face->glyph->format == FT_GLYPH_FORMAT_BITMAP || 00214 face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) 00215 { 00216 /* ok, copy it */ 00217 FT_Glyph glyph; 00218 00219 00220 error = FT_Get_Glyph( face->glyph, &glyph ); 00221 if ( !error ) 00222 { 00223 *aglyph = glyph; 00224 goto Exit; 00225 } 00226 } 00227 else 00228 error = FTC_Err_Invalid_Argument; 00229 } 00230 } 00231 00232 Exit: 00233 return error; 00234 } 00235 00236 00237 FT_CALLBACK_DEF( FT_Bool ) 00238 ftc_basic_gnode_compare_faceid( FTC_Node ftcgnode, 00239 FT_Pointer ftcface_id, 00240 FTC_Cache cache ) 00241 { 00242 FTC_GNode gnode = (FTC_GNode)ftcgnode; 00243 FTC_FaceID face_id = (FTC_FaceID)ftcface_id; 00244 FTC_BasicFamily family = (FTC_BasicFamily)gnode->family; 00245 FT_Bool result; 00246 00247 00248 result = FT_BOOL( family->attrs.scaler.face_id == face_id ); 00249 if ( result ) 00250 { 00251 /* we must call this function to avoid this node from appearing 00252 * in later lookups with the same face_id! 00253 */ 00254 FTC_GNode_UnselectFamily( gnode, cache ); 00255 } 00256 return result; 00257 } 00258 00259 00260 /* 00261 * 00262 * basic image cache 00263 * 00264 */ 00265 00266 FT_CALLBACK_TABLE_DEF 00267 const FTC_IFamilyClassRec ftc_basic_image_family_class = 00268 { 00269 { 00270 sizeof ( FTC_BasicFamilyRec ), 00271 ftc_basic_family_compare, 00272 ftc_basic_family_init, 00273 0, /* FTC_MruNode_ResetFunc */ 00274 0 /* FTC_MruNode_DoneFunc */ 00275 }, 00276 ftc_basic_family_load_glyph 00277 }; 00278 00279 00280 FT_CALLBACK_TABLE_DEF 00281 const FTC_GCacheClassRec ftc_basic_image_cache_class = 00282 { 00283 { 00284 ftc_inode_new, 00285 ftc_inode_weight, 00286 ftc_gnode_compare, 00287 ftc_basic_gnode_compare_faceid, 00288 ftc_inode_free, 00289 00290 sizeof ( FTC_GCacheRec ), 00291 ftc_gcache_init, 00292 ftc_gcache_done 00293 }, 00294 (FTC_MruListClass)&ftc_basic_image_family_class 00295 }; 00296 00297 00298 /* documentation is in ftcache.h */ 00299 00300 FT_EXPORT_DEF( FT_Error ) 00301 FTC_ImageCache_New( FTC_Manager manager, 00302 FTC_ImageCache *acache ) 00303 { 00304 return FTC_GCache_New( manager, &ftc_basic_image_cache_class, 00305 (FTC_GCache*)acache ); 00306 } 00307 00308 00309 /* documentation is in ftcache.h */ 00310 00311 FT_EXPORT_DEF( FT_Error ) 00312 FTC_ImageCache_Lookup( FTC_ImageCache cache, 00313 FTC_ImageType type, 00314 FT_UInt gindex, 00315 FT_Glyph *aglyph, 00316 FTC_Node *anode ) 00317 { 00318 FTC_BasicQueryRec query; 00319 FTC_Node node = 0; /* make compiler happy */ 00320 FT_Error error; 00321 FT_PtrDist hash; 00322 00323 00324 /* some argument checks are delayed to FTC_Cache_Lookup */ 00325 if ( !aglyph ) 00326 { 00327 error = FTC_Err_Invalid_Argument; 00328 goto Exit; 00329 } 00330 00331 *aglyph = NULL; 00332 if ( anode ) 00333 *anode = NULL; 00334 00335 #if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU ) 00336 00337 /* 00338 * This one is a major hack used to detect whether we are passed a 00339 * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one. 00340 */ 00341 if ( (FT_ULong)type->width >= 0x10000L ) 00342 { 00343 FTC_OldImageDesc desc = (FTC_OldImageDesc)type; 00344 00345 00346 query.attrs.scaler.face_id = desc->font.face_id; 00347 query.attrs.scaler.width = desc->font.pix_width; 00348 query.attrs.scaler.height = desc->font.pix_height; 00349 query.attrs.load_flags = desc->flags; 00350 } 00351 else 00352 00353 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ 00354 00355 { 00356 if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX ) 00357 { 00358 FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" )); 00359 FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) )); 00360 } 00361 00362 query.attrs.scaler.face_id = type->face_id; 00363 query.attrs.scaler.width = type->width; 00364 query.attrs.scaler.height = type->height; 00365 query.attrs.load_flags = (FT_UInt)type->flags; 00366 } 00367 00368 query.attrs.scaler.pixel = 1; 00369 query.attrs.scaler.x_res = 0; /* make compilers happy */ 00370 query.attrs.scaler.y_res = 0; 00371 00372 hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex; 00373 00374 #if 1 /* inlining is about 50% faster! */ 00375 FTC_GCACHE_LOOKUP_CMP( cache, 00376 ftc_basic_family_compare, 00377 FTC_GNode_Compare, 00378 hash, gindex, 00379 &query, 00380 node, 00381 error ); 00382 #else 00383 error = FTC_GCache_Lookup( FTC_GCACHE( cache ), 00384 hash, gindex, 00385 FTC_GQUERY( &query ), 00386 &node ); 00387 #endif 00388 if ( !error ) 00389 { 00390 *aglyph = FTC_INODE( node )->glyph; 00391 00392 if ( anode ) 00393 { 00394 *anode = node; 00395 node->ref_count++; 00396 } 00397 } 00398 00399 Exit: 00400 return error; 00401 } 00402 00403 00404 /* documentation is in ftcache.h */ 00405 00406 FT_EXPORT_DEF( FT_Error ) 00407 FTC_ImageCache_LookupScaler( FTC_ImageCache cache, 00408 FTC_Scaler scaler, 00409 FT_ULong load_flags, 00410 FT_UInt gindex, 00411 FT_Glyph *aglyph, 00412 FTC_Node *anode ) 00413 { 00414 FTC_BasicQueryRec query; 00415 FTC_Node node = 0; /* make compiler happy */ 00416 FT_Error error; 00417 FT_PtrDist hash; 00418 00419 00420 /* some argument checks are delayed to FTC_Cache_Lookup */ 00421 if ( !aglyph || !scaler ) 00422 { 00423 error = FTC_Err_Invalid_Argument; 00424 goto Exit; 00425 } 00426 00427 *aglyph = NULL; 00428 if ( anode ) 00429 *anode = NULL; 00430 00431 /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */ 00432 if ( load_flags > FT_UINT_MAX ) 00433 { 00434 FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" )); 00435 FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) )); 00436 } 00437 00438 query.attrs.scaler = scaler[0]; 00439 query.attrs.load_flags = (FT_UInt)load_flags; 00440 00441 hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex; 00442 00443 FTC_GCACHE_LOOKUP_CMP( cache, 00444 ftc_basic_family_compare, 00445 FTC_GNode_Compare, 00446 hash, gindex, 00447 &query, 00448 node, 00449 error ); 00450 if ( !error ) 00451 { 00452 *aglyph = FTC_INODE( node )->glyph; 00453 00454 if ( anode ) 00455 { 00456 *anode = node; 00457 node->ref_count++; 00458 } 00459 } 00460 00461 Exit: 00462 return error; 00463 } 00464 00465 00466 00467 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS 00468 00469 /* yet another backwards-legacy structure */ 00470 typedef struct FTC_OldImage_Desc_ 00471 { 00472 FTC_FontRec font; 00473 FT_UInt image_type; 00474 00475 } FTC_OldImage_Desc; 00476 00477 00478 #define FTC_OLD_IMAGE_FORMAT( x ) ( (x) & 7 ) 00479 00480 00481 #define ftc_old_image_format_bitmap 0x0000 00482 #define ftc_old_image_format_outline 0x0001 00483 00484 #define ftc_old_image_format_mask 0x000F 00485 00486 #define ftc_old_image_flag_monochrome 0x0010 00487 #define ftc_old_image_flag_unhinted 0x0020 00488 #define ftc_old_image_flag_autohinted 0x0040 00489 #define ftc_old_image_flag_unscaled 0x0080 00490 #define ftc_old_image_flag_no_sbits 0x0100 00491 00492 /* monochrome bitmap */ 00493 #define ftc_old_image_mono ftc_old_image_format_bitmap | \ 00494 ftc_old_image_flag_monochrome 00495 00496 /* anti-aliased bitmap */ 00497 #define ftc_old_image_grays ftc_old_image_format_bitmap 00498 00499 /* scaled outline */ 00500 #define ftc_old_image_outline ftc_old_image_format_outline 00501 00502 00503 static void 00504 ftc_image_type_from_old_desc( FTC_ImageType typ, 00505 FTC_OldImage_Desc* desc ) 00506 { 00507 typ->face_id = desc->font.face_id; 00508 typ->width = desc->font.pix_width; 00509 typ->height = desc->font.pix_height; 00510 00511 /* convert image type flags to load flags */ 00512 { 00513 FT_UInt load_flags = FT_LOAD_DEFAULT; 00514 FT_UInt type = desc->image_type; 00515 00516 00517 /* determine load flags, depending on the font description's */ 00518 /* image type */ 00519 00520 if ( FTC_OLD_IMAGE_FORMAT( type ) == ftc_old_image_format_bitmap ) 00521 { 00522 if ( type & ftc_old_image_flag_monochrome ) 00523 load_flags |= FT_LOAD_MONOCHROME; 00524 00525 /* disable embedded bitmaps loading if necessary */ 00526 if ( type & ftc_old_image_flag_no_sbits ) 00527 load_flags |= FT_LOAD_NO_BITMAP; 00528 } 00529 else 00530 { 00531 /* we want an outline, don't load embedded bitmaps */ 00532 load_flags |= FT_LOAD_NO_BITMAP; 00533 00534 if ( type & ftc_old_image_flag_unscaled ) 00535 load_flags |= FT_LOAD_NO_SCALE; 00536 } 00537 00538 /* always render glyphs to bitmaps */ 00539 load_flags |= FT_LOAD_RENDER; 00540 00541 if ( type & ftc_old_image_flag_unhinted ) 00542 load_flags |= FT_LOAD_NO_HINTING; 00543 00544 if ( type & ftc_old_image_flag_autohinted ) 00545 load_flags |= FT_LOAD_FORCE_AUTOHINT; 00546 00547 typ->flags = load_flags; 00548 } 00549 } 00550 00551 00552 FT_EXPORT( FT_Error ) 00553 FTC_Image_Cache_New( FTC_Manager manager, 00554 FTC_ImageCache *acache ); 00555 00556 FT_EXPORT( FT_Error ) 00557 FTC_Image_Cache_Lookup( FTC_ImageCache icache, 00558 FTC_OldImage_Desc* desc, 00559 FT_UInt gindex, 00560 FT_Glyph *aglyph ); 00561 00562 00563 FT_EXPORT_DEF( FT_Error ) 00564 FTC_Image_Cache_New( FTC_Manager manager, 00565 FTC_ImageCache *acache ) 00566 { 00567 return FTC_ImageCache_New( manager, (FTC_ImageCache*)acache ); 00568 } 00569 00570 00571 00572 FT_EXPORT_DEF( FT_Error ) 00573 FTC_Image_Cache_Lookup( FTC_ImageCache icache, 00574 FTC_OldImage_Desc* desc, 00575 FT_UInt gindex, 00576 FT_Glyph *aglyph ) 00577 { 00578 FTC_ImageTypeRec type0; 00579 00580 00581 if ( !desc ) 00582 return FTC_Err_Invalid_Argument; 00583 00584 ftc_image_type_from_old_desc( &type0, desc ); 00585 00586 return FTC_ImageCache_Lookup( (FTC_ImageCache)icache, 00587 &type0, 00588 gindex, 00589 aglyph, 00590 NULL ); 00591 } 00592 00593 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ 00594 00595 00596 /* 00597 * 00598 * basic small bitmap cache 00599 * 00600 */ 00601 00602 00603 FT_CALLBACK_TABLE_DEF 00604 const FTC_SFamilyClassRec ftc_basic_sbit_family_class = 00605 { 00606 { 00607 sizeof( FTC_BasicFamilyRec ), 00608 ftc_basic_family_compare, 00609 ftc_basic_family_init, 00610 0, /* FTC_MruNode_ResetFunc */ 00611 0 /* FTC_MruNode_DoneFunc */ 00612 }, 00613 ftc_basic_family_get_count, 00614 ftc_basic_family_load_bitmap 00615 }; 00616 00617 00618 FT_CALLBACK_TABLE_DEF 00619 const FTC_GCacheClassRec ftc_basic_sbit_cache_class = 00620 { 00621 { 00622 ftc_snode_new, 00623 ftc_snode_weight, 00624 ftc_snode_compare, 00625 ftc_basic_gnode_compare_faceid, 00626 ftc_snode_free, 00627 00628 sizeof ( FTC_GCacheRec ), 00629 ftc_gcache_init, 00630 ftc_gcache_done 00631 }, 00632 (FTC_MruListClass)&ftc_basic_sbit_family_class 00633 }; 00634 00635 00636 /* documentation is in ftcache.h */ 00637 00638 FT_EXPORT_DEF( FT_Error ) 00639 FTC_SBitCache_New( FTC_Manager manager, 00640 FTC_SBitCache *acache ) 00641 { 00642 return FTC_GCache_New( manager, &ftc_basic_sbit_cache_class, 00643 (FTC_GCache*)acache ); 00644 } 00645 00646 00647 /* documentation is in ftcache.h */ 00648 00649 FT_EXPORT_DEF( FT_Error ) 00650 FTC_SBitCache_Lookup( FTC_SBitCache cache, 00651 FTC_ImageType type, 00652 FT_UInt gindex, 00653 FTC_SBit *ansbit, 00654 FTC_Node *anode ) 00655 { 00656 FT_Error error; 00657 FTC_BasicQueryRec query; 00658 FTC_Node node = 0; /* make compiler happy */ 00659 FT_PtrDist hash; 00660 00661 00662 if ( anode ) 00663 *anode = NULL; 00664 00665 /* other argument checks delayed to FTC_Cache_Lookup */ 00666 if ( !ansbit ) 00667 return FTC_Err_Invalid_Argument; 00668 00669 *ansbit = NULL; 00670 00671 #if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU ) 00672 00673 /* This one is a major hack used to detect whether we are passed a 00674 * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one. 00675 */ 00676 if ( (FT_ULong)type->width >= 0x10000L ) 00677 { 00678 FTC_OldImageDesc desc = (FTC_OldImageDesc)type; 00679 00680 00681 query.attrs.scaler.face_id = desc->font.face_id; 00682 query.attrs.scaler.width = desc->font.pix_width; 00683 query.attrs.scaler.height = desc->font.pix_height; 00684 query.attrs.load_flags = desc->flags; 00685 } 00686 else 00687 00688 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ 00689 00690 { 00691 if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX ) 00692 { 00693 FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" )); 00694 FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) )); 00695 } 00696 00697 query.attrs.scaler.face_id = type->face_id; 00698 query.attrs.scaler.width = type->width; 00699 query.attrs.scaler.height = type->height; 00700 query.attrs.load_flags = (FT_UInt)type->flags; 00701 } 00702 00703 query.attrs.scaler.pixel = 1; 00704 query.attrs.scaler.x_res = 0; /* make compilers happy */ 00705 query.attrs.scaler.y_res = 0; 00706 00707 /* beware, the hash must be the same for all glyph ranges! */ 00708 hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + 00709 gindex / FTC_SBIT_ITEMS_PER_NODE; 00710 00711 #if 1 /* inlining is about 50% faster! */ 00712 FTC_GCACHE_LOOKUP_CMP( cache, 00713 ftc_basic_family_compare, 00714 FTC_SNode_Compare, 00715 hash, gindex, 00716 &query, 00717 node, 00718 error ); 00719 #else 00720 error = FTC_GCache_Lookup( FTC_GCACHE( cache ), 00721 hash, 00722 gindex, 00723 FTC_GQUERY( &query ), 00724 &node ); 00725 #endif 00726 if ( error ) 00727 goto Exit; 00728 00729 *ansbit = FTC_SNODE( node )->sbits + 00730 ( gindex - FTC_GNODE( node )->gindex ); 00731 00732 if ( anode ) 00733 { 00734 *anode = node; 00735 node->ref_count++; 00736 } 00737 00738 Exit: 00739 return error; 00740 } 00741 00742 00743 /* documentation is in ftcache.h */ 00744 00745 FT_EXPORT_DEF( FT_Error ) 00746 FTC_SBitCache_LookupScaler( FTC_SBitCache cache, 00747 FTC_Scaler scaler, 00748 FT_ULong load_flags, 00749 FT_UInt gindex, 00750 FTC_SBit *ansbit, 00751 FTC_Node *anode ) 00752 { 00753 FT_Error error; 00754 FTC_BasicQueryRec query; 00755 FTC_Node node = 0; /* make compiler happy */ 00756 FT_PtrDist hash; 00757 00758 00759 if ( anode ) 00760 *anode = NULL; 00761 00762 /* other argument checks delayed to FTC_Cache_Lookup */ 00763 if ( !ansbit || !scaler ) 00764 return FTC_Err_Invalid_Argument; 00765 00766 *ansbit = NULL; 00767 00768 /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */ 00769 if ( load_flags > FT_UINT_MAX ) 00770 { 00771 FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" )); 00772 FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) )); 00773 } 00774 00775 query.attrs.scaler = scaler[0]; 00776 query.attrs.load_flags = (FT_UInt)load_flags; 00777 00778 /* beware, the hash must be the same for all glyph ranges! */ 00779 hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + 00780 gindex / FTC_SBIT_ITEMS_PER_NODE; 00781 00782 FTC_GCACHE_LOOKUP_CMP( cache, 00783 ftc_basic_family_compare, 00784 FTC_SNode_Compare, 00785 hash, gindex, 00786 &query, 00787 node, 00788 error ); 00789 if ( error ) 00790 goto Exit; 00791 00792 *ansbit = FTC_SNODE( node )->sbits + 00793 ( gindex - FTC_GNODE( node )->gindex ); 00794 00795 if ( anode ) 00796 { 00797 *anode = node; 00798 node->ref_count++; 00799 } 00800 00801 Exit: 00802 return error; 00803 } 00804 00805 00806 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS 00807 00808 FT_EXPORT( FT_Error ) 00809 FTC_SBit_Cache_New( FTC_Manager manager, 00810 FTC_SBitCache *acache ); 00811 00812 FT_EXPORT( FT_Error ) 00813 FTC_SBit_Cache_Lookup( FTC_SBitCache cache, 00814 FTC_OldImage_Desc* desc, 00815 FT_UInt gindex, 00816 FTC_SBit *ansbit ); 00817 00818 00819 FT_EXPORT_DEF( FT_Error ) 00820 FTC_SBit_Cache_New( FTC_Manager manager, 00821 FTC_SBitCache *acache ) 00822 { 00823 return FTC_SBitCache_New( manager, (FTC_SBitCache*)acache ); 00824 } 00825 00826 00827 FT_EXPORT_DEF( FT_Error ) 00828 FTC_SBit_Cache_Lookup( FTC_SBitCache cache, 00829 FTC_OldImage_Desc* desc, 00830 FT_UInt gindex, 00831 FTC_SBit *ansbit ) 00832 { 00833 FTC_ImageTypeRec type0; 00834 00835 00836 if ( !desc ) 00837 return FTC_Err_Invalid_Argument; 00838 00839 ftc_image_type_from_old_desc( &type0, desc ); 00840 00841 return FTC_SBitCache_Lookup( (FTC_SBitCache)cache, 00842 &type0, 00843 gindex, 00844 ansbit, 00845 NULL ); 00846 } 00847 00848 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ 00849 00850 00851 /* END */ Generated on Sun May 27 2012 04:33:48 for ReactOS by
1.7.6.1
|