/src/compiler/android-ndk/jni/freetype/src/smooth/ftspic.c

http://ftk.googlecode.com/ · C · 97 lines · 59 code · 14 blank · 24 comment · 5 complexity · bc973f0addfb7d7a488fcc3928f71d8f MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftspic.c */
  4. /* */
  5. /* The FreeType position independent code services for smooth module. */
  6. /* */
  7. /* Copyright 2009 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. #ifdef FT_CONFIG_OPTION_PIC
  22. /* forward declaration of PIC init functions from ftgrays.c */
  23. void FT_Init_Class_ft_grays_raster(FT_Raster_Funcs*);
  24. void
  25. ft_smooth_renderer_class_pic_free( FT_Library library )
  26. {
  27. FT_PIC_Container* pic_container = &library->pic_container;
  28. FT_Memory memory = library->memory;
  29. if ( pic_container->smooth )
  30. {
  31. SmoothPIC* container = (SmoothPIC*)pic_container->smooth;
  32. if(--container->ref_count)
  33. return;
  34. FT_FREE( container );
  35. pic_container->smooth = NULL;
  36. }
  37. }
  38. FT_Error
  39. ft_smooth_renderer_class_pic_init( FT_Library library )
  40. {
  41. FT_PIC_Container* pic_container = &library->pic_container;
  42. FT_Error error = FT_Err_Ok;
  43. SmoothPIC* container;
  44. FT_Memory memory = library->memory;
  45. /* since this function also serve smooth_lcd and smooth_lcdv renderers,
  46. it implements reference counting */
  47. if(pic_container->smooth)
  48. {
  49. ((SmoothPIC*)pic_container->smooth)->ref_count++;
  50. return error;
  51. }
  52. /* allocate pointer, clear and set global container pointer */
  53. if ( FT_ALLOC ( container, sizeof ( *container ) ) )
  54. return error;
  55. FT_MEM_SET( container, 0, sizeof(*container) );
  56. pic_container->smooth = container;
  57. container->ref_count = 1;
  58. /* initialize pointer table - this is how the module usually expects this data */
  59. FT_Init_Class_ft_grays_raster(&container->ft_grays_raster);
  60. /*Exit:*/
  61. if(error)
  62. ft_smooth_renderer_class_pic_free(library);
  63. return error;
  64. }
  65. /* re-route these init and free functions to the above functions */
  66. FT_Error ft_smooth_lcd_renderer_class_pic_init(FT_Library library)
  67. {
  68. return ft_smooth_renderer_class_pic_init(library);
  69. }
  70. void ft_smooth_lcd_renderer_class_pic_free(FT_Library library)
  71. {
  72. ft_smooth_renderer_class_pic_free(library);
  73. }
  74. FT_Error ft_smooth_lcdv_renderer_class_pic_init(FT_Library library)
  75. {
  76. return ft_smooth_renderer_class_pic_init(library);
  77. }
  78. void ft_smooth_lcdv_renderer_class_pic_free(FT_Library library)
  79. {
  80. ft_smooth_renderer_class_pic_free(library);
  81. }
  82. #endif /* FT_CONFIG_OPTION_PIC */
  83. /* END */