31853
|
1 /*
|
|
2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
|
|
3 * Copyright (C) 2010 Grigori Goronzy <greg@geekmind.org>
|
|
4 *
|
|
5 * This file is part of libass.
|
|
6 *
|
34011
|
7 * Permission to use, copy, modify, and distribute this software for any
|
|
8 * purpose with or without fee is hereby granted, provided that the above
|
|
9 * copyright notice and this permission notice appear in all copies.
|
31853
|
10 *
|
34011
|
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
31853
|
18 */
|
|
19
|
|
20 #include "config.h"
|
|
21 #include "ass_render.h"
|
|
22
|
|
23 static void ass_reconfigure(ASS_Renderer *priv)
|
|
24 {
|
|
25 ASS_Settings *settings = &priv->settings;
|
|
26
|
|
27 priv->render_id++;
|
34295
|
28 ass_cache_empty(priv->cache.outline_cache, 0);
|
|
29 ass_cache_empty(priv->cache.bitmap_cache, 0);
|
|
30 ass_cache_empty(priv->cache.composite_cache, 0);
|
31853
|
31 ass_free_images(priv->prev_images_root);
|
|
32 priv->prev_images_root = 0;
|
|
33
|
|
34 priv->width = settings->frame_width;
|
|
35 priv->height = settings->frame_height;
|
|
36 priv->orig_width = settings->frame_width - settings->left_margin -
|
|
37 settings->right_margin;
|
|
38 priv->orig_height = settings->frame_height - settings->top_margin -
|
|
39 settings->bottom_margin;
|
|
40 priv->orig_width_nocrop =
|
|
41 settings->frame_width - FFMAX(settings->left_margin, 0) -
|
|
42 FFMAX(settings->right_margin, 0);
|
|
43 priv->orig_height_nocrop =
|
|
44 settings->frame_height - FFMAX(settings->top_margin, 0) -
|
|
45 FFMAX(settings->bottom_margin, 0);
|
|
46 }
|
|
47
|
|
48 void ass_set_frame_size(ASS_Renderer *priv, int w, int h)
|
|
49 {
|
|
50 if (priv->settings.frame_width != w || priv->settings.frame_height != h) {
|
|
51 priv->settings.frame_width = w;
|
|
52 priv->settings.frame_height = h;
|
|
53 if (priv->settings.aspect == 0.) {
|
|
54 priv->settings.aspect = ((double) w) / h;
|
|
55 priv->settings.storage_aspect = ((double) w) / h;
|
|
56 }
|
|
57 ass_reconfigure(priv);
|
|
58 }
|
|
59 }
|
|
60
|
34295
|
61 void ass_set_shaper(ASS_Renderer *priv, ASS_ShapingLevel level)
|
|
62 {
|
|
63 #ifdef CONFIG_HARFBUZZ
|
|
64 // select the complex shaper for illegal values
|
|
65 if (level == ASS_SHAPING_SIMPLE || level == ASS_SHAPING_COMPLEX)
|
|
66 priv->settings.shaper = level;
|
|
67 else
|
|
68 priv->settings.shaper = ASS_SHAPING_COMPLEX;
|
|
69 #endif
|
|
70 }
|
|
71
|
31853
|
72 void ass_set_margins(ASS_Renderer *priv, int t, int b, int l, int r)
|
|
73 {
|
|
74 if (priv->settings.left_margin != l || priv->settings.right_margin != r ||
|
|
75 priv->settings.top_margin != t || priv->settings.bottom_margin != b) {
|
|
76 priv->settings.left_margin = l;
|
|
77 priv->settings.right_margin = r;
|
|
78 priv->settings.top_margin = t;
|
|
79 priv->settings.bottom_margin = b;
|
|
80 ass_reconfigure(priv);
|
|
81 }
|
|
82 }
|
|
83
|
|
84 void ass_set_use_margins(ASS_Renderer *priv, int use)
|
|
85 {
|
|
86 priv->settings.use_margins = use;
|
|
87 }
|
|
88
|
|
89 void ass_set_aspect_ratio(ASS_Renderer *priv, double dar, double sar)
|
|
90 {
|
|
91 if (priv->settings.aspect != dar || priv->settings.storage_aspect != sar) {
|
|
92 priv->settings.aspect = dar;
|
|
93 priv->settings.storage_aspect = sar;
|
|
94 ass_reconfigure(priv);
|
|
95 }
|
|
96 }
|
|
97
|
|
98 void ass_set_font_scale(ASS_Renderer *priv, double font_scale)
|
|
99 {
|
|
100 if (priv->settings.font_size_coeff != font_scale) {
|
|
101 priv->settings.font_size_coeff = font_scale;
|
|
102 ass_reconfigure(priv);
|
|
103 }
|
|
104 }
|
|
105
|
|
106 void ass_set_hinting(ASS_Renderer *priv, ASS_Hinting ht)
|
|
107 {
|
|
108 if (priv->settings.hinting != ht) {
|
|
109 priv->settings.hinting = ht;
|
|
110 ass_reconfigure(priv);
|
|
111 }
|
|
112 }
|
|
113
|
|
114 void ass_set_line_spacing(ASS_Renderer *priv, double line_spacing)
|
|
115 {
|
|
116 priv->settings.line_spacing = line_spacing;
|
|
117 }
|
|
118
|
35262
|
119 void ass_set_line_position(ASS_Renderer *priv, double line_position)
|
|
120 {
|
|
121 if (priv->settings.line_position != line_position) {
|
|
122 priv->settings.line_position = line_position;
|
|
123 ass_reconfigure(priv);
|
|
124 }
|
|
125 }
|
|
126
|
31853
|
127 void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
|
|
128 const char *default_family, int fc, const char *config,
|
|
129 int update)
|
|
130 {
|
|
131 free(priv->settings.default_font);
|
|
132 free(priv->settings.default_family);
|
|
133 priv->settings.default_font = default_font ? strdup(default_font) : 0;
|
|
134 priv->settings.default_family =
|
|
135 default_family ? strdup(default_family) : 0;
|
|
136
|
|
137 if (priv->fontconfig_priv)
|
|
138 fontconfig_done(priv->fontconfig_priv);
|
|
139 priv->fontconfig_priv =
|
|
140 fontconfig_init(priv->library, priv->ftlibrary, default_family,
|
|
141 default_font, fc, config, update);
|
|
142 }
|
|
143
|
|
144 int ass_fonts_update(ASS_Renderer *render_priv)
|
|
145 {
|
|
146 return fontconfig_update(render_priv->fontconfig_priv);
|
|
147 }
|
|
148
|
|
149 void ass_set_cache_limits(ASS_Renderer *render_priv, int glyph_max,
|
|
150 int bitmap_max)
|
|
151 {
|
|
152 render_priv->cache.glyph_max = glyph_max ? glyph_max : GLYPH_CACHE_MAX;
|
|
153 render_priv->cache.bitmap_max_size = bitmap_max ? 1048576 * bitmap_max :
|
|
154 BITMAP_CACHE_MAX_SIZE;
|
|
155 }
|