[PATCH] uint32_t -> int32_t in rectangle functions

Mika Pruikkonen <[email protected]>
Newsgroups gmane.comp.graphics.y.devel
Message-ID <[email protected]>
Y slowed down dramatically when I moved a window out of the left or
top border of the screen when using fbdev. I remember that there
was a change from unsigned to signed coordinates a few months back
(I think it was discussed in irc), but I found some unsigned
coordinates remaining in Y/util/rectangle.[ch]. I think that the
whole screen was invalidated during window movement if one of the 
window's coordinates became negative. 

The coordinates and dimensions were already saved as signed integers 
in struct Rectangle, there were just a few arguments and internal 
variables which still used unsigned values. This patch changes them 
and fixes the problem. It can also be found as patch-2 in the same 
archive as the previous patch I posted.


--- orig/Y/util/rectangle.c
+++ mod/Y/util/rectangle.c
@@ -20,7 +20,7 @@
 #include <Y/util/yutil.h>
 
 struct Rectangle *
-rectangleCreate (uint32_t x, uint32_t y, uint32_t w, uint32_t h)
+rectangleCreate (int32_t x, int32_t y, int32_t w, int32_t h)
 {
   struct Rectangle *rect = ymalloc (sizeof (struct Rectangle));
   rect -> x = x;
@@ -46,7 +46,7 @@
 rectangleUnion (struct Rectangle *dest,
                 const struct Rectangle *src1, const struct Rectangle *src2)
 {
-  uint32_t x0, y0, x1, y1, w, h, area0, area1;
+  int32_t x0, y0, x1, y1, w, h, area0, area1;
   x0 = MIN (src1 -> x, src2 -> x);
   y0 = MIN (src1 -> y, src2 -> y);
   x1 = MAX (src1 -> x + src1 -> w, src2 -> x + src2 -> w);   
@@ -69,10 +69,10 @@
 rectangleIntersect (struct Rectangle *dest,
                     const struct Rectangle *src1, const struct Rectangle *src2)
 {
-  uint32_t x = MAX (src1 -> x, src2 -> x);
-  uint32_t y = MAX (src1 -> y, src2 -> y);
-  uint32_t mw = MIN (src1 -> x + src1 -> w, src2 -> x + src2 -> w);
-  uint32_t mh = MIN (src1 -> y + src1 -> h, src2 -> y + src2 -> h);
+  int32_t x = MAX (src1 -> x, src2 -> x);
+  int32_t y = MAX (src1 -> y, src2 -> y);
+  int32_t mw = MIN (src1 -> x + src1 -> w, src2 -> x + src2 -> w);
+  int32_t mh = MIN (src1 -> y + src1 -> h, src2 -> y + src2 -> h);
   if (dest)
     {
       dest -> x = x;


--- orig/Y/util/rectangle.h
+++ mod/Y/util/rectangle.h
@@ -32,7 +32,7 @@
 
 #include <Y/util/llist.h>
 
-struct Rectangle *rectangleCreate (uint32_t x, uint32_t y, uint32_t w, uint32_t h);
+struct Rectangle *rectangleCreate (int32_t x, int32_t y, int32_t w, int32_t h);
 struct Rectangle *rectangleDuplicate (const struct Rectangle *);
 void              rectangleDestroy (struct Rectangle *);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.