Skip to content

Commit

Permalink
outline: rearrange allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSmile committed May 19, 2019
1 parent f6982a0 commit 7307cbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
1 change: 0 additions & 1 deletion libass/ass_drawing.c
Expand Up @@ -181,7 +181,6 @@ bool ass_drawing_parse(ASS_Outline *outline, ASS_Rect *cbox,
{
if (!outline_alloc(outline, DRAWING_INITIAL_POINTS, DRAWING_INITIAL_SEGMENTS))
return false;
outline->n_points = outline->n_segments = 0;
rectangle_reset(cbox);

ASS_DrawingToken *tokens = drawing_tokenize(text);
Expand Down
10 changes: 6 additions & 4 deletions libass/ass_outline.c
Expand Up @@ -35,6 +35,7 @@ bool outline_alloc(ASS_Outline *outline, size_t n_points, size_t n_segments)

outline->max_points = n_points;
outline->max_segments = n_segments;
outline->n_points = outline->n_segments = 0;
return true;
}

Expand All @@ -61,7 +62,6 @@ bool outline_convert(ASS_Outline *outline, const FT_Outline *source)
S_ON, S_Q, S_C1, S_C2
};

outline->n_points = outline->n_segments = 0;
for (size_t i = 0, j = 0; i < source->n_contours; i++) {
ASS_Vector pt;
bool skip_last = false;
Expand Down Expand Up @@ -1344,13 +1344,15 @@ static bool close_contour(StrokerState *str, int dir)
bool outline_stroke(ASS_Outline *result, ASS_Outline *result1,
const ASS_Outline *path, int xbord, int ybord, int eps)
{
outline_alloc(result, 2 * path->n_points, 2 * path->n_segments);
outline_alloc(result1, 2 * path->n_points, 2 * path->n_segments);
if (!result->max_points || !result1->max_points)
return false;

const int dir = 3;
int rad = FFMAX(xbord, ybord);
assert(rad >= eps);

result->n_points = result->n_segments = 0;
result1->n_points = result1->n_segments = 0;

StrokerState str;
str.result[0] = result;
str.result[1] = result1;
Expand Down
12 changes: 4 additions & 8 deletions libass/ass_render.c
Expand Up @@ -1190,14 +1190,10 @@ size_t ass_outline_construct(void *key, void *value, void *priv)
if (!outline_scale_pow2(&src, &k->outline->outline[0],
k->scale_ord_x, k->scale_ord_y))
return 1;

outline_alloc(&v->outline[0], 2 * src.n_points, 2 * src.n_segments);
outline_alloc(&v->outline[1], 2 * src.n_points, 2 * src.n_segments);
if (!v->outline[0].max_points || !v->outline[1].max_points ||
!outline_stroke(&v->outline[0], &v->outline[1], &src,
k->border.x * STROKER_PRECISION,
k->border.y * STROKER_PRECISION,
STROKER_PRECISION)) {
if (!outline_stroke(&v->outline[0], &v->outline[1], &src,
k->border.x * STROKER_PRECISION,
k->border.y * STROKER_PRECISION,
STROKER_PRECISION)) {
ass_msg(render_priv->library, MSGL_WARN, "Cannot stroke outline");
outline_free(&v->outline[0]);
outline_free(&v->outline[1]);
Expand Down

0 comments on commit 7307cbd

Please sign in to comment.