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);
|
36363
|
46 if (settings->storage_height) {
|
|
47 priv->storage_width = settings->storage_width;
|
|
48 priv->storage_height = settings->storage_height;
|
|
49 } else {
|
|
50 priv->storage_width = priv->orig_width;
|
|
51 priv->storage_height = priv->orig_height;
|
|
52 }
|
31853
|
53 }
|
|
54
|
|
55 void ass_set_frame_size(ASS_Renderer *priv, int w, int h)
|
|
56 {
|
|
57 if (priv->settings.frame_width != w || priv->settings.frame_height != h) {
|
|
58 priv->settings.frame_width = w;
|
|
59 priv->settings.frame_height = h;
|
36363
|
60 ass_reconfigure(priv);
|
|
61 }
|
|
62 }
|
|
63
|
|
64 void ass_set_storage_size(ASS_Renderer *priv, int w, int h)
|
|
65 {
|
|
66 if (priv->settings.storage_width != w ||
|
|
67 priv->settings.storage_height != h) {
|
|
68 priv->settings.storage_width = w;
|
|
69 priv->settings.storage_height = h;
|
31853
|
70 ass_reconfigure(priv);
|
|
71 }
|
|
72 }
|
|
73
|
34295
|
74 void ass_set_shaper(ASS_Renderer *priv, ASS_ShapingLevel level)
|
|
75 {
|
|
76 #ifdef CONFIG_HARFBUZZ
|
|
77 // select the complex shaper for illegal values
|
|
78 if (level == ASS_SHAPING_SIMPLE || level == ASS_SHAPING_COMPLEX)
|
|
79 priv->settings.shaper = level;
|
|
80 else
|
|
81 priv->settings.shaper = ASS_SHAPING_COMPLEX;
|
|
82 #endif
|
|
83 }
|
|
84
|
31853
|
85 void ass_set_margins(ASS_Renderer *priv, int t, int b, int l, int r)
|
|
86 {
|
|
87 if (priv->settings.left_margin != l || priv->settings.right_margin != r ||
|
|
88 priv->settings.top_margin != t || priv->settings.bottom_margin != b) {
|
|
89 priv->settings.left_margin = l;
|
|
90 priv->settings.right_margin = r;
|
|
91 priv->settings.top_margin = t;
|
|
92 priv->settings.bottom_margin = b;
|
|
93 ass_reconfigure(priv);
|
|
94 }
|
|
95 }
|
|
96
|
|
97 void ass_set_use_margins(ASS_Renderer *priv, int use)
|
|
98 {
|
|
99 priv->settings.use_margins = use;
|
|
100 }
|
|
101
|
|
102 void ass_set_aspect_ratio(ASS_Renderer *priv, double dar, double sar)
|
|
103 {
|
36363
|
104 ass_set_pixel_aspect(priv, dar / sar);
|
|
105 }
|
|
106
|
|
107 void ass_set_pixel_aspect(ASS_Renderer *priv, double par)
|
|
108 {
|
|
109 if (priv->settings.par != par) {
|
|
110 priv->settings.par = par;
|
31853
|
111 ass_reconfigure(priv);
|
|
112 }
|
|
113 }
|
|
114
|
|
115 void ass_set_font_scale(ASS_Renderer *priv, double font_scale)
|
|
116 {
|
|
117 if (priv->settings.font_size_coeff != font_scale) {
|
|
118 priv->settings.font_size_coeff = font_scale;
|
|
119 ass_reconfigure(priv);
|
|
120 }
|
|
121 }
|
|
122
|
|
123 void ass_set_hinting(ASS_Renderer *priv, ASS_Hinting ht)
|
|
124 {
|
|
125 if (priv->settings.hinting != ht) {
|
|
126 priv->settings.hinting = ht;
|
|
127 ass_reconfigure(priv);
|
|
128 }
|
|
129 }
|
|
130
|
|
131 void ass_set_line_spacing(ASS_Renderer *priv, double line_spacing)
|
|
132 {
|
|
133 priv->settings.line_spacing = line_spacing;
|
|
134 }
|
|
135
|
35262
|
136 void ass_set_line_position(ASS_Renderer *priv, double line_position)
|
|
137 {
|
|
138 if (priv->settings.line_position != line_position) {
|
|
139 priv->settings.line_position = line_position;
|
|
140 ass_reconfigure(priv);
|
|
141 }
|
|
142 }
|
|
143
|
31853
|
144 void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
|
|
145 const char *default_family, int fc, const char *config,
|
|
146 int update)
|
|
147 {
|
|
148 free(priv->settings.default_font);
|
|
149 free(priv->settings.default_family);
|
|
150 priv->settings.default_font = default_font ? strdup(default_font) : 0;
|
|
151 priv->settings.default_family =
|
|
152 default_family ? strdup(default_family) : 0;
|
|
153
|
|
154 if (priv->fontconfig_priv)
|
|
155 fontconfig_done(priv->fontconfig_priv);
|
|
156 priv->fontconfig_priv =
|
|
157 fontconfig_init(priv->library, priv->ftlibrary, default_family,
|
|
158 default_font, fc, config, update);
|
|
159 }
|
|
160
|
|
161 int ass_fonts_update(ASS_Renderer *render_priv)
|
|
162 {
|
|
163 return fontconfig_update(render_priv->fontconfig_priv);
|
|
164 }
|
|
165
|
|
166 void ass_set_cache_limits(ASS_Renderer *render_priv, int glyph_max,
|
|
167 int bitmap_max)
|
|
168 {
|
|
169 render_priv->cache.glyph_max = glyph_max ? glyph_max : GLYPH_CACHE_MAX;
|
|
170 render_priv->cache.bitmap_max_size = bitmap_max ? 1048576 * bitmap_max :
|
|
171 BITMAP_CACHE_MAX_SIZE;
|
|
172 }
|