freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] gsoc-anurag-2022 f6bd130ba 22/27: Remove redundant code


From: Werner Lemberg
Subject: [freetype2] gsoc-anurag-2022 f6bd130ba 22/27: Remove redundant code
Date: Mon, 3 Oct 2022 17:51:54 -0400 (EDT)

branch: gsoc-anurag-2022
commit f6bd130ba3c9930031b2275202ef22ee991177ce
Author: Anurag Thakur <anurag105csec21@bpitindia.edu.in>
Commit: Anurag Thakur <anurag105csec21@bpitindia.edu.in>

    Remove redundant code
---
 src/dense/ftdense.c     | 54 +++----------------------------------------------
 src/dense/ftdenserend.c | 11 +++++++---
 src/smooth/ftgrays.c    |  2 +-
 3 files changed, 12 insertions(+), 55 deletions(-)

diff --git a/src/dense/ftdense.c b/src/dense/ftdense.c
index 8dcb0396c..af52dbccf 100644
--- a/src/dense/ftdense.c
+++ b/src/dense/ftdense.c
@@ -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;
diff --git a/src/dense/ftdenserend.c b/src/dense/ftdenserend.c
index a068a1baa..cd2aeeb4c 100644
--- a/src/dense/ftdenserend.c
+++ b/src/dense/ftdenserend.c
@@ -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 )
   {
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 193ae9966..28a081cbc 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -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 ) )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]