Edit

kc3-lang/freetype/src/cache/ftcimage.c

Branch :

  • Show log

    Commit

  • Author : Werner Lemberg
    Date : 2004-05-17 09:25:04
    Hash : e260d253
    Message : * 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.

  • src/cache/ftcimage.c
  • /***************************************************************************/
    /*                                                                         */
    /*  ftcimage.c                                                             */
    /*                                                                         */
    /*    FreeType Image cache (body).                                         */
    /*                                                                         */
    /*  Copyright 2000-2001, 2003, 2004 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.                                        */
    /*                                                                         */
    /***************************************************************************/
    
    
    #include <ft2build.h>
    #include FT_CACHE_H
    #include FT_CACHE_INTERNAL_IMAGE_H
    #include FT_INTERNAL_MEMORY_H
    
    #include "ftccback.h"
    #include "ftcerror.h"
    
    
      /* finalize a given glyph image node */
      FT_EXPORT_DEF( void )
      FTC_INode_Free( FTC_INode  inode,
                      FTC_Cache  cache )
      {
        FT_Memory  memory = cache->memory;
    
    
        if ( inode->glyph )
        {
          FT_Done_Glyph( inode->glyph );
          inode->glyph = NULL;
        }
    
        FTC_GNode_Done( FTC_GNODE( inode ), cache );
        FT_FREE( inode );
      }
    
    
      FT_LOCAL_DEF( void )
      ftc_inode_free( FTC_Node   ftcinode,
                      FTC_Cache  cache )
      {
        FTC_INode  inode = (FTC_INode)ftcinode;
    
    
        FTC_INode_Free( inode, cache );
      }
    
    
      /* initialize a new glyph image node */
      FT_EXPORT_DEF( FT_Error )
      FTC_INode_New( FTC_INode   *pinode,
                     FTC_GQuery   gquery,
                     FTC_Cache    cache )
      {
        FT_Memory  memory = cache->memory;
        FT_Error   error;
        FTC_INode  inode;
    
    
        if ( !FT_NEW( inode ) )
        {
          FTC_GNode         gnode  = FTC_GNODE( inode );
          FTC_Family        family = gquery->family;
          FT_UInt           gindex = gquery->gindex;
          FTC_IFamilyClass  clazz  = FTC_CACHE__IFAMILY_CLASS( cache );
    
    
          /* initialize its inner fields */
          FTC_GNode_Init( gnode, gindex, family );
    
          /* we will now load the glyph image */
          error = clazz->family_load_glyph( family, gindex, cache,
                                            &inode->glyph );
        }
    
        *pinode = inode;
        return error;
      }
    
    
      FT_LOCAL_DEF( FT_Error )
      ftc_inode_new( FTC_Node   *ftcpinode,
                     FT_Pointer  ftcgquery,
                     FTC_Cache   cache )
      {
        FTC_INode  *pinode = (FTC_INode*)ftcpinode;
        FTC_GQuery  gquery = (FTC_GQuery)ftcgquery;
    
    
        return FTC_INode_New( pinode, gquery, cache );
      }
    
    
      FT_EXPORT_DEF( FT_ULong )
      FTC_INode_Weight( FTC_INode  inode )
      {
        FT_ULong  size  = 0;
        FT_Glyph  glyph = inode->glyph;
    
    
        switch ( glyph->format )
        {
        case FT_GLYPH_FORMAT_BITMAP:
          {
            FT_BitmapGlyph  bitg;
    
    
            bitg = (FT_BitmapGlyph)glyph;
            size = bitg->bitmap.rows * labs( bitg->bitmap.pitch ) +
                   sizeof ( *bitg );
          }
          break;
    
        case FT_GLYPH_FORMAT_OUTLINE:
          {
            FT_OutlineGlyph  outg;
    
    
            outg = (FT_OutlineGlyph)glyph;
            size = outg->outline.n_points *
                     ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
                   outg->outline.n_contours * sizeof ( FT_Short ) +
                   sizeof ( *outg );
          }
          break;
    
        default:
          ;
        }
    
        size += sizeof ( *inode );
        return size;
      }
    
    
      FT_LOCAL_DEF( FT_ULong )
      ftc_inode_weight( FTC_Node   ftcinode,
                        FTC_Cache  ftccache )
      {
        FTC_INode  inode = (FTC_INode)ftcinode;
        FT_UNUSED( ftccache );
    
    
        return FTC_INode_Weight( inode );
      }
    
    
    /* END */