#endif
struct font_freetype_methods freetype_methods;
/* </main> */
+ unsigned char * ft_buffer;
+ unsigned int ft_buffer_size;
};
static int dummy;
static char sdl_next_orientation = WEBOS_ORIENTATION_PORTRAIT;
# endif
#endif
-static unsigned char * ft_buffer = NULL;
-static unsigned int ft_buffer_size = 0;
struct graphics_font_priv {
#ifdef SDL_TTF
{
dbg(0, "graphics_destroy %p %u\n", gr, gr->overlay_mode);
- g_free (ft_buffer);
+ if (gr->ft_buffer) {
+ g_free (gr->ft_buffer);
+ gr->ft_buffer = NULL;
+ }
if(gr->overlay_mode)
{
static void
-resize_ft_buffer (unsigned int new_size)
+resize_ft_buffer (struct graphics_priv *gr, unsigned int new_size)
{
- if (new_size > ft_buffer_size) {
- g_free (ft_buffer);
- ft_buffer = g_malloc (new_size);
- dbg(1, "old_size(%i) new_size(%i) ft_buffer(%i)\n", ft_buffer_size, new_size, ft_buffer);
- ft_buffer_size = new_size;
+ if (new_size > gr->ft_buffer_size) {
+ if (gr->ft_buffer)
+ g_free (gr->ft_buffer);
+ gr->ft_buffer = g_malloc (new_size);
+ dbg(1, "old_size(%i) new_size(%i) ft_buffer(%i)\n", gr->ft_buffer_size, new_size, gr->ft_buffer);
+ gr->ft_buffer_size = new_size;
}
}
if (g->w && g->h && bg) {
stride = (g->w + 2) * 4;
if (color) {
- resize_ft_buffer(stride * (g->h + 2));
- gr->freetype_methods.get_shadow(g, ft_buffer, 32, stride, &white, &transparent);
+ resize_ft_buffer(gr, stride * (g->h + 2));
+ gr->freetype_methods.get_shadow(g, gr->ft_buffer, 32, stride, &white, &transparent);
SDL_Surface *glyph_surface =
- SDL_CreateRGBSurfaceFrom(ft_buffer, g->w + 2, g->h + 2,
+ SDL_CreateRGBSurfaceFrom(gr->ft_buffer, g->w + 2, g->h + 2,
32,
stride,
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
if (color) {
stride = g->w;
if (bg) {
- resize_ft_buffer(stride * g->h * 4);
- gr->freetype_methods.get_glyph(g, ft_buffer, 32,
+ resize_ft_buffer(gr, stride * g->h * 4);
+ gr->freetype_methods.get_glyph(g, gr->ft_buffer, 32,
stride * 4, &black,
&white, &transparent);
SDL_Surface *glyph_surface =
- SDL_CreateRGBSurfaceFrom(ft_buffer, g->w, g->h, 32,
+ SDL_CreateRGBSurfaceFrom(gr->ft_buffer, g->w, g->h, 32,
stride * 4,
0x000000ff,0x0000ff00, 0x00ff0000,0xff000000);
if (glyph_surface) {
}
}
stride *= 4;
- resize_ft_buffer(stride * g->h);
- gr->freetype_methods.get_glyph(g, ft_buffer, 32, stride,
+ resize_ft_buffer(gr, stride * g->h);
+ gr->freetype_methods.get_glyph(g, gr->ft_buffer, 32, stride,
&black, &white,
&transparent);
int ii, jj;
- unsigned char* pGlyph = ft_buffer;
+ unsigned char* pGlyph = gr->ft_buffer;
for (jj = 0; jj < g->h; ++jj) {
for (ii = 0; ii < g->w; ++ii) {
if(*(pGlyph+3) > 0) {