[gimp/soc-2011-seamless-clone2] Bug 696958 - In-image preview in Transform tools is off by one screen pixel



commit 4a4ecf93bc77a9ec7e2bb8356ff05b9122f59873
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.

 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 bfa8a47..c53807a 100644
--- a/app/display/gimpcanvastransformpreview.c
+++ b/app/display/gimpcanvastransformpreview.c
@@ -1177,85 +1177,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]