diff options
author | Dr.Smile <vabnick@gmail.com> | 2017-09-17 03:39:11 +0300 |
---|---|---|
committer | Dr.Smile <vabnick@gmail.com> | 2017-09-17 04:07:20 +0300 |
commit | ad6510b9c78f5c79f7492b608912dc5281e15e47 (patch) | |
tree | 245c655bd8f0b4c4a2884d941509c965dc8778bd /libass/ass_drawing.c | |
parent | 71cf4e3b6328cdac390cdc84fa9c289224e2179d (diff) | |
download | libass-ad6510b9c78f5c79f7492b608912dc5281e15e47.tar.bz2 libass-ad6510b9c78f5c79f7492b608912dc5281e15e47.tar.xz |
Consolidate bounding box operations
Diffstat (limited to 'libass/ass_drawing.c')
-rw-r--r-- | libass/ass_drawing.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/libass/ass_drawing.c b/libass/ass_drawing.c index 64f7b29..5918469 100644 --- a/libass/ass_drawing.c +++ b/libass/ass_drawing.c @@ -174,28 +174,15 @@ static void drawing_free_tokens(ASS_DrawingToken *token) } /* - * \brief Update drawing cbox - */ -static inline void update_cbox(ASS_Drawing *drawing, ASS_Vector *point) -{ - ASS_Rect *box = &drawing->cbox; - - box->x_min = FFMIN(box->x_min, point->x); - box->x_max = FFMAX(box->x_max, point->x); - box->y_min = FFMIN(box->y_min, point->y); - box->y_max = FFMAX(box->y_max, point->y); -} - -/* * \brief Translate and scale a point coordinate according to baseline * offset and scale. */ static inline void translate_point(ASS_Drawing *drawing, ASS_Vector *point) { - point->x = drawing->point_scale_x * point->x; - point->y = drawing->point_scale_y * point->y; + point->x = lrint(drawing->point_scale_x * point->x); + point->y = lrint(drawing->point_scale_y * point->y); - update_cbox(drawing, point); + rectangle_update(&drawing->cbox, point->x, point->y, point->x, point->y); } /* @@ -244,8 +231,7 @@ ASS_Drawing *ass_drawing_new(ASS_Library *lib) ASS_Drawing *drawing = calloc(1, sizeof(*drawing)); if (!drawing) return NULL; - drawing->cbox.x_min = drawing->cbox.y_min = INT32_MAX; - drawing->cbox.x_max = drawing->cbox.y_max = INT32_MIN; + rectangle_reset(&drawing->cbox); drawing->library = lib; drawing->scale_x = 1.; drawing->scale_y = 1.; |