2006-10-01 17:09:04 +00:00
|
|
|
// -*- c-basic-offset: 8; indent-tabs-mode: t -*-
|
|
|
|
// vim:ts=8:sw=8:noet:ai:
|
|
|
|
/*
|
2008-05-13 08:02:23 +00:00
|
|
|
* Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
|
|
|
|
*
|
2008-05-14 17:21:58 +00:00
|
|
|
* This file is part of libass.
|
2008-05-13 08:02:23 +00:00
|
|
|
*
|
2008-05-14 17:21:58 +00:00
|
|
|
* libass is free software; you can redistribute it and/or modify
|
2008-05-13 08:02:23 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2008-05-14 17:21:58 +00:00
|
|
|
* libass is distributed in the hope that it will be useful,
|
2008-05-13 08:02:23 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2008-05-14 17:21:58 +00:00
|
|
|
* with libass; if not, write to the Free Software Foundation, Inc.,
|
2008-05-13 08:02:23 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2006-10-01 17:09:04 +00:00
|
|
|
|
2008-01-29 23:25:11 +00:00
|
|
|
#ifndef LIBASS_CACHE_H
|
|
|
|
#define LIBASS_CACHE_H
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2008-03-05 08:24:09 +00:00
|
|
|
#include "ass.h"
|
|
|
|
#include "ass_font.h"
|
|
|
|
#include "ass_bitmap.h"
|
|
|
|
|
2006-11-26 20:34:54 +00:00
|
|
|
void ass_font_cache_init(void);
|
2006-11-27 17:13:52 +00:00
|
|
|
ass_font_t* ass_font_cache_find(ass_font_desc_t* desc);
|
2007-05-03 19:13:54 +00:00
|
|
|
void* ass_font_cache_add(ass_font_t* font);
|
2006-11-26 20:34:54 +00:00
|
|
|
void ass_font_cache_done(void);
|
2006-07-07 18:26:51 +00:00
|
|
|
|
|
|
|
|
2007-04-20 23:02:20 +00:00
|
|
|
// describes a bitmap; bitmaps with equivalents structs are considered identical
|
|
|
|
typedef struct bitmap_hash_key_s {
|
2006-07-07 18:26:51 +00:00
|
|
|
char bitmap; // bool : true = bitmap, false = outline
|
2006-11-28 22:17:33 +00:00
|
|
|
ass_font_t* font;
|
2007-05-14 20:41:14 +00:00
|
|
|
double size; // font size
|
2006-11-28 22:17:33 +00:00
|
|
|
uint32_t ch; // character code
|
2006-07-07 18:26:51 +00:00
|
|
|
unsigned outline; // border width, 16.16 fixed point value
|
|
|
|
int bold, italic;
|
2006-09-16 13:32:46 +00:00
|
|
|
char be; // blur edges
|
2009-02-07 01:13:02 +00:00
|
|
|
double blur; // gaussian blur
|
2006-07-07 18:26:51 +00:00
|
|
|
|
|
|
|
unsigned scale_x, scale_y; // 16.16
|
2007-02-16 17:54:47 +00:00
|
|
|
int frx, fry, frz; // signed 16.16
|
2007-04-20 23:19:23 +00:00
|
|
|
int shift_x, shift_y; // shift vector that was added to glyph before applying rotation
|
|
|
|
// = 0, if frx = fry = frx = 0
|
|
|
|
// = (glyph base point) - (rotation origin), otherwise
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2006-07-07 18:26:51 +00:00
|
|
|
FT_Vector advance; // subpixel shift vector
|
2007-04-20 23:02:20 +00:00
|
|
|
} bitmap_hash_key_t;
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2007-04-20 23:02:20 +00:00
|
|
|
typedef struct bitmap_hash_val_s {
|
|
|
|
bitmap_t* bm; // the actual bitmaps
|
2006-09-16 13:08:17 +00:00
|
|
|
bitmap_t* bm_o;
|
2006-09-24 16:04:37 +00:00
|
|
|
bitmap_t* bm_s;
|
2007-04-20 23:02:20 +00:00
|
|
|
} bitmap_hash_val_t;
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2007-04-20 23:02:20 +00:00
|
|
|
void ass_bitmap_cache_init(void);
|
2007-05-03 19:13:54 +00:00
|
|
|
void* cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val);
|
2007-04-20 23:02:20 +00:00
|
|
|
bitmap_hash_val_t* cache_find_bitmap(bitmap_hash_key_t* key);
|
|
|
|
void ass_bitmap_cache_reset(void);
|
|
|
|
void ass_bitmap_cache_done(void);
|
2006-07-07 18:26:51 +00:00
|
|
|
|
2009-03-05 20:47:33 +00:00
|
|
|
|
|
|
|
// Cache for composited bitmaps
|
|
|
|
typedef struct composite_hash_key_s {
|
|
|
|
int aw, ah, bw, bh;
|
|
|
|
int ax, ay, bx, by;
|
|
|
|
bitmap_hash_key_t a;
|
|
|
|
bitmap_hash_key_t b;
|
|
|
|
} composite_hash_key_t;
|
|
|
|
|
|
|
|
typedef struct composite_hash_val_s {
|
|
|
|
unsigned char* a;
|
|
|
|
unsigned char* b;
|
|
|
|
} composite_hash_val_t;
|
|
|
|
|
|
|
|
void ass_composite_cache_init(void);
|
|
|
|
void* cache_add_composite(composite_hash_key_t* key, composite_hash_val_t* val);
|
|
|
|
composite_hash_val_t* cache_find_composite(composite_hash_key_t* key);
|
|
|
|
void ass_composite_cache_reset(void);
|
|
|
|
void ass_composite_cache_done(void);
|
|
|
|
|
|
|
|
|
2007-04-20 23:04:21 +00:00
|
|
|
// describes an outline glyph
|
|
|
|
typedef struct glyph_hash_key_s {
|
|
|
|
ass_font_t* font;
|
2007-05-14 20:41:14 +00:00
|
|
|
double size; // font size
|
2007-04-20 23:04:21 +00:00
|
|
|
uint32_t ch; // character code
|
|
|
|
int bold, italic;
|
|
|
|
unsigned scale_x, scale_y; // 16.16
|
|
|
|
FT_Vector advance; // subpixel shift vector
|
2007-05-01 14:29:28 +00:00
|
|
|
unsigned outline; // border width, 16.16
|
2007-04-20 23:04:21 +00:00
|
|
|
} glyph_hash_key_t;
|
|
|
|
|
|
|
|
typedef struct glyph_hash_val_s {
|
|
|
|
FT_Glyph glyph;
|
2007-04-20 23:13:34 +00:00
|
|
|
FT_Glyph outline_glyph;
|
2007-04-20 23:04:21 +00:00
|
|
|
FT_BBox bbox_scaled; // bbox after scaling, but before rotation
|
|
|
|
FT_Vector advance; // 26.6, advance distance to the next bitmap in line
|
|
|
|
} glyph_hash_val_t;
|
|
|
|
|
|
|
|
void ass_glyph_cache_init(void);
|
2007-05-03 19:13:54 +00:00
|
|
|
void* cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val);
|
2007-04-20 23:04:21 +00:00
|
|
|
glyph_hash_val_t* cache_find_glyph(glyph_hash_key_t* key);
|
|
|
|
void ass_glyph_cache_reset(void);
|
|
|
|
void ass_glyph_cache_done(void);
|
|
|
|
|
2009-05-13 02:58:57 +00:00
|
|
|
typedef struct hashmap_s hashmap_t;
|
2007-04-20 23:00:30 +00:00
|
|
|
typedef void (*hashmap_item_dtor_t)(void* key, size_t key_size, void* value, size_t value_size);
|
|
|
|
typedef int (*hashmap_key_compare_t)(void* key1, void* key2, size_t key_size);
|
|
|
|
typedef unsigned (*hashmap_hash_t)(void* key, size_t key_size);
|
|
|
|
|
|
|
|
hashmap_t* hashmap_init(size_t key_size, size_t value_size, int nbuckets,
|
|
|
|
hashmap_item_dtor_t item_dtor, hashmap_key_compare_t key_compare,
|
|
|
|
hashmap_hash_t hash);
|
|
|
|
void hashmap_done(hashmap_t* map);
|
2007-05-03 19:13:54 +00:00
|
|
|
void* hashmap_insert(hashmap_t* map, void* key, void* value);
|
2007-04-20 23:00:30 +00:00
|
|
|
void* hashmap_find(hashmap_t* map, void* key);
|
|
|
|
|
2008-01-29 23:25:11 +00:00
|
|
|
#endif /* LIBASS_CACHE_H */
|