ftspic.c

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  ftspic.c                                                               */
00004 /*                                                                         */
00005 /*    The FreeType position independent code services for smooth module.   */
00006 /*                                                                         */
00007 /*  Copyright 2009 by                                                      */
00008 /*  Oran Agra and Mickey Gabel.                                            */
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_FREETYPE_H
00021 #include FT_INTERNAL_OBJECTS_H
00022 #include "ftspic.h"
00023 
00024 #ifdef FT_CONFIG_OPTION_PIC
00025 
00026   /* forward declaration of PIC init functions from ftgrays.c */
00027   void FT_Init_Class_ft_grays_raster(FT_Raster_Funcs*);
00028 
00029   void
00030   ft_smooth_renderer_class_pic_free(  FT_Library library )
00031   {
00032     FT_PIC_Container* pic_container = &library->pic_container;
00033     FT_Memory memory = library->memory;
00034     if ( pic_container->smooth )
00035     {
00036       SmoothPIC* container = (SmoothPIC*)pic_container->smooth;
00037       if(--container->ref_count)
00038         return;
00039       FT_FREE( container );
00040       pic_container->smooth = NULL;
00041     }
00042   }
00043 
00044 
00045   FT_Error
00046   ft_smooth_renderer_class_pic_init(  FT_Library library )
00047   {
00048     FT_PIC_Container* pic_container = &library->pic_container;
00049     FT_Error        error = FT_Err_Ok;
00050     SmoothPIC* container;
00051     FT_Memory memory = library->memory;
00052 
00053     /* since this function also serve smooth_lcd and smooth_lcdv renderers, 
00054        it implements reference counting */
00055     if(pic_container->smooth)
00056     {
00057       ((SmoothPIC*)pic_container->smooth)->ref_count++;
00058       return error;
00059     }
00060 
00061     /* allocate pointer, clear and set global container pointer */
00062     if ( FT_ALLOC ( container, sizeof ( *container ) ) )
00063       return error;
00064     FT_MEM_SET( container, 0, sizeof(*container) );
00065     pic_container->smooth = container;
00066     container->ref_count = 1;
00067 
00068     /* initialize pointer table - this is how the module usually expects this data */
00069     FT_Init_Class_ft_grays_raster(&container->ft_grays_raster);
00070 /*Exit:*/
00071     if(error)
00072       ft_smooth_renderer_class_pic_free(library);
00073     return error;
00074   }
00075 
00076   /* re-route these init and free functions to the above functions */
00077   FT_Error ft_smooth_lcd_renderer_class_pic_init(FT_Library library)
00078   {
00079     return ft_smooth_renderer_class_pic_init(library);
00080   }
00081   void ft_smooth_lcd_renderer_class_pic_free(FT_Library library)
00082   {
00083     ft_smooth_renderer_class_pic_free(library);
00084   }
00085   FT_Error ft_smooth_lcdv_renderer_class_pic_init(FT_Library library)
00086   {
00087     return ft_smooth_renderer_class_pic_init(library);
00088   }
00089   void ft_smooth_lcdv_renderer_class_pic_free(FT_Library library)
00090   {
00091     ft_smooth_renderer_class_pic_free(library);
00092   }
00093 
00094 #endif /* FT_CONFIG_OPTION_PIC */
00095 
00096 
00097 /* END */

Generated on Tue Jul 5 14:13:51 2011 for ROOT_528-00b_version by  doxygen 1.5.1