ttmlrender: rename TextRange type and its fields.

https://bugzilla.gnome.org/show_bug.cgi?id=780402
This commit is contained in:
Chris Bass 2017-03-21 12:15:50 +00:00 committed by Sebastian Dröge
parent ac91886ab7
commit 4f790d13a6

View File

@ -1168,14 +1168,14 @@ gst_ttml_render_draw_rectangle (guint width, guint height,
typedef struct typedef struct
{ {
guint first_char; guint first_index;
guint last_char; guint last_index;
} TextRange; } CharRange;
static void static void
gst_ttml_render_text_range_free (TextRange * range) gst_ttml_render_char_range_free (CharRange * range)
{ {
g_slice_free (TextRange, range); g_slice_free (CharRange, range);
} }
@ -1336,11 +1336,11 @@ gst_ttml_render_unify_block (const GstSubtitleBlock * block, GstBuffer * buf)
/* From the elements within @block, generate a string of the subtitle text /* From the elements within @block, generate a string of the subtitle text
* marked-up using pango-markup. Also, store the ranges of characters belonging * marked-up using pango-markup. Also, store the ranges of characters belonging
* to the text of each element in @text_ranges. */ * to the text of each element in @char_ranges. */
static gchar * static gchar *
gst_ttml_render_generate_marked_up_string (GstTtmlRender * render, gst_ttml_render_generate_marked_up_string (GstTtmlRender * render,
const GstSubtitleBlock * block, GstBuffer * text_buf, const GstSubtitleBlock * block, GstBuffer * text_buf,
GPtrArray * text_ranges) GPtrArray * char_ranges)
{ {
gchar *escaped_text, *joined_text, *old_text, *font_family, *font_size, gchar *escaped_text, *joined_text, *old_text, *font_family, *font_size,
*fgcolor; *fgcolor;
@ -1355,13 +1355,13 @@ gst_ttml_render_generate_marked_up_string (GstTtmlRender * render,
gst_ttml_render_handle_whitespace (unified_block); gst_ttml_render_handle_whitespace (unified_block);
for (i = 0; i < element_count; ++i) { for (i = 0; i < element_count; ++i) {
TextRange *range = g_slice_new0 (TextRange); CharRange *range = g_slice_new0 (CharRange);
UnifiedElement *unified_element = UnifiedElement *unified_element =
gst_ttml_render_unified_block_get_element (unified_block, i); gst_ttml_render_unified_block_get_element (unified_block, i);
escaped_text = g_markup_escape_text (unified_element->text, -1); escaped_text = g_markup_escape_text (unified_element->text, -1);
GST_CAT_DEBUG (ttmlrender_debug, "Escaped text is: \"%s\"", escaped_text); GST_CAT_DEBUG (ttmlrender_debug, "Escaped text is: \"%s\"", escaped_text);
range->first_char = total_text_length; range->first_index = total_text_length;
fgcolor = fgcolor =
gst_ttml_render_color_to_string (unified_element->element-> gst_ttml_render_color_to_string (unified_element->element->
@ -1397,11 +1397,11 @@ gst_ttml_render_generate_marked_up_string (GstTtmlRender * render,
GST_CAT_DEBUG (ttmlrender_debug, "Joined text is now: %s", joined_text); GST_CAT_DEBUG (ttmlrender_debug, "Joined text is now: %s", joined_text);
total_text_length += strlen (unified_element->text); total_text_length += strlen (unified_element->text);
range->last_char = total_text_length - 1; range->last_index = total_text_length - 1;
GST_CAT_DEBUG (ttmlrender_debug, GST_CAT_DEBUG (ttmlrender_debug,
"First character index: %u; last character " "index: %u", "First character index: %u; last character " "index: %u",
range->first_char, range->last_char); range->first_index, range->last_index);
g_ptr_array_insert (text_ranges, i, range); g_ptr_array_insert (char_ranges, i, range);
g_free (old_text); g_free (old_text);
g_free (escaped_text); g_free (escaped_text);
@ -1768,7 +1768,7 @@ gst_ttml_render_render_element_backgrounds (const GstSubtitleBlock * block,
guint padding; guint padding;
PangoLayoutLine *line; PangoLayoutLine *line;
PangoRectangle first_char_pos, last_char_pos, line_extents; PangoRectangle first_char_pos, last_char_pos, line_extents;
TextRange *range; CharRange *range;
const GstSubtitleElement *element; const GstSubtitleElement *element;
guint rect_width; guint rect_width;
GstBuffer *rectangle; GstBuffer *rectangle;
@ -1781,12 +1781,12 @@ gst_ttml_render_render_element_backgrounds (const GstSubtitleBlock * block,
element = gst_subtitle_block_get_element (block, i); element = gst_subtitle_block_get_element (block, i);
GST_CAT_LOG (ttmlrender_debug, "First char index: %u Last char index: %u", GST_CAT_LOG (ttmlrender_debug, "First char index: %u Last char index: %u",
range->first_char, range->last_char); range->first_index, range->last_index);
pango_layout_index_to_pos (layout, range->first_char, &first_char_pos); pango_layout_index_to_pos (layout, range->first_index, &first_char_pos);
pango_layout_index_to_pos (layout, range->last_char, &last_char_pos); pango_layout_index_to_pos (layout, range->last_index, &last_char_pos);
pango_layout_index_to_line_x (layout, range->first_char, 1, pango_layout_index_to_line_x (layout, range->first_index, 1,
&first_line, NULL); &first_line, NULL);
pango_layout_index_to_line_x (layout, range->last_char, 0, pango_layout_index_to_line_x (layout, range->last_index, 0,
&last_line, NULL); &last_line, NULL);
first_char_start = PANGO_PIXELS (first_char_pos.x) - horiz_offset; first_char_start = PANGO_PIXELS (first_char_pos.x) - horiz_offset;
@ -1957,7 +1957,7 @@ gst_ttml_render_render_text_block (GstTtmlRender * render,
gboolean overflow) gboolean overflow)
{ {
GPtrArray *char_ranges = g_ptr_array_new_with_free_func ((GDestroyNotify) GPtrArray *char_ranges = g_ptr_array_new_with_free_func ((GDestroyNotify)
gst_ttml_render_text_range_free); gst_ttml_render_char_range_free);
gchar *marked_up_string; gchar *marked_up_string;
PangoAlignment alignment; PangoAlignment alignment;
guint max_font_size; guint max_font_size;