changeset 202:3313d5e8d23c

removed some heap allocs
author Frank Benoit <benoit@tionex.de>
date Sat, 08 Mar 2008 16:32:26 +0100
parents 889ad17c1fe1
children 4085a50170ab
files dwt/graphics/GC.d
diffstat 1 files changed, 18 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/graphics/GC.d	Sat Mar 08 14:01:38 2008 +0100
+++ b/dwt/graphics/GC.d	Sat Mar 08 16:32:26 2008 +0100
@@ -395,11 +395,11 @@
     int nRects;
     GdkRectangle* rects;
     OS.gdk_region_get_rectangles(rgn, &rects, &nRects);
-    GdkRectangle* rect = new GdkRectangle();
-    int[] pointArray = new int[8];
+    GdkRectangle* rect;
+    int[8] pointArray;
     double x, y;
     for (int i=0; i<nRects; i++) {
-        *rect = rects[i];
+        rect = rects +i;
         x = rect.x;
         y = rect.y;
         Cairo.cairo_matrix_transform_point(cast(cairo_matrix_t*)matrix.ptr, &x, &y);
@@ -503,13 +503,13 @@
     if (data.image is null & paint) {
         OS.gdk_gc_set_exposures(handle, false);
         bool disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
-        GdkRectangle* rect = new GdkRectangle ();
+        GdkRectangle rect;
         if (disjoint) {
             rect.x = srcX;
             rect.y = srcY;
             rect.width = width;
             rect.height = height;
-            OS.gdk_window_invalidate_rect (cast(GdkWindow*)drawable, rect, false);
+            OS.gdk_window_invalidate_rect (cast(GdkWindow*)drawable, &rect, false);
 //          OS.gdk_window_clear_area_e(drawable, srcX, srcY, width, height);
         } else {
             if (deltaX !is 0) {
@@ -519,7 +519,7 @@
                 rect.y = srcY;
                 rect.width = Math.abs(deltaX);
                 rect.height = height;
-                OS.gdk_window_invalidate_rect (cast(GdkWindow*)drawable, rect, false);
+                OS.gdk_window_invalidate_rect (cast(GdkWindow*)drawable, &rect, false);
 //              OS.gdk_window_clear_area_e(drawable, newX, srcY, Math.abs(deltaX), height);
             }
             if (deltaY !is 0) {
@@ -529,7 +529,7 @@
                 rect.y = newY;
                 rect.width = width;
                 rect.height = Math.abs(deltaY);
-                OS.gdk_window_invalidate_rect (cast(GdkWindow*)drawable, rect, false);
+                OS.gdk_window_invalidate_rect (cast(GdkWindow*)drawable, &rect, false);
 //              OS.gdk_window_clear_area_e(drawable, srcX, newY, width, Math.abs(deltaY));
             }
         }
@@ -1101,11 +1101,11 @@
         int nRects;
         GdkRectangle* rects;
         OS.gdk_region_get_rectangles(clipping, &rects, &nRects);
-        GdkRectangle* rect = new GdkRectangle();
+        GdkRectangle* rect;
         short[] xRects = new short[nRects * 4];
         for (int i=0, j=0; i<nRects; i++, j+=4) {
-            *rect = rects[i];
-            xRects[j] = cast(short)rect.x;
+            rect = rects +i;
+            xRects[j  ] = cast(short)rect.x;
             xRects[j+1] = cast(short)rect.y;
             xRects[j+2] = cast(short)rect.width;
             xRects[j+3] = cast(short)rect.height;
@@ -2293,10 +2293,10 @@
     auto damageRgn = data.damageRgn;
     if (clipRgn !is null || damageRgn !is null || cairo !is null) {
         auto rgn = OS.gdk_region_new();
-        GdkRectangle* rect = new GdkRectangle();
+        GdkRectangle rect;
         rect.width = width;
         rect.height = height;
-        OS.gdk_region_union_with_rect(rgn, rect);
+        OS.gdk_region_union_with_rect(rgn, &rect);
         if (damageRgn !is null) {
             OS.gdk_region_intersect (rgn, damageRgn);
         }
@@ -2320,7 +2320,7 @@
             OS.gdk_region_destroy(rgn);
             rgn = clipRgn;
         }
-        OS.gdk_region_get_clipbox(rgn, rect);
+        OS.gdk_region_get_clipbox(rgn, &rect);
         OS.gdk_region_destroy(rgn);
         x = rect.x;
         y = rect.y;
@@ -2355,10 +2355,10 @@
     if (clipRgn is null) {
         int width,height;
         OS.gdk_drawable_get_size(data.drawable, &width, &height);
-        GdkRectangle* rect = new GdkRectangle();
+        GdkRectangle rect;
         rect.width = width;
         rect.height = height;
-        OS.gdk_region_union_with_rect(clipping, rect);
+        OS.gdk_region_union_with_rect(clipping, &rect);
     } else {
         /* Convert clipping to device space if needed */
         if (data.clippingTransform !is null) {
@@ -3079,7 +3079,7 @@
         int nRects;
         GdkRectangle * rects;
         OS.gdk_region_get_rectangles(clipRgn, &rects, &nRects);
-        GdkRectangle* rect = new GdkRectangle();
+        //GdkRectangle* rect = new GdkRectangle();
         for (int i=0; i<nRects; i++) {
             Cairo.cairo_rectangle(cairo, rects[i].x, rects[i].y, rects[i].width, rects[i].height);
         }
@@ -3156,13 +3156,13 @@
         y = y + height;
         height = -height;
     }
-    GdkRectangle* rect = new GdkRectangle();
+    GdkRectangle rect;
     rect.x = x;
     rect.y = y;
     rect.width = width;
     rect.height = height;
     auto clipRgn = OS.gdk_region_new();
-    OS.gdk_region_union_with_rect(clipRgn, rect);
+    OS.gdk_region_union_with_rect(clipRgn, &rect);
     setClipping(clipRgn);
     OS.gdk_region_destroy(clipRgn);
 }