ftspic.c revision aacb8e1368a883fcbc9fe64fd0e460cef9c9b20c
1295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/***************************************************************************/ 2295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* */ 3295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* ftspic.c */ 4295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* */ 5295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* The FreeType position independent code services for smooth module. */ 6295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* */ 7aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich/* Copyright 2009, 2010 by */ 8295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* Oran Agra and Mickey Gabel. */ 9295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* */ 10295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* This file is part of the FreeType project, and may only be used, */ 11295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* modified, and distributed under the terms of the FreeType project */ 12295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* this file you indicate that you have read the license and */ 14295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* understand and accept it fully. */ 15295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* */ 16295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/***************************************************************************/ 17295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 18295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 19295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#include <ft2build.h> 20295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#include FT_FREETYPE_H 21295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#include FT_INTERNAL_OBJECTS_H 22295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#include "ftspic.h" 23295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 24295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#ifdef FT_CONFIG_OPTION_PIC 25295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 26295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* forward declaration of PIC init functions from ftgrays.c */ 27295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner void FT_Init_Class_ft_grays_raster(FT_Raster_Funcs*); 28295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 29295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner void 30295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner ft_smooth_renderer_class_pic_free( FT_Library library ) 31295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 32295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_PIC_Container* pic_container = &library->pic_container; 33295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_Memory memory = library->memory; 34295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner if ( pic_container->smooth ) 35295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 36295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner SmoothPIC* container = (SmoothPIC*)pic_container->smooth; 37295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner if(--container->ref_count) 38295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner return; 39295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_FREE( container ); 40295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner pic_container->smooth = NULL; 41295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 42295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 43295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 44295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 45295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_Error 46aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich ft_smooth_renderer_class_pic_init( FT_Library library ) 47295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 48aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich FT_PIC_Container* pic_container = &library->pic_container; 49aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich FT_Error error = Smooth_Err_Ok; 50aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich SmoothPIC* container; 51aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich FT_Memory memory = library->memory; 52aacb8e1368a883fcbc9fe64fd0e460cef9c9b20cNick Kralevich 53295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 54295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* since this function also serve smooth_lcd and smooth_lcdv renderers, 55295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner it implements reference counting */ 56295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner if(pic_container->smooth) 57295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 58295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner ((SmoothPIC*)pic_container->smooth)->ref_count++; 59295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner return error; 60295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 61295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 62295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* allocate pointer, clear and set global container pointer */ 63295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner if ( FT_ALLOC ( container, sizeof ( *container ) ) ) 64295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner return error; 65295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_MEM_SET( container, 0, sizeof(*container) ); 66295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner pic_container->smooth = container; 67295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner container->ref_count = 1; 68295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 69295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* initialize pointer table - this is how the module usually expects this data */ 70295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_Init_Class_ft_grays_raster(&container->ft_grays_raster); 71295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/*Exit:*/ 72295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner if(error) 73295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner ft_smooth_renderer_class_pic_free(library); 74295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner return error; 75295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 76295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 77295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* re-route these init and free functions to the above functions */ 78295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_Error ft_smooth_lcd_renderer_class_pic_init(FT_Library library) 79295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 80295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner return ft_smooth_renderer_class_pic_init(library); 81295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 82295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner void ft_smooth_lcd_renderer_class_pic_free(FT_Library library) 83295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 84295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner ft_smooth_renderer_class_pic_free(library); 85295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 86295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_Error ft_smooth_lcdv_renderer_class_pic_init(FT_Library library) 87295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 88295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner return ft_smooth_renderer_class_pic_init(library); 89295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 90295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner void ft_smooth_lcdv_renderer_class_pic_free(FT_Library library) 91295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 92295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner ft_smooth_renderer_class_pic_free(library); 93295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 94295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 95295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#endif /* FT_CONFIG_OPTION_PIC */ 96295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 97295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 98295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner/* END */ 99