freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 1cb6e3d: [graph] Fix negative pitch issues.


From: Werner Lemberg
Subject: [freetype2-demos] master 1cb6e3d: [graph] Fix negative pitch issues.
Date: Sat, 8 Jan 2022 10:18:11 -0500 (EST)

branch: master
commit 1cb6e3d657c63077bb5a3f37eb7d169c62e7313b
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [graph] Fix negative pitch issues.
    
    Some cropping issues were identified by forcing unusual negative
    pitch in glyphs.  This fixes those issues and removes some unused
    fields.
    
    * graph/gblblit.c (GBlenderBlitRec): Remove unused fields.
    * graph/gblblit.c (graph/gblblit.c): Revise negative pitch code.
    * graph/gblender.h (gblender_dump_stats): Remove macro semicolon.
---
 graph/gblblit.c  | 28 ++++++++++++----------------
 graph/gblblit.h  |  4 ----
 graph/gblender.h |  2 +-
 3 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/graph/gblblit.c b/graph/gblblit.c
index fcd73db..e1935e7 100644
--- a/graph/gblblit.c
+++ b/graph/gblblit.c
@@ -263,14 +263,14 @@ gblender_blit_init( GBlenderBlit           blit,
 
   GBlenderSourceFormat   src_format;
   const unsigned char*   src_buffer = glyph->buffer;
-  int                    src_pitch  = glyph->pitch;
+  const int              src_pitch  = glyph->pitch;
   int                    src_width  = glyph->width;
   int                    src_height = glyph->rows;
   GBlenderTargetFormat   dst_format;
   unsigned char*         dst_buffer = target->buffer;
-  int                    dst_pitch  = target->pitch;
-  int                    dst_width  = target->width;
-  int                    dst_height = target->rows;
+  const int              dst_pitch  = target->pitch;
+  const int              dst_width  = target->width;
+  const int              dst_height = target->rows;
 
 
   switch ( glyph->mode )
@@ -345,24 +345,20 @@ gblender_blit_init( GBlenderBlit           blit,
   if ( src_width <= 0 || src_height <= 0 )
     return -1;
 
-  blit->width      = src_width;
-  blit->height     = src_height;
-  blit->src_format = src_format;
-  blit->dst_format = dst_format;
+  blit->width     = src_width;
+  blit->height    = src_height;
 
-  blit->src_x     = src_x;
-  blit->src_y     = src_y;
-  blit->src_line  = src_buffer + src_pitch*src_y;
   blit->src_pitch = src_pitch;
   if ( src_pitch < 0 )
-    blit->src_line -= (src_height-1)*src_pitch;
+    src_y -= glyph->rows - 1;
+  blit->src_line  = src_buffer + src_pitch * src_y;
+  blit->src_x     = src_x;
 
-  blit->dst_x     = dst_x;
-  blit->dst_y     = dst_y;
-  blit->dst_line  = dst_buffer + dst_pitch*dst_y;
   blit->dst_pitch = dst_pitch;
   if ( dst_pitch < 0 )
-    blit->dst_line -= (dst_height-1)*dst_pitch;
+    dst_y -= dst_height - 1;
+  blit->dst_line  = dst_buffer + dst_pitch * dst_y;
+  blit->dst_x     = dst_x;
 
   return 0;
 }
diff --git a/graph/gblblit.h b/graph/gblblit.h
index 6f8a889..192cd59 100644
--- a/graph/gblblit.h
+++ b/graph/gblblit.h
@@ -48,13 +48,9 @@ typedef struct GBlenderBlitRec_
   const unsigned char*  src_line;
   int                   src_pitch;
   int                   src_x;
-  int                   src_y;
   unsigned char*        dst_line;
   int                   dst_pitch;
   int                   dst_x;
-  int                   dst_y;
-  GBlenderSourceFormat  src_format;
-  GBlenderTargetFormat  dst_format;
 
   GBlender              blender;
   GBlenderBlitFunc      blit_func;
diff --git a/graph/gblender.h b/graph/gblender.h
index 443e371..1aa7a99 100644
--- a/graph/gblender.h
+++ b/graph/gblender.h
@@ -145,7 +145,7 @@
   GBLENDER_API( void )
   gblender_dump_stats( GBlender  blender );
 #else
-# define gblender_dump_stats(b)  do { } while (0);
+# define gblender_dump_stats(b)  do { } while (0)
 #endif
 
 #ifdef GBLENDER_STATS



reply via email to

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