[base] Clean up BBox_Conic_Check.

* src/base/ftbbox.c (BBox_Conic_Check): Remove redundant checks for
extremum at the segment ends, which are already within the bbox.
Slightly modify calculations.
This commit is contained in:
Alexei Podtelezhnikov 2013-08-17 22:19:21 -04:00
parent 1a9c3d14fb
commit 32a7d87050
2 changed files with 19 additions and 22 deletions

View File

@ -1,3 +1,11 @@
2013-08-17 Alexei Podtelezhnikov <apodtele@gmail.com>
[base] Clean up BBox_Conic_Check.
* src/base/ftbbox.c (BBox_Conic_Check): Remove redundant checks for
extremum at the segment ends, which are already within the bbox.
Slightly modify calculations.
2013-08-15 Alexei Podtelezhnikov <apodtele@gmail.com>
[base] Finish experimental (disabled) BBox_Cubic_Check implementation.

View File

@ -108,30 +108,19 @@
FT_Pos* min,
FT_Pos* max )
{
if ( y1 <= y3 && y2 == y1 ) /* flat arc */
goto Suite;
/* This function is only called when a control off-point is outside */
/* the bbox. This also means there must be a local extremum within */
/* the segment with the value of (y1*y3 - y2*y2)/(y1 - 2*y2 + y3). */
/* Offsetting from the closest point to the extermum, y2, we get */
if ( y1 < y3 )
{
if ( y2 >= y1 && y2 <= y3 ) /* ascending arc */
goto Suite;
}
else
{
if ( y2 >= y3 && y2 <= y1 ) /* descending arc */
{
y2 = y1;
y1 = y3;
y3 = y2;
goto Suite;
}
}
y1 -= y2;
y3 -= y2;
y2 += FT_MulDiv( y1, y3, y1 + y3 );
y1 = y3 = y1 - FT_MulDiv( y2 - y1, y2 - y1, y1 - 2*y2 + y3 );
Suite:
if ( y1 < *min ) *min = y1;
if ( y3 > *max ) *max = y3;
if ( y2 < *min )
*min = y2;
if ( y2 > *max )
*max = y2;
}