diff options
author | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-10-18 18:33:19 +0000 |
---|---|---|
committer | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-10-18 18:33:19 +0000 |
commit | 5b5798f039283751ea2edab492429b4814956f9f (patch) | |
tree | 1cd92bfdf11c4561a01ec794cdbeffbc57dab054 /libass/ass_render.c | |
parent | 67232605efd807725a653e1ecab32874377e9c40 (diff) | |
download | mpv-5b5798f039283751ea2edab492429b4814956f9f.tar.bz2 mpv-5b5798f039283751ea2edab492429b4814956f9f.tar.xz |
Move base point calculation to a separate function. Will be reused soon.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20300 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass/ass_render.c')
-rw-r--r-- | libass/ass_render.c | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index ce6dae3a0c..d322814ce9 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -1556,6 +1556,42 @@ static int get_face_descender(FT_Face face) } /** + * \brief Calculate base point for positioning and rotation + * \param bbox text bbox + * \param alignment alignment + * \param bx, by out: base point coordinates + */ +static void get_base_point(FT_BBox bbox, int alignment, int* bx, int* by) +{ + const int halign = alignment & 3; + const int valign = alignment & 12; + if (bx) + switch(halign) { + case HALIGN_LEFT: + *bx = bbox.xMin; + break; + case HALIGN_CENTER: + *bx = (bbox.xMax + bbox.xMin) / 2; + break; + case HALIGN_RIGHT: + *bx = bbox.xMax; + break; + } + if (by) + switch(valign) { + case VALIGN_TOP: + *by = bbox.yMin; + break; + case VALIGN_CENTER: + *by = (bbox.yMax + bbox.yMin) / 2; + break; + case VALIGN_SUB: + *by = bbox.yMax; + break; + } +} + +/** * \brief Main ass rendering function, glues everything together * \param event event to render * Process event, appending resulting ass_image_t's to images_root. @@ -1788,33 +1824,12 @@ static int ass_render_event(ass_event_t* event, event_images_t* event_images) // positioned events are totally different if (render_context.evt_type == EVENT_POSITIONED) { - int align_shift_x = 0; - int align_shift_y = 0; + int base_x = 0; + int base_y = 0; mp_msg(MSGT_GLOBAL, MSGL_DBG2, "positioned event at %d, %d\n", render_context.pos_x, render_context.pos_y); - switch(halign) { - case HALIGN_LEFT: - align_shift_x = - bbox.xMin; - break; - case HALIGN_CENTER: - align_shift_x = - (bbox.xMax + bbox.xMin) /2; - break; - case HALIGN_RIGHT: - align_shift_x = - bbox.xMax; - break; - } - switch(valign) { - case VALIGN_TOP: - align_shift_y = - bbox.yMin; - break; - case VALIGN_CENTER: - align_shift_y = - (bbox.yMax + bbox.yMin) /2; - break; - case VALIGN_SUB: - align_shift_y = - bbox.yMax; - break; - } - device_x = x2scr(render_context.pos_x) + align_shift_x; - device_y = y2scr(render_context.pos_y) + align_shift_y; + get_base_point(bbox, alignment, &base_x, &base_y); + device_x = x2scr(render_context.pos_x) - base_x; + device_y = y2scr(render_context.pos_y) - base_y; } // fix clip coordinates (they depend on alignment) |