Merge mask fixes from tomato branch

--
svn merge -r49075:49076 -r49086:49087  ^/branches/soc-2011-tomato
This commit is contained in:
Sergey Sharybin 2012-07-21 09:01:39 +00:00
parent 21e3e3b8fc
commit 1bb7cfded6

@ -541,6 +541,8 @@ static void spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feat
int next = i + 1;
float delta;
DO_MINMAX2(feather_points[i], min, max);
if (next == tot_feather_point) {
if (spline->flag & MASK_SPLINE_CYCLIC)
next = 0;
@ -555,16 +557,27 @@ static void spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feat
delta = fabsf(feather_points[i][1] - feather_points[next][1]);
if (delta > max_delta_y)
max_delta_y = delta;
}
DO_MINMAX2(feather_points[i], min, max);
/* prevent divisionsby zero by ensuring bounding box is not collapsed */
if (max[0] - min[0] < FLT_EPSILON) {
max[0] += 0.01f;
min[0] -= 0.01f;
}
if (max[1] - min[1] < FLT_EPSILON) {
max[1] += 0.01f;
min[1] -= 0.01f;
}
/* use dynamically calculated buckets per side, so we likely wouldn't
* run into a situation when segment doesn't fit two buckets which is
* pain collecting candidates for intersection
*/
max_delta_x /= max[0] - min[0];
max_delta_y /= max[1] - min[1];
max_delta = MAX2(max_delta_x, max_delta_y);
buckets_per_side = MIN2(512, 0.9f / max_delta);