diff options
author | 11rcombs <rodger.combs@gmail.com> | 2014-01-25 19:06:12 -0600 |
---|---|---|
committer | 11rcombs <rodger.combs@gmail.com> | 2014-01-25 19:09:15 -0600 |
commit | 5dd56af2f97419ce5a72d1dab2e9c19b34c1dd57 (patch) | |
tree | 1997f519ae3d5f75a76a3cee3dd95034e513210a /libass/ass_render.h | |
parent | fa3b6fa3ee1de42232f0513539af2464a3c9203a (diff) | |
download | libass-5dd56af2f97419ce5a72d1dab2e9c19b34c1dd57.tar.bz2 libass-5dd56af2f97419ce5a72d1dab2e9c19b34c1dd57.tar.xz |
Combine bitmaps before applying blur and shadow
Diffstat (limited to 'libass/ass_render.h')
-rw-r--r-- | libass/ass_render.h | 76 |
1 files changed, 74 insertions, 2 deletions
diff --git a/libass/ass_render.h b/libass/ass_render.h index a41586b5..ab0b7046 100644 --- a/libass/ass_render.h +++ b/libass/ass_render.h @@ -41,9 +41,11 @@ typedef struct ass_shaper ASS_Shaper; #include "ass_fontconfig.h" #include "ass_library.h" #include "ass_drawing.h" +#include "ass_bitmap.h" -#define GLYPH_CACHE_MAX 1000 -#define BITMAP_CACHE_MAX_SIZE 30 * 1048576 +#define GLYPH_CACHE_MAX 10000 +#define BITMAP_CACHE_MAX_SIZE 500 * 1048576 +#define COMPOSITE_CACHE_MAX_SIZE 500 * 1048576 #define PARSED_FADE (1<<0) #define PARSED_A (1<<1) @@ -103,6 +105,49 @@ typedef enum { EF_KARAOKE_KO } Effect; +// describes a combined bitmap +typedef struct { + Bitmap *bm; // glyphs bitmap + unsigned w; + unsigned h; + Bitmap *bm_o; // outline bitmap + unsigned o_w; + unsigned o_h; + Bitmap *bm_s; // shadow bitmap + FT_Vector pos; + uint32_t c[4]; // colors + FT_Vector advance; // 26.6 + Effect effect_type; + int effect_timing; // time duration of current karaoke word + // after process_karaoke_effects: distance in pixels from the glyph origin. + // part of the glyph to the left of it is displayed in a different color. + int be; // blur edges + double blur; // gaussian blur + double shadow_x; + double shadow_y; + double frx, fry, frz; // rotation + double fax, fay; // text shearing + double scale_x, scale_y; + int border_style; + int has_border; + double border_x, border_y; + double hspacing; + unsigned italic; + unsigned bold; + int flags; + + unsigned has_outline; + unsigned is_drawing; + + int max_str_length; + int str_length; + unsigned chars; + char *str; + int cached; + FT_Vector pos_orig; + int first_pos_x; +} CombinedBitmapInfo; + // describes a glyph // GlyphInfo and TextInfo are used for text centering and word-wrapping operations typedef struct glyph_info { @@ -130,6 +175,7 @@ typedef struct glyph_info { uint32_t c[4]; // colors FT_Vector advance; // 26.6 FT_Vector cluster_advance; + char effect; // the first (leading) glyph of some effect ? Effect effect_type; int effect_timing; // time duration of current karaoke word // after process_karaoke_effects: distance in pixels from the glyph origin. @@ -170,9 +216,12 @@ typedef struct { int length; LineInfo *lines; int n_lines; + CombinedBitmapInfo *combined_bitmaps; + unsigned n_bitmaps; double height; int max_glyphs; int max_lines; + unsigned max_bitmaps; } TextInfo; // Renderer state. @@ -251,8 +300,23 @@ typedef struct { Cache *composite_cache; size_t glyph_max; size_t bitmap_max_size; + size_t composite_max_size; } CacheStore; +typedef void (*BitmapBlendFunc)(uint8_t *dst, intptr_t dst_stride, + uint8_t *src, intptr_t src_stride, + intptr_t height, intptr_t width); +typedef void (*BitmapMulFunc)(uint8_t *dst, intptr_t dst_stride, + uint8_t *src1, intptr_t src1_stride, + uint8_t *src2, intptr_t src2_stride, + intptr_t width, intptr_t height); +typedef void (*BEBlurFunc)(uint8_t *buf, intptr_t w, + intptr_t h, intptr_t stride, + uint16_t *tmp); +typedef void (*RestrideBitmapFunc)(uint8_t *dst, intptr_t dst_stride, + uint8_t *src, intptr_t src_stride, + intptr_t width, intptr_t height); + struct ass_renderer { ASS_Library *library; FT_Library ftlibrary; @@ -288,6 +352,12 @@ struct ass_renderer { TextInfo text_info; CacheStore cache; + BitmapBlendFunc add_bitmaps_func; + BitmapBlendFunc sub_bitmaps_func; + BitmapMulFunc mul_bitmaps_func; + BEBlurFunc be_blur_func; + RestrideBitmapFunc restride_bitmap_func; + FreeList *free_head; FreeList *free_tail; }; @@ -311,6 +381,8 @@ typedef struct { void reset_render_context(ASS_Renderer *render_priv, ASS_Style *style); void ass_free_images(ASS_Image *img); +void make_shadow_bitmap(CombinedBitmapInfo* info); +void apply_blur(CombinedBitmapInfo* info, ASS_Renderer *render_priv); // XXX: this is actually in ass.c, includes should be fixed later on void ass_lazy_track_init(ASS_Library *lib, ASS_Track *track); |