[dense] Add optimization for vertical lines

* src/dense/ftdense.c: Optimize line drawing when a vertical line is encountered
This commit is contained in:
Anurag Thakur 2022-11-19 13:14:51 +05:30
parent bca7bda1e7
commit 668bc29ff0
1 changed files with 87 additions and 58 deletions

View File

@ -126,6 +126,34 @@ dense_render_line( dense_worker* worker, FT_Pos tox, FT_Pos toy )
to_y = worker->m_h<<6;
}
if(deltax == 0){
FT26D6 x = from_x;
int x0i = x>>6;
FT26D6 x0floor = x0i<<6;
// y-coordinate of first pixel of line
int y0 = from_y>>6;
// y-coordinate of last pixel of line
int y_limit = (to_y + 0x3f)>>6;
FT20D12* m_a = worker->m_a;
for ( int y = y0; y < y_limit; y++ )
{
int linestart = y * worker->m_w;
FT26D6 dy = min( (y + 1)<<6, to_y ) - max( y<<6, from_y );
m_a[linestart + x0i] += dir*dy*(64 - x + x0floor);
m_a[linestart + ( x0i + 1 )] += dir*dy*(x-x0floor);
}
}
else
{
int x = from_x;
int y0 = from_y>>6;
int y_limit = (to_y + 0x3f)>>6;
@ -199,6 +227,7 @@ dense_render_line( dense_worker* worker, FT_Pos tox, FT_Pos toy )
x = xnext;
}
}
}
static int