rastpic.c

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  rastpic.c                                                              */
00004 /*                                                                         */
00005 /*    The FreeType position independent code services for raster 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 "rastpic.h"
00023 
00024 #ifdef FT_CONFIG_OPTION_PIC
00025 
00026   /* forward declaration of PIC init functions from ftraster.c */
00027   void FT_Init_Class_ft_standard_raster(FT_Raster_Funcs*);
00028 
00029   void
00030   ft_raster1_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->raster )
00035     {
00036       RasterPIC* container = (RasterPIC*)pic_container->raster;
00037       if(--container->ref_count)
00038         return;
00039       FT_FREE( container );
00040       pic_container->raster = NULL;
00041     }
00042   }
00043 
00044 
00045   FT_Error
00046   ft_raster1_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     RasterPIC* container;
00051     FT_Memory memory = library->memory;
00052 
00053     /* since this function also serve raster5 renderer, 
00054        it implements reference counting */
00055     if(pic_container->raster)
00056     {
00057       ((RasterPIC*)pic_container->raster)->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->raster = 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_standard_raster(&container->ft_standard_raster);
00070 /*Exit:*/
00071     if(error)
00072       ft_raster1_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_raster5_renderer_class_pic_init(FT_Library library)
00078   {
00079     return ft_raster1_renderer_class_pic_init(library);
00080   }
00081   void ft_raster5_renderer_class_pic_free(FT_Library library)
00082   {
00083     ft_raster1_renderer_class_pic_free(library);
00084   }
00085 
00086 #endif /* FT_CONFIG_OPTION_PIC */
00087 
00088 
00089 /* END */

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