[gimp] app: remove lots of bounds checks from gimp_display_shell_draw_area()



commit fc5775f16fd962134d287a64a27178d7c4c8db1a
Author: Michael Natterer <mitch gimp org>
Date:   Sun May 2 13:08:11 2010 +0200

    app: remove lots of bounds checks from gimp_display_shell_draw_area()
    
    because we now guarantee to only pass in-image areas to draw.

 app/display/gimpdisplayshell-draw.c |   80 +++++++++++++----------------------
 1 files changed, 29 insertions(+), 51 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c
index 86b077a..3ee4efb 100644
--- a/app/display/gimpdisplayshell-draw.c
+++ b/app/display/gimpdisplayshell-draw.c
@@ -588,68 +588,46 @@ gimp_display_shell_draw_area (GimpDisplayShell *shell,
                               gint              w,
                               gint              h)
 {
-  gint sx, sy;
-  gint sw, sh;
+  GdkRectangle  rect;
+  gint          x2, y2;
+  gint          i, j;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+  g_return_if_fail (gimp_display_get_image (shell->display));
 
-  if (! gimp_display_get_image (shell->display))
-    return;
-
-  sx = - shell->offset_x;
-  sy = - shell->offset_y;
+  x2 = x + w;
+  y2 = y + h;
 
-  gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
+  if (shell->highlight)
+    {
+      rect.x      = ceil  (shell->scale_x * shell->highlight->x);
+      rect.y      = ceil  (shell->scale_y * shell->highlight->y);
+      rect.width  = floor (shell->scale_x * shell->highlight->width);
+      rect.height = floor (shell->scale_y * shell->highlight->height);
+    }
 
-  /*  check if the passed in area intersects with
-   *  both the display and the image
+  /*  display the image in RENDER_BUF_WIDTH x RENDER_BUF_HEIGHT
+   *  sized chunks
    */
-  if (gimp_rectangle_intersect (x, y, w, h,
-                                0, 0, shell->disp_width,  shell->disp_height,
-                                &x, &y, &w, &h)
-      &&
-      gimp_rectangle_intersect (x, y, w, h,
-                                sx, sy, sw, sh,
-                                &x, &y, &w, &h))
+  for (i = y; i < y2; i += GIMP_DISPLAY_RENDER_BUF_HEIGHT)
     {
-      GdkRectangle  rect;
-      gint          x2, y2;
-      gint          i, j;
-
-      x2 = x + w;
-      y2 = y + h;
-
-      if (shell->highlight)
+      for (j = x; j < x2; j += GIMP_DISPLAY_RENDER_BUF_WIDTH)
         {
-          rect.x      = ceil  (shell->scale_x * shell->highlight->x);
-          rect.y      = ceil  (shell->scale_y * shell->highlight->y);
-          rect.width  = floor (shell->scale_x * shell->highlight->width);
-          rect.height = floor (shell->scale_y * shell->highlight->height);
-        }
+          gint disp_xoffset, disp_yoffset;
+          gint dx, dy;
 
-      /*  display the image in RENDER_BUF_WIDTH x RENDER_BUF_HEIGHT
-       *  sized chunks
-       */
-      for (i = y; i < y2; i += GIMP_DISPLAY_RENDER_BUF_HEIGHT)
-        {
-          for (j = x; j < x2; j += GIMP_DISPLAY_RENDER_BUF_WIDTH)
-            {
-              gint disp_xoffset, disp_yoffset;
-              gint dx, dy;
+          dx = MIN (x2 - j, GIMP_DISPLAY_RENDER_BUF_WIDTH);
+          dy = MIN (y2 - i, GIMP_DISPLAY_RENDER_BUF_HEIGHT);
 
-              dx = MIN (x2 - j, GIMP_DISPLAY_RENDER_BUF_WIDTH);
-              dy = MIN (y2 - i, GIMP_DISPLAY_RENDER_BUF_HEIGHT);
+          gimp_display_shell_scroll_get_disp_offset (shell,
+                                                     &disp_xoffset,
+                                                     &disp_yoffset);
 
-              gimp_display_shell_scroll_get_disp_offset (shell,
-                                                         &disp_xoffset,
-                                                         &disp_yoffset);
-
-              gimp_display_shell_render (shell,
-                                         j - disp_xoffset,
-                                         i - disp_yoffset,
-                                         dx, dy,
-                                         shell->highlight ? &rect : NULL);
-            }
+          gimp_display_shell_render (shell,
+                                     j - disp_xoffset,
+                                     i - disp_yoffset,
+                                     dx, dy,
+                                     shell->highlight ? &rect : NULL);
         }
     }
 }



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