[smooth] Slightly optimize conic and cubic flatterners.

* src/smooth/ftgrays.c (gray_render_conic, gray_render_cubic): Move
out some code from the main loop to speed it up.
This commit is contained in:
Werner Lemberg 2011-09-17 09:21:25 +02:00
parent 487913d9a6
commit e9e93d1b19
2 changed files with 54 additions and 48 deletions

View File

@ -1,3 +1,10 @@
2011-09-17 Alexei Podtelezhnikov <apodtele@gmail.com>
[smooth] Slightly optimize conic and cubic flatterners.
* src/smooth/ftgrays.c (gray_render_conic, gray_render_cubic): Move
out some code from the main loop to speed it up.
2011-09-11 Tomas Hoger <thoger@redhat.com> 2011-09-11 Tomas Hoger <thoger@redhat.com>
Slightly improve LZW_CLEAR handling. Slightly improve LZW_CLEAR handling.

View File

@ -872,6 +872,7 @@ typedef ptrdiff_t FT_PtrDist;
const FT_Vector* to ) const FT_Vector* to )
{ {
TPos dx, dy; TPos dx, dy;
TPos min, max, y;
int top, level; int top, level;
int* levels; int* levels;
FT_Vector* arc; FT_Vector* arc;
@ -884,32 +885,17 @@ typedef ptrdiff_t FT_PtrDist;
arc[1].y = UPSCALE( control->y ); arc[1].y = UPSCALE( control->y );
arc[2].x = ras.x; arc[2].x = ras.x;
arc[2].y = ras.y; arc[2].y = ras.y;
top = 0;
dx = FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x ); dx = FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x );
dy = FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y ); dy = FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y );
if ( dx < dy ) if ( dx < dy )
dx = dy; dx = dy;
level = 0; if ( dx < ONE_PIXEL / 4 )
while ( dx > ONE_PIXEL / 6 ) goto Draw;
{
dx >>= 2;
level++;
}
levels = ras.lev_stack;
levels[0] = level;
top = 0;
do
{
level = levels[top];
if ( level > 1 )
{
/* check that the arc crosses the current band */
TPos min, max, y;
/* short-cut the arc that crosses the current band */
min = max = arc[0].y; min = max = arc[0].y;
y = arc[1].y; y = arc[1].y;
@ -923,6 +909,21 @@ typedef ptrdiff_t FT_PtrDist;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey ) if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
goto Draw; goto Draw;
level = 0;
do
{
dx >>= 2;
level++;
} while ( dx > ONE_PIXEL / 4 );
levels = ras.lev_stack;
levels[0] = level;
do
{
level = levels[top];
if ( level > 0 )
{
gray_split_conic( arc ); gray_split_conic( arc );
arc += 2; arc += 2;
top++; top++;
@ -973,6 +974,7 @@ typedef ptrdiff_t FT_PtrDist;
const FT_Vector* to ) const FT_Vector* to )
{ {
FT_Vector* arc; FT_Vector* arc;
TPos min, max, y;
arc = ras.bez_stack; arc = ras.bez_stack;
@ -985,12 +987,7 @@ typedef ptrdiff_t FT_PtrDist;
arc[3].x = ras.x; arc[3].x = ras.x;
arc[3].y = ras.y; arc[3].y = ras.y;
for (;;) /* Short-cut the arc that crosses the current band. */
{
/* Check that the arc crosses the current band. */
TPos min, max, y;
min = max = arc[0].y; min = max = arc[0].y;
y = arc[1].y; y = arc[1].y;
@ -1014,6 +1011,8 @@ typedef ptrdiff_t FT_PtrDist;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey ) if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
goto Draw; goto Draw;
for (;;)
{
/* Decide whether to split or draw. See `Rapid Termination */ /* Decide whether to split or draw. See `Rapid Termination */
/* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */ /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */
/* F. Hain, at */ /* F. Hain, at */