[gimp/gimp-2-8] Bug 696958 - In-image preview in Transform tools is off by one screen pixel



commit fb38e0a5f9e2881edad43a23769f87913e18d3f2
Author: Pedro Gimeno Fortea <pggit-2e67 personal formauri es>
Date:   Tue Apr 2 17:23:40 2013 +0200

    Bug 696958 - In-image preview in Transform tools is off by one screen pixel
    
    Simplify the loops without any significant loss in performance, separating
    the positive and negative X directions to treat each correctly. Fixes this
    bug. (cherry-picked from commit faf221781126fa82cbeecc99569e02233ffbaef1)

 app/display/gimpcanvastransformpreview.c |   73 ++++++++----------------------
 1 files changed, 19 insertions(+), 54 deletions(-)
---
diff --git a/app/display/gimpcanvastransformpreview.c b/app/display/gimpcanvastransformpreview.c
index c18e1d5..75cc404 100644
--- a/app/display/gimpcanvastransformpreview.c
+++ b/app/display/gimpcanvastransformpreview.c
@@ -1370,85 +1370,50 @@ gimp_canvas_transform_preview_trace_tri_edge (gint *dest,
                                               gint  x2,
                                               gint  y2)
 {
-  const gint  dy = y2 - y1;
-  gint        dx;
-  gint        xdir;
+  const gint  dx   = x2 - x1;
+  const gint  dy   = y2 - y1;
+  gint        b    = dy;
+  gint       *dptr = dest;
   gint        errorterm;
-  gint        b;
-  gint       *dptr;
 
   if (dy <= 0)
     return;
 
   g_return_if_fail (dest != NULL);
 
-  errorterm = 0;
-  dptr      = dest;
-
-  if (x2 < x1)
-    {
-      dx = x1 - x2;
-      xdir = -1;
-    }
-  else
+  if (dx >= 0)
     {
-      dx = x2 - x1;
-      xdir = 1;
-    }
+      errorterm = 0;
 
-  if (dx >= dy)
-    {
-      b = dy;
-      while (b --)
+      while (b--)
         {
-          *dptr = x1;
+          *dptr++ = x1;
+
           errorterm += dx;
 
           while (errorterm > dy)
             {
-              x1 += xdir;
+              x1++;
               errorterm -= dy;
             }
-
-          dptr ++;
         }
     }
-  else if (dy >= dx)
+  else
     {
-      b = dy;
-      while (b --)
-        {
-          *dptr = x1;
-          errorterm += dx;
+      errorterm = dy;
 
-          if (errorterm > dy)
+      while (b--)
+        {
+          while (errorterm > dy)
             {
-              x1 += xdir;
+              x1--;
               errorterm -= dy;
             }
 
-          dptr ++;
-        }
-    }
-  else if (dx == 0)
-    {
-      b = dy;
-      while (b --)
-        {
-          *dptr = x1;
-
-          dptr ++;
-        }
-    }
-  else /* dy == dx */
-    {
-      b = dy;
-      while (b --)
-        {
-          *dptr = x1;
-          x1 += xdir;
+          /* dx is negative here, so this is effectively an addition: */
+          errorterm -= dx;
 
-          dptr ++;
+          *dptr++ = x1;
         }
     }
 }


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