freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] gsoc-anurag-2023 895d11b18 2/2: Attempt to use new render li


From: Werner Lemberg
Subject: [freetype2] gsoc-anurag-2023 895d11b18 2/2: Attempt to use new render line algo
Date: Fri, 6 Oct 2023 19:36:04 -0400 (EDT)

branch: gsoc-anurag-2023
commit 895d11b18c92cce6b005a77a93a3fc06be06db0a
Author: Anurag Thakur <anurag105csec21@bpitindia.edu.in>
Commit: Anurag Thakur <anurag105csec21@bpitindia.edu.in>

    Attempt to use new render line algo
---
 src/base/ftobjs.c   |  2 +-
 src/dense/ftdense.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 86 insertions(+), 6 deletions(-)

diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 82113e30e..1c8e6e13f 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -3154,7 +3154,7 @@ int conic_to2(FT_GlyphSlot* slot, FT_Vector *control, 
FT_Vector *from, FT_Vector
       face->garray = (FT_GlyphSlot*)malloc(
           face->driver->clazz->slot_object_size * face->num_glyphs );
       //error           = FT_Set_Char_Size( face, 0, 160 * 64, 300, 300 );
-      error           = FT_Set_Pixel_Sizes( face, 0, 500);
+      error           = FT_Set_Pixel_Sizes( face, 0, 100);
       // int glyph_index = FT_Get_Char_Index( face, 'A' );
       // error           = FT_Load_Glyph( face, glyph_index, 
FT_LOAD_NO_HINTING );
 
diff --git a/src/dense/ftdense.c b/src/dense/ftdense.c
index e36dc080e..982553740 100644
--- a/src/dense/ftdense.c
+++ b/src/dense/ftdense.c
@@ -174,7 +174,7 @@ dense_render_line2( dense_worker* worker, FT_PreLine pl )
 
     }
   }
-  else
+  else if(0)
   {
     int    x       = from_x;
     int    y0      = from_y>>6;
@@ -212,8 +212,9 @@ dense_render_line2( dense_worker* worker, FT_PreLine pl )
       if ( x1i <= x0i + 1 )
       {
         FT26D6 xmf = ( ( x + xnext )>>1) - x0floor;
-        m_a[linestart + x0i] += d * ((1<<6) - xmf);
-        m_a[linestart + ( x0i + 1 )] += d * xmf;
+        FT20D12 dxmf = d*xmf;
+        m_a[linestart + x0i] += (d * 64) - dxmf;
+        m_a[linestart + ( x0i + 1 )] += dxmf;
       }
       else
       {
@@ -252,6 +253,85 @@ dense_render_line2( dense_worker* worker, FT_PreLine pl )
       x = xnext;
     }
   }
+  else{
+        FT20D12* m_a     = worker->m_a;
+
+    float    x0       = from_x/64.0;
+    float    y0       = from_y/64.0;
+    float    x1       = to_x/64.0;
+    float    y1       = to_y/64.0;
+
+    float    start_x       = truncf(x0);
+    float    start_y       = truncf(y0);
+    float    end_x       = truncf(x1);
+    float    end_y       = truncf(y1);
+
+    float dx = end_x - start_x;
+    float dy = end_y - start_y;
+
+    float tdx = dx == 0 ? 999999 : 1.0/dx;
+    float tdy = 1.0/dy;
+
+    int target_x = start_x + 1.0;
+    int target_y = start_y + 1.0;
+
+    float sx = 1.0 * ((tdx>0)?1:-1);
+    float sy = 1.0 * ((tdy>0)?1:-1);
+
+    float tmx = tdx*((target_x - x0));
+    float tmy = tdy*((target_y - y0));
+
+    tdx = fabs(tdx);
+    tdy = fabs(tdy);
+
+    float x_prev = x0;
+    float y_prev = y0;
+
+    int index = start_x + start_y*worker->m_w;
+    int index_x_inc = (int)sx;
+    int index_y_inc = worker->m_w * ((sy>0)?1:-1);
+
+    int dist = (abs(start_x - end_x) + abs(start_y-end_y));
+
+    while (dist > 0)
+    {
+      dist--;
+      int prev_index = index;
+      float y_next, x_next;
+      if (tmx<tmy)
+      {
+        y_next = tmx * dy + y0;
+        x_next = target_x;
+        tmx += tdx;
+        target_x += sx;
+        index += index_x_inc;
+      }else{
+        y_next = target_y;
+        x_next = tmy*dx + x0;
+        tmy += tdy;
+        target_y += sy;
+        index += index_y_inc;
+
+      }
+      if(prev_index>0 && prev_index<(worker->m_h * worker->m_w)){
+      m_a[prev_index] += (y_prev-y_next) - 
((y_prev-y_next)*((x_prev+x_next)/2));
+      m_a[prev_index +1] += ((y_prev-y_next) *((x_prev+x_next)/2));
+      }
+
+      x_prev = x_next;
+      y_prev = y_next;
+
+    }
+    m_a[(int)(end_x+end_y* worker->m_w)] += (y_prev-y1) - 
((y_prev-y1)*((x_prev+x1)/2));
+    m_a[(int)(end_x+end_y * worker->m_w)+1] += (y_prev-y1)*((x_prev+x1)/2);
+
+
+  }
+
+
+
+  
+ 
 }
 
 
@@ -588,10 +668,10 @@ dense_raster_render( FT_Raster raster, const 
FT_Raster_Params* params )
 
   int size = (worker->m_w * worker->m_h + 3) & ~3;
 
-  worker->m_a      = malloc( sizeof( FT20D12 ) * size );
+  worker->m_a      = calloc( size, sizeof( FT20D12 ));
   worker->m_a_size = size;
 
-  memset( worker->m_a, 0, ( sizeof( FT20D12 ) * size ) );
+  //memset( worker->m_a, 0, ( sizeof( FT20D12 ) * size ) );
   /* exit if nothing to do */
   if ( worker->m_w <= worker->m_origin_x || worker->m_h <= worker->m_origin_y )
   {



reply via email to

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