vlc | branch: master | Francois Cartegnie <[email protected]> | Wed Jun 7 18:02:41 2017 +0200| [f13716abf8903b743234fad13ec7c58db2990233] | committer: Francois Cartegnie
text_renderer: freetype: strip lines according to max_height > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f13716abf8903b743234fad13ec7c58db2990233 --- modules/text_renderer/freetype/freetype.c | 8 ++++++- modules/text_renderer/freetype/text_layout.c | 35 ++++++++++++++++++++++------ modules/text_renderer/freetype/text_layout.h | 4 +++- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/modules/text_renderer/freetype/freetype.c b/modules/text_renderer/freetype/freetype.c index 2779a82279..b688391cdd 100644 --- a/modules/text_renderer/freetype/freetype.c +++ b/modules/text_renderer/freetype/freetype.c @@ -1138,9 +1138,15 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region_out, else if( p_region_in->i_x > 0 && (unsigned)p_region_in->i_x < i_max_width ) i_max_width -= p_region_in->i_x; + unsigned i_max_height = p_filter->fmt_out.video.i_visible_height; + if( p_region_in->i_max_height > 0 && (unsigned) p_region_in->i_max_height < i_max_height ) + i_max_height = p_region_in->i_max_height; + else if( p_region_in->i_y > 0 && (unsigned)p_region_in->i_y < i_max_height ) + i_max_height -= p_region_in->i_y; + rv = LayoutText( p_filter, psz_text, pp_styles, pi_k_durations, i_text_length, p_region_in->b_gridmode, - i_max_width, &p_lines, &bbox, &i_max_face_height ); + i_max_width, i_max_height, &p_lines, &bbox, &i_max_face_height ); p_region_out->i_x = p_region_in->i_x; p_region_out->i_y = p_region_in->i_y; diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c index a735148301..ff2bd98085 100644 --- a/modules/text_renderer/freetype/text_layout.c +++ b/modules/text_renderer/freetype/text_layout.c @@ -1460,15 +1460,17 @@ error: int LayoutText( filter_t *p_filter, const uni_char_t *psz_text, text_style_t **pp_styles, - uint32_t *pi_k_dates, int i_len, bool b_grid, unsigned i_max_width, + uint32_t *pi_k_dates, int i_len, bool b_grid, + unsigned i_max_width, unsigned i_max_height, line_desc_t **pp_lines, FT_BBox *p_bbox, int *pi_max_face_height ) { line_desc_t *p_first_line = 0; line_desc_t **pp_line = &p_first_line; paragraph_t *p_paragraph = 0; int i_paragraph_start = 0; - int i_max_height = 0; + unsigned i_total_height = 0; unsigned i_max_advance_x = 0; + int i_max_face_height = 0; for( int i = 0; i <= i_len; ++i ) { @@ -1528,9 +1530,28 @@ int LayoutText( filter_t *p_filter, FreeParagraph( p_paragraph ); p_paragraph = 0; - for( ; *pp_line; pp_line = &( *pp_line )->p_next ) - i_max_height = __MAX( i_max_height, ( *pp_line )->i_height ); - + for( ; *pp_line; pp_line = &(*pp_line)->p_next ) + { + i_total_height += (*pp_line)->i_height; + if( i_max_height > 0 && i_total_height > i_max_height ) + { + i_total_height = i_max_height + 1; + line_desc_t *p_todelete = *pp_line; + while( p_todelete ) /* Drop extra lines */ + { + line_desc_t *p_next = p_todelete->p_next; + FreeLine( p_todelete ); + p_todelete = p_next; + } + *pp_line = NULL; + i = i_len + 1; /* force no more paragraphs */ + break; /* ! no p_next ! */ + } + else if( (*pp_line)->i_height > i_max_face_height ) + { + i_max_face_height = (*pp_line)->i_height; + } + } i_paragraph_start = i + 1; } } @@ -1550,12 +1571,12 @@ int LayoutText( filter_t *p_filter, p_line->bbox.yMax -= i_base_line; BBoxEnlarge( &bbox, &p_line->bbox ); - i_base_line += i_max_height; + i_base_line += i_max_face_height; } + *pi_max_face_height = i_max_face_height; *pp_lines = p_first_line; *p_bbox = bbox; - *pi_max_face_height = i_max_height; return VLC_SUCCESS; error: diff --git a/modules/text_renderer/freetype/text_layout.h b/modules/text_renderer/freetype/text_layout.h index 8834488de6..0cb3aca710 100644 --- a/modules/text_renderer/freetype/text_layout.h +++ b/modules/text_renderer/freetype/text_layout.h @@ -72,11 +72,13 @@ line_desc_t *NewLine( int i_count ); * \param i_len length of the arrays \p psz_text, \p pp_styles, and \p pi_k_dates [IN] * \param b_grid true for grid-mode text [IN] * \param i_max_width maximum available width to layout text [IN] + * \param i_max_height maximum available height to layout text [IN] * \param pp_lines the list of line_desc_t's with rendered glyphs [OUT] * \param p_bbox the bounding box of all the lines [OUT] * \param pi_max_face_height maximum line height [OUT] */ int LayoutText( filter_t *p_filter, const uni_char_t *psz_text, text_style_t **pp_styles, - uint32_t *pi_k_dates, int i_len, bool b_grid, unsigned i_max_width, + uint32_t *pi_k_dates, int i_len, bool b_grid, + unsigned i_max_width, unsigned i_max_height, line_desc_t **pp_lines, FT_BBox *p_bbox, int *pi_max_face_height ); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
