freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master c878adf: * graph/grfill.c (grFillHLine): Fix cr


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master c878adf: * graph/grfill.c (grFillHLine): Fix cropping.
Date: Sat, 29 Sep 2018 13:22:44 -0400 (EDT)

branch: master
commit c878adf560627e2b73ee5f39309bc750d1ecdc62
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    * graph/grfill.c (grFillHLine): Fix cropping.
    (grFillVLine): Refactor in line with `grFillHLine'.
---
 ChangeLog      |  5 +++++
 graph/grfill.c | 25 +++++++++----------------
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 05a51c8..bf7e641 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-09-29  Alexei Podtelezhnikov  <address@hidden>
+
+       * graph/grfill.c (grFillHLine): Fix cropping.
+       (grFillVLine): Refactor in line with `grFillHLine'.
+
 2018-09-26  Alexei Podtelezhnikov  <address@hidden>
 
        * src/ftstring.c (Process_Event, event_help): Implement flushing.
diff --git a/graph/grfill.c b/graph/grfill.c
index d2fa74b..9148f81 100644
--- a/graph/grfill.c
+++ b/graph/grfill.c
@@ -170,9 +170,9 @@ grFillHLine( grBitmap*  target,
   }
   delta = x + width - target->width;
   if ( delta > 0 )
-    width -= x;
+    width -= delta;
 
-  if ( y < 0 || y >= target->rows || width < 0 || hline_func == NULL )
+  if ( y < 0 || y >= target->rows || width <= 0 || hline_func == NULL )
     return;
 
   line = target->buffer + y*target->pitch;
@@ -191,10 +191,7 @@ grFillVLine( grBitmap*  target,
 {
   int              delta;
   unsigned char*   line;
-  grFillHLineFunc  hline_func;
-
-  if ( x < 0 || x >= target->width )
-    return;
+  grFillHLineFunc  hline_func = gr_fill_hline_funcs[ target->mode ];
 
   if ( y < 0 )
   {
@@ -205,19 +202,15 @@ grFillVLine( grBitmap*  target,
   if ( delta > 0 )
     height -= delta;
 
-  if ( height <= 0 )
+  if ( x < 0 || x >= target->width || height <= 0 || hline_func == NULL )
     return;
 
-  hline_func = gr_fill_hline_funcs[ target->mode ];
-  if ( hline_func )
-  {
-    line = target->buffer + y*target->pitch;
-    if ( target->pitch < 0 )
-      line -= target->pitch*(target->rows-1);
+  line = target->buffer + y*target->pitch;
+  if ( target->pitch < 0 )
+    line -= target->pitch*(target->rows-1);
 
-    for ( ; height > 0; height--, line += target->pitch )
-      hline_func( line, x, 1, color );
-  }
+  for ( ; height > 0; height--, line += target->pitch )
+    hline_func( line, x, 1, color );
 }
 
 extern void



reply via email to

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