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++;
|
|
28 priv->cache.glyph_cache =
|
|
29 ass_glyph_cache_reset(priv->cache.glyph_cache);
|
|
30 priv->cache.bitmap_cache =
|
|
31 ass_bitmap_cache_reset(priv->cache.bitmap_cache);
|
|
32 priv->cache.composite_cache =
|
|
33 ass_composite_cache_reset(priv->cache.composite_cache);
|
|
34 ass_free_images(priv->prev_images_root);
|
|
35 priv->prev_images_root = 0;
|
|
36
|
|
37 priv->width = settings->frame_width;
|
|
38 priv->height = settings->frame_height;
|
|
39 priv->orig_width = settings->frame_width - settings->left_margin -
|
|
40 settings->right_margin;
|
|
41 priv->orig_height = settings->frame_height - settings->top_margin -
|
|
42 settings->bottom_margin;
|
|
43 priv->orig_width_nocrop =
|
|
44 settings->frame_width - FFMAX(settings->left_margin, 0) -
|
|
45 FFMAX(settings->right_margin, 0);
|
|
46 priv->orig_height_nocrop =
|
|
47 settings->frame_height - FFMAX(settings->top_margin, 0) -
|
|
48 FFMAX(settings->bottom_margin, 0);
|
|
49 }
|
|
50
|
|
51 void ass_set_frame_size(ASS_Renderer *priv, int w, int h)
|
|
52 {
|
|
53 if (priv->settings.frame_width != w || priv->settings.frame_height != h) {
|
|
54 priv->settings.frame_width = w;
|
|
55 priv->settings.frame_height = h;
|
|
56 if (priv->settings.aspect == 0.) {
|
|
57 priv->settings.aspect = ((double) w) / h;
|
|
58 priv->settings.storage_aspect = ((double) w) / h;
|
|
59 }
|
|
60 ass_reconfigure(priv);
|
|
61 }
|
|
62 }
|
|
63
|
|
64 void ass_set_margins(ASS_Renderer *priv, int t, int b, int l, int r)
|
|
65 {
|
|
66 if (priv->settings.left_margin != l || priv->settings.right_margin != r ||
|
|
67 priv->settings.top_margin != t || priv->settings.bottom_margin != b) {
|
|
68 priv->settings.left_margin = l;
|
|
69 priv->settings.right_margin = r;
|
|
70 priv->settings.top_margin = t;
|
|
71 priv->settings.bottom_margin = b;
|
|
72 ass_reconfigure(priv);
|
|
73 }
|
|
74 }
|
|
75
|
|
76 void ass_set_use_margins(ASS_Renderer *priv, int use)
|
|
77 {
|
|
78 priv->settings.use_margins = use;
|
|
79 }
|
|
80
|
|
81 void ass_set_aspect_ratio(ASS_Renderer *priv, double dar, double sar)
|
|
82 {
|
|
83 if (priv->settings.aspect != dar || priv->settings.storage_aspect != sar) {
|
|
84 priv->settings.aspect = dar;
|
|
85 priv->settings.storage_aspect = sar;
|
|
86 ass_reconfigure(priv);
|
|
87 }
|
|
88 }
|
|
89
|
|
90 void ass_set_font_scale(ASS_Renderer *priv, double font_scale)
|
|
91 {
|
|
92 if (priv->settings.font_size_coeff != font_scale) {
|
|
93 priv->settings.font_size_coeff = font_scale;
|
|
94 ass_reconfigure(priv);
|
|
95 }
|
|
96 }
|
|
97
|
|
98 void ass_set_hinting(ASS_Renderer *priv, ASS_Hinting ht)
|
|
99 {
|
|
100 if (priv->settings.hinting != ht) {
|
|
101 priv->settings.hinting = ht;
|
|
102 ass_reconfigure(priv);
|
|
103 }
|
|
104 }
|
|
105
|
|
106 void ass_set_line_spacing(ASS_Renderer *priv, double line_spacing)
|
|
107 {
|
|
108 priv->settings.line_spacing = line_spacing;
|
|
109 }
|
|
110
|
|
111 void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
|
|
112 const char *default_family, int fc, const char *config,
|
|
113 int update)
|
|
114 {
|
|
115 free(priv->settings.default_font);
|
|
116 free(priv->settings.default_family);
|
|
117 priv->settings.default_font = default_font ? strdup(default_font) : 0;
|
|
118 priv->settings.default_family =
|
|
119 default_family ? strdup(default_family) : 0;
|
|
120
|
|
121 if (priv->fontconfig_priv)
|
|
122 fontconfig_done(priv->fontconfig_priv);
|
|
123 priv->fontconfig_priv =
|
|
124 fontconfig_init(priv->library, priv->ftlibrary, default_family,
|
|
125 default_font, fc, config, update);
|
|
126 }
|
|
127
|
|
128 int ass_fonts_update(ASS_Renderer *render_priv)
|
|
129 {
|
|
130 return fontconfig_update(render_priv->fontconfig_priv);
|
|
131 }
|
|
132
|
|
133 void ass_set_cache_limits(ASS_Renderer *render_priv, int glyph_max,
|
|
134 int bitmap_max)
|
|
135 {
|
|
136 render_priv->cache.glyph_max = glyph_max ? glyph_max : GLYPH_CACHE_MAX;
|
|
137 render_priv->cache.bitmap_max_size = bitmap_max ? 1048576 * bitmap_max :
|
|
138 BITMAP_CACHE_MAX_SIZE;
|
|
139 }
|