Remove redundant code

This commit is contained in:
Anurag Thakur 2022-09-14 20:10:37 +05:30
parent 5424f47eb9
commit f6bd130ba3
3 changed files with 12 additions and 55 deletions

View File

@ -86,6 +86,8 @@ dense_render_line( dense_worker* worker, TPos to_x, TPos to_y )
to_x = TRUNC( (int)to_x );
to_y = TRUNC( (int)to_y );
// printf("line from: %d, %d to %d, %d\n", from_x, from_y, to_x, to_y);
float dir;
if ( from_y < to_y )
dir = 1;
@ -112,57 +114,6 @@ dense_render_line( dense_worker* worker, TPos to_x, TPos to_y )
to_y = (float)worker->m_h;
}
/**
Handle parts of the line outside the clip rectangle by
snapping them to the left or right edge, or, if they intersect the clip area,
by recursive calls.
*/
FT_Vector intersect = { 0, 0 };
int recursive = 0;
if ( from_x >= worker->m_w && to_x >= worker->m_w )
{
from_x = to_x = (float)worker->m_w;
dxdy = 0;
}
else if ( from_x <= 0 && to_x <= 0 )
{
from_x = to_x = 0;
dxdy = 0;
}
else if ( ( from_x < 0 ) != ( to_x < 0 ) )
{
intersect.x = 0;
intersect.y = to_y - to_x / dxdy;
recursive = 1;
}
else if ( ( from_x > worker->m_w ) != ( to_x > worker->m_w ) )
{
intersect.x = worker->m_w;
intersect.y = from_y + ( worker->m_w - from_x ) / dxdy;
recursive = 1;
}
if ( recursive )
{
from_x += worker->m_origin_x;
from_y += worker->m_origin_y;
to_x += worker->m_origin_x;
to_y += worker->m_origin_y;
intersect.x += worker->m_origin_x;
intersect.y += worker->m_origin_y;
if ( dir == 1 )
{
dense_render_line( worker, intersect.x, intersect.y );
dense_render_line( worker, to_x, to_y );
}
else
{
dense_render_line( worker, intersect.x, intersect.y );
dense_render_line( worker, from_x, from_y );
}
return;
}
float x = from_x;
int y0 = (int)from_y;
int y_limit = (int)ceil( to_y );
@ -170,6 +121,7 @@ dense_render_line( dense_worker* worker, TPos to_x, TPos to_y )
for ( int y = y0; y < y_limit; y++ )
{
// printf("y is %d\n", y);
int linestart = y * worker->m_w;
float dy = fmin( y + 1.0f, to_y ) - fmax( (float)y, from_y );
float xnext = x + dxdy * dy;

View File

@ -98,13 +98,18 @@ take a variable named `memory`. It can only be known if you follow the macros 3
if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
goto Exit;
/* @QUES: What does this flag mean ?*/
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
/* @QUES: Where can I read more about why x and y shift are required */
x_shift = 64 * -slot->bitmap_left;
y_shift = 64 * -slot->bitmap_top;
/* @QUES: What does this flag mean ?*/
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
y_shift += 64 * (FT_Int)bitmap->rows;
if ( bitmap->pixel_mode == FT_PIXEL_MODE_LCD_V )
y_shift += 64 * (FT_Int)bitmap->rows / 3;
else
y_shift += 64 * (FT_Int)bitmap->rows;
if ( origin )
{

View File

@ -876,10 +876,10 @@ typedef ptrdiff_t FT_PtrDist;
TCoord fx1, fy1, fx2, fy2;
TCoord ex1, ey1, ex2, ey2;
ey1 = TRUNC( ras.y );
ey2 = TRUNC( to_y );
/* perform vertical clipping */
if ( ( ey1 >= ras.max_ey && ey2 >= ras.max_ey ) ||
( ey1 < ras.min_ey && ey2 < ras.min_ey ) )