/src/freetype/src/smooth/ftspic.c

https://bitbucket.org/cabalistic/ogredeps/ · C · 107 lines · 61 code · 22 blank · 24 comment · 5 complexity · 7545106eff1b96ac2ec88a5476840852 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftspic.c */
  4. /* */
  5. /* The FreeType position independent code services for smooth module. */
  6. /* */
  7. /* Copyright 2009, 2010 by */
  8. /* Oran Agra and Mickey Gabel. */
  9. /* */
  10. /* This file is part of the FreeType project, and may only be used, */
  11. /* modified, and distributed under the terms of the FreeType project */
  12. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  13. /* this file you indicate that you have read the license and */
  14. /* understand and accept it fully. */
  15. /* */
  16. /***************************************************************************/
  17. #include <ft2build.h>
  18. #include FT_FREETYPE_H
  19. #include FT_INTERNAL_OBJECTS_H
  20. #include "ftspic.h"
  21. #include "ftsmerrs.h"
  22. #ifdef FT_CONFIG_OPTION_PIC
  23. /* forward declaration of PIC init functions from ftgrays.c */
  24. void
  25. FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs );
  26. void
  27. ft_smooth_renderer_class_pic_free( FT_Library library )
  28. {
  29. FT_PIC_Container* pic_container = &library->pic_container;
  30. FT_Memory memory = library->memory;
  31. if ( pic_container->smooth )
  32. {
  33. SmoothPIC* container = (SmoothPIC*)pic_container->smooth;
  34. if ( --container->ref_count )
  35. return;
  36. FT_FREE( container );
  37. pic_container->smooth = NULL;
  38. }
  39. }
  40. FT_Error
  41. ft_smooth_renderer_class_pic_init( FT_Library library )
  42. {
  43. FT_PIC_Container* pic_container = &library->pic_container;
  44. FT_Error error = Smooth_Err_Ok;
  45. SmoothPIC* container;
  46. FT_Memory memory = library->memory;
  47. /* since this function also serve smooth_lcd and smooth_lcdv renderers,
  48. it implements reference counting */
  49. if ( pic_container->smooth )
  50. {
  51. ((SmoothPIC*)pic_container->smooth)->ref_count++;
  52. return error;
  53. }
  54. /* allocate pointer, clear and set global container pointer */
  55. if ( FT_ALLOC ( container, sizeof ( *container ) ) )
  56. return error;
  57. FT_MEM_SET( container, 0, sizeof ( *container ) );
  58. pic_container->smooth = container;
  59. container->ref_count = 1;
  60. /* initialize pointer table - this is how the module usually expects this data */
  61. FT_Init_Class_ft_grays_raster( &container->ft_grays_raster );
  62. /*Exit:*/
  63. if ( error )
  64. ft_smooth_renderer_class_pic_free( library );
  65. return error;
  66. }
  67. /* re-route these init and free functions to the above functions */
  68. FT_Error ft_smooth_lcd_renderer_class_pic_init( FT_Library library )
  69. {
  70. return ft_smooth_renderer_class_pic_init( library );
  71. }
  72. void ft_smooth_lcd_renderer_class_pic_free( FT_Library library )
  73. {
  74. ft_smooth_renderer_class_pic_free( library );
  75. }
  76. FT_Error ft_smooth_lcdv_renderer_class_pic_init( FT_Library library )
  77. {
  78. return ft_smooth_renderer_class_pic_init( library );
  79. }
  80. void ft_smooth_lcdv_renderer_class_pic_free( FT_Library library )
  81. {
  82. ft_smooth_renderer_class_pic_free( library );
  83. }
  84. #endif /* FT_CONFIG_OPTION_PIC */
  85. /* END */