Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        draw.c 


Log Message:
Cleanups.

===================================================================
RCS file: /cvs/e/e16/e/src/draw.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -3 -r1.97 -r1.98
--- draw.c      17 Jan 2007 01:10:42 -0000      1.97
+++ draw.c      9 Jun 2007 14:17:38 -0000       1.98
@@ -132,109 +132,81 @@
 }
 
 static void
-EBlendRemoveShape(EWin * ewin, Pixmap pmap, int x, int y)
+EBlendRemoveShape(Win win, Pixmap pmap, int x, int y)
 {
-   static GC           gc = 0, gcm = 0;
-   static int          rn, ord;
-   static XRectangle  *rl = NULL;
-   static Pixmap       mask = 0;
+   static GC           gc = 0;
    Window              root = VRoot.xwin;
-   XGCValues           gcv;
-   int                 i, w, h;
+   int                 w, h;
 
-   if (!ewin)
+   if (!win)
      {
-       if (rl)
-          XFree(rl);
        if (gc)
           EXFreeGC(gc);
-       if (gcm)
-          EXFreeGC(gcm);
-       if (mask)
-          EXFreePixmap(mask);
-       mask = 0;
        gc = 0;
-       gcm = 0;
-       rl = NULL;
        return;
      }
 
-   w = EoGetW(ewin);
-   h = EoGetH(ewin);
-   if (!rl)
-     {
-       rl = EShapeGetRectangles(EoGetWin(ewin), ShapeBounding, &rn, &ord);
-       if (rn < 1)
-          return;
-       else if (rn == 1)
-         {
-            if ((rl[0].x == 0) && (rl[0].y == 0)
-                && (rl[0].width == EoGetW(ewin))
-                && (rl[0].height == EoGetH(ewin)))
-              {
-                 if (rl)
-                    XFree(rl);
-                 rl = NULL;
-                 return;
-              }
-         }
-     }
-   if (!mask)
-      mask = EXCreatePixmap(root, w, h, 1);
-   if (!gcm)
-      gcm = EXCreateGC(mask, 0, &gcv);
+   w = WinGetW(win);
+   h = WinGetH(win);
+
    if (!gc)
      {
+       XGCValues           gcv;
+       GC                  gcm;
+       Pixmap              mask;
+       XRectangle         *rl;
+       int                 i;
+
        gcv.subwindow_mode = IncludeInferiors;
        gc = EXCreateGC(root, GCSubwindowMode, &gcv);
+
+       mask = EXCreatePixmap(root, w, h, 1);
+       gcm = EXCreateGC(mask, 0, NULL);
        XSetForeground(disp, gcm, 1);
        XFillRectangle(disp, mask, gcm, 0, 0, w, h);
        XSetForeground(disp, gcm, 0);
-       for (i = 0; i < rn; i++)
+       rl = win->rects;
+       for (i = 0; i < win->num_rect; i++)
           XFillRectangle(disp, mask, gcm, rl[i].x, rl[i].y, rl[i].width,
                          rl[i].height);
        XSetClipMask(disp, gc, mask);
+       EXFreeGC(gcm);
+       EXFreePixmap(mask);
      }
+
    XSetClipOrigin(disp, gc, x, y);
    XCopyArea(disp, pmap, root, gc, x, y, w, h, x, y);
 }
 
 static void
-EBlendPixImg(EWin * ewin, PixImg * s1, PixImg * s2, PixImg * dst, int x, int y,
+EBlendPixImg(Win win, PixImg * s1, PixImg * s2, PixImg * dst, int x, int y,
             int w, int h)
 {
-   static int          rn, ord;
-   static XRectangle  *rl = NULL;
    static GC           gc = 0;
    Window              root = VRoot.xwin;
-   XGCValues           gcv;
    int                 i, j, ox, oy;
 
-   if (!s1)
+   if (!win)
      {
        if (gc)
           EXFreeGC(gc);
-       if (rl > (XRectangle *) 1)
-          XFree(rl);
        gc = 0;
-       rl = NULL;
        return;
      }
+
    if (!gc)
      {
+       XGCValues           gcv;
+
        gcv.subwindow_mode = IncludeInferiors;
        gc = EXCreateGC(root, GCSubwindowMode, &gcv);
-     }
-   if (!rl)
-     {
-       rl = EShapeGetRectangles(EoGetWin(ewin), ShapeBounding, &rn, &ord);
-       if (rl)
-          XSetClipRectangles(disp, gc, x, y, rl, rn, ord);
-       if (!rl)
-          rl = (XRectangle *) 1;
+       if (win->rects)
+          XSetClipRectangles(disp, gc, x, y, win->rects, win->num_rect,
+                             win->ord);
      }
    else
       XSetClipOrigin(disp, gc, x, y);
+
    ox = 0;
    oy = 0;
    if ((x >= VRoot.w) || (y >= VRoot.h))
@@ -260,11 +232,59 @@
 
    ESync();
 
-   if (dst)
+   switch (dst->xim->bits_per_pixel)
      {
-       switch (dst->xim->bits_per_pixel)
+     case 32:
+       for (j = 0; j < h; j++)
+         {
+            unsigned int       *ptr1, *ptr2, *ptr3;
+
+            ptr1 =
+               (unsigned int *)(s1->xim->data +
+                                ((x) *
+                                 ((s1->xim->bits_per_pixel) >> 3)) +
+                                ((j + y) * s1->xim->bytes_per_line));
+            ptr2 =
+               (unsigned int *)(s2->xim->data +
+                                ((ox) *
+                                 ((s2->xim->bits_per_pixel) >> 3)) +
+                                ((j + oy) * s2->xim->bytes_per_line));
+            ptr3 =
+               (unsigned int *)(dst->xim->data +
+                                ((ox) *
+                                 ((dst->xim->bits_per_pixel) >> 3)) +
+                                ((j + oy) * dst->xim->bytes_per_line));
+            for (i = 0; i < w; i++)
+              {
+                 unsigned int        p1, p2;
+
+                 p1 = *ptr1++;
+                 p2 = *ptr2++;
+                 *ptr3++ =
+                    ((p1 >> 1) & 0x7f7f7f7f) +
+                    ((p2 >> 1) & 0x7f7f7f7f) + (p1 & p2 & 0x01010101);
+              }
+         }
+       break;
+     case 24:
+       for (j = 0; j < h; j++)
+         {
+            for (i = 0; i < w; i++)
+              {
+                 unsigned int        p1, p2;
+
+                 p1 = XGetPixel(s1->xim, (i + x), (j + y));
+                 p2 = XGetPixel(s2->xim, (i + ox), (j + oy));
+                 XPutPixel(dst->xim, (i + ox), (j + oy),
+                           (((p1 >> 1) & 0x7f7f7f7f) +
+                            ((p2 >> 1) & 0x7f7f7f7f) +
+                            (p1 & p2 & 0x01010101)));
+              }
+         }
+       break;
+     case 16:
+       if (DefaultDepth(disp, VRoot.scr) != 15)
          {
-         case 32:
             for (j = 0; j < h; j++)
               {
                  unsigned int       *ptr1, *ptr2, *ptr3;
@@ -284,348 +304,362 @@
                                      ((ox) *
                                       ((dst->xim->bits_per_pixel) >> 3)) +
                                      ((j + oy) * dst->xim->bytes_per_line));
-                 for (i = 0; i < w; i++)
+                 if (!(w & 0x1))
                    {
-                      unsigned int        p1, p2;
+                      for (i = 0; i < w; i += 2)
+                        {
+                           unsigned int        p1, p2;
 
-                      p1 = *ptr1++;
-                      p2 = *ptr2++;
-                      *ptr3++ =
-                         ((p1 >> 1) & 0x7f7f7f7f) +
-                         ((p2 >> 1) & 0x7f7f7f7f) + (p1 & p2 & 0x01010101);
+                           p1 = *ptr1++;
+                           p2 = *ptr2++;
+                           *ptr3++ =
+                              ((p1 >> 1) &
+                               ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)
+                                | (0x78 << 24) | (0x7c << 19) | (0x78
+                                                                 <<
+                                                                 13)))
+                              +
+                              ((p2 >> 1) &
+                               ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)
+                                | (0x78 << 24) | (0x7c << 19) | (0x78
+                                                                 <<
+                                                                 13)))
+                              +
+                              (p1 & p2 &
+                               ((0x1 << 11) | (0x1 << 5) | (0x1) |
+                                (0x1 << 27) | (0x1 << 21) | (0x1 << 16)));
+                        }
+                   }
+                 else
+                   {
+                      for (i = 0; i < (w - 1); i += 2)
+                        {
+                           unsigned int        p1, p2;
+
+                           p1 = *ptr1++;
+                           p2 = *ptr2++;
+                           *ptr3++ =
+                              ((p1 >> 1) &
+                               ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)
+                                | (0x78 << 24) | (0x7c << 19) | (0x78
+                                                                 <<
+                                                                 13)))
+                              +
+                              ((p2 >> 1) &
+                               ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)
+                                | (0x78 << 24) | (0x7c << 19) | (0x78
+                                                                 <<
+                                                                 13)))
+                              +
+                              (p1 & p2 &
+                               ((0x1 << 11) | (0x1 << 5) | (0x1) |
+                                (0x1 << 27) | (0x1 << 21) | (0x1 << 16)));
+                        }
+                      {
+                         unsigned short     *pptr1, *pptr2, *pptr3;
+                         unsigned short      pp1, pp2;
+
+                         pptr1 = (unsigned short *)ptr1;
+                         pptr2 = (unsigned short *)ptr2;
+                         pptr3 = (unsigned short *)ptr3;
+                         pp1 = *pptr1;
+                         pp2 = *pptr2;
+                         *pptr3 =
+                            ((pp1 >> 1) &
+                             ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)))
+                            +
+                            ((pp2 >> 1) &
+                             ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)))
+                            + (pp1 & pp2 & ((0x1 << 11) | (0x1 << 5) | (0x1)));
+                      }
                    }
               }
-            break;
-         case 24:
+         }
+       else
+         {
             for (j = 0; j < h; j++)
               {
-                 for (i = 0; i < w; i++)
-                   {
-                      unsigned int        p1, p2;
+                 unsigned int       *ptr1, *ptr2, *ptr3;
 
-                      p1 = XGetPixel(s1->xim, (i + x), (j + y));
-                      p2 = XGetPixel(s2->xim, (i + ox), (j + oy));
-                      XPutPixel(dst->xim, (i + ox), (j + oy),
-                                (((p1 >> 1) & 0x7f7f7f7f) +
-                                 ((p2 >> 1) & 0x7f7f7f7f) +
-                                 (p1 & p2 & 0x01010101)));
-                   }
-              }
-            break;
-         case 16:
-            if (DefaultDepth(disp, VRoot.scr) != 15)
-              {
-                 for (j = 0; j < h; j++)
-                   {
-                      unsigned int       *ptr1, *ptr2, *ptr3;
-
-                      ptr1 =
-                         (unsigned int *)(s1->xim->data +
-                                          ((x) *
-                                           ((s1->xim->bits_per_pixel) >> 3)) +
-                                          ((j + y) * s1->xim->bytes_per_line));
-                      ptr2 =
-                         (unsigned int *)(s2->xim->data +
-                                          ((ox) *
-                                           ((s2->xim->bits_per_pixel) >> 3)) +
-                                          ((j +
-                                            oy) * s2->xim->bytes_per_line));
-                      ptr3 =
-                         (unsigned int *)(dst->xim->data +
-                                          ((ox) *
-                                           ((dst->xim->bits_per_pixel) >> 3)) +
-                                          ((j +
-                                            oy) * dst->xim->bytes_per_line));
-                      if (!(w & 0x1))
+                 ptr1 =
+                    (unsigned int *)(s1->xim->data +
+                                     ((x) *
+                                      ((s1->xim->
+                                        bits_per_pixel) >> 3)) + ((j +
+                                                                   y) *
+                                                                  s1->
+                                                                  xim->
+                                                                  
bytes_per_line));
+                 ptr2 =
+                    (unsigned int *)(s2->xim->data +
+                                     ((ox) *
+                                      ((s2->xim->
+                                        bits_per_pixel) >> 3)) + ((j +
+                                                                   oy)
+                                                                  *
+                                                                  s2->
+                                                                  xim->
+                                                                  
bytes_per_line));
+                 ptr3 =
+                    (unsigned int *)(dst->xim->data +
+                                     ((ox) *
+                                      ((dst->xim->
+                                        bits_per_pixel) >> 3)) + ((j +
+                                                                   oy)
+                                                                  *
+                                                                  dst->
+                                                                  xim->
+                                                                  
bytes_per_line));
+                 if (!(w & 0x1))
+                   {
+                      for (i = 0; i < w; i += 2)
                         {
-                           for (i = 0; i < w; i += 2)
-                             {
-                                unsigned int        p1, p2;
-
-                                p1 = *ptr1++;
-                                p2 = *ptr2++;
-                                *ptr3++ =
-                                   ((p1 >> 1) &
-                                    ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)
-                                     | (0x78 << 24) | (0x7c << 19) | (0x78
-                                                                      <<
-                                                                      13)))
-                                   +
-                                   ((p2 >> 1) &
-                                    ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)
-                                     | (0x78 << 24) | (0x7c << 19) | (0x78
-                                                                      <<
-                                                                      13)))
-                                   +
-                                   (p1 & p2 &
-                                    ((0x1 << 11) | (0x1 << 5) | (0x1) |
-                                     (0x1 << 27) | (0x1 << 21) | (0x1 << 16)));
-                             }
+                           unsigned int        p1, p2;
+
+                           p1 = *ptr1++;
+                           p2 = *ptr2++;
+                           *ptr3++ =
+                              ((p1 >> 1) &
+                               ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)
+                                | (0x78 << 23) | (0x78 << 18) | (0x78
+                                                                 <<
+                                                                 13)))
+                              +
+                              ((p2 >> 1) &
+                               ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)
+                                | (0x78 << 23) | (0x78 << 18) | (0x78
+                                                                 <<
+                                                                 13)))
+                              +
+                              (p1 & p2 &
+                               ((0x1 << 10) | (0x1 << 5) | (0x1) |
+                                (0x1 << 26) | (0x1 << 20) | (0x1 << 16)));
                         }
-                      else
+                   }
+                 else
+                   {
+                      for (i = 0; i < (w - 1); i += 2)
                         {
-                           for (i = 0; i < (w - 1); i += 2)
-                             {
-                                unsigned int        p1, p2;
-
-                                p1 = *ptr1++;
-                                p2 = *ptr2++;
-                                *ptr3++ =
-                                   ((p1 >> 1) &
-                                    ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)
-                                     | (0x78 << 24) | (0x7c << 19) | (0x78
-                                                                      <<
-                                                                      13)))
-                                   +
-                                   ((p2 >> 1) &
-                                    ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)
-                                     | (0x78 << 24) | (0x7c << 19) | (0x78
-                                                                      <<
-                                                                      13)))
-                                   +
-                                   (p1 & p2 &
-                                    ((0x1 << 11) | (0x1 << 5) | (0x1) |
-                                     (0x1 << 27) | (0x1 << 21) | (0x1 << 16)));
-                             }
-                           {
-                              unsigned short     *pptr1, *pptr2, *pptr3;
-                              unsigned short      pp1, pp2;
-
-                              pptr1 = (unsigned short *)ptr1;
-                              pptr2 = (unsigned short *)ptr2;
-                              pptr3 = (unsigned short *)ptr3;
-                              pp1 = *pptr1;
-                              pp2 = *pptr2;
-                              *pptr3 =
-                                 ((pp1 >> 1) &
-                                  ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)))
-                                 +
-                                 ((pp2 >> 1) &
-                                  ((0x78 << 8) | (0x7c << 3) | (0x78 >> 3)))
-                                 +
-                                 (pp1 & pp2 &
-                                  ((0x1 << 11) | (0x1 << 5) | (0x1)));
-                           }
+                           unsigned int        p1, p2;
+
+                           p1 = *ptr1++;
+                           p2 = *ptr2++;
+                           *ptr3++ =
+                              ((p1 >> 1) &
+                               ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)
+                                | (0x78 << 23) | (0x78 << 18) | (0x78
+                                                                 <<
+                                                                 13)))
+                              +
+                              ((p2 >> 1) &
+                               ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)
+                                | (0x78 << 23) | (0x78 << 18) | (0x78
+                                                                 <<
+                                                                 13)))
+                              +
+                              (p1 & p2 &
+                               ((0x1 << 10) | (0x1 << 5) | (0x1) |
+                                (0x1 << 26) | (0x1 << 20) | (0x1 << 16)));
                         }
+                      {
+                         unsigned short     *pptr1, *pptr2, *pptr3;
+                         unsigned short      pp1, pp2;
+
+                         pptr1 = (unsigned short *)ptr1;
+                         pptr2 = (unsigned short *)ptr2;
+                         pptr3 = (unsigned short *)ptr3;
+                         pp1 = *pptr1;
+                         pp2 = *pptr2;
+                         *pptr3++ =
+                            ((pp1 >> 1) &
+                             ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)))
+                            +
+                            ((pp2 >> 1) &
+                             ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)))
+                            + (pp1 & pp2 & ((0x1 << 10) | (0x1 << 5) | (0x1)));
+                      }
                    }
               }
-            else
+         }
+       break;
+     default:
+       for (j = 0; j < h; j++)
+         {
+            unsigned char      *ptr1, *ptr2, *ptr3;
+
+            ptr1 =
+               (unsigned char *)(s1->xim->data +
+                                 ((x) *
+                                  ((s1->xim->bits_per_pixel) >> 3)) +
+                                 ((j + y) * s1->xim->bytes_per_line));
+            ptr2 =
+               (unsigned char *)(s2->xim->data +
+                                 ((ox) *
+                                  ((s2->xim->bits_per_pixel) >> 3)) +
+                                 ((j + oy) * s2->xim->bytes_per_line));
+            ptr3 =
+               (unsigned char *)(dst->xim->data +
+                                 ((ox) *
+                                  ((dst->xim->bits_per_pixel) >> 3)) +
+                                 ((j + oy) * dst->xim->bytes_per_line));
+            if (!(w & 0x1))
               {
-                 for (j = 0; j < h; j++)
+                 if (j & 0x1)
                    {
-                      unsigned int       *ptr1, *ptr2, *ptr3;
-
-                      ptr1 =
-                         (unsigned int *)(s1->xim->data +
-                                          ((x) *
-                                           ((s1->xim->
-                                             bits_per_pixel) >> 3)) + ((j +
-                                                                        y) *
-                                                                       s1->
-                                                                       xim->
-                                                                       
bytes_per_line));
-                      ptr2 =
-                         (unsigned int *)(s2->xim->data +
-                                          ((ox) *
-                                           ((s2->xim->
-                                             bits_per_pixel) >> 3)) + ((j +
-                                                                        oy)
-                                                                       *
-                                                                       s2->
-                                                                       xim->
-                                                                       
bytes_per_line));
-                      ptr3 =
-                         (unsigned int *)(dst->xim->data +
-                                          ((ox) *
-                                           ((dst->xim->
-                                             bits_per_pixel) >> 3)) + ((j +
-                                                                        oy)
-                                                                       *
-                                                                       dst->
-                                                                       xim->
-                                                                       
bytes_per_line));
-                      if (!(w & 0x1))
+                      ptr2++;
+                      for (i = 0; i < w; i += 2)
                         {
-                           for (i = 0; i < w; i += 2)
-                             {
-                                unsigned int        p1, p2;
-
-                                p1 = *ptr1++;
-                                p2 = *ptr2++;
-                                *ptr3++ =
-                                   ((p1 >> 1) &
-                                    ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)
-                                     | (0x78 << 23) | (0x78 << 18) | (0x78
-                                                                      <<
-                                                                      13)))
-                                   +
-                                   ((p2 >> 1) &
-                                    ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)
-                                     | (0x78 << 23) | (0x78 << 18) | (0x78
-                                                                      <<
-                                                                      13)))
-                                   +
-                                   (p1 & p2 &
-                                    ((0x1 << 10) | (0x1 << 5) | (0x1) |
-                                     (0x1 << 26) | (0x1 << 20) | (0x1 << 16)));
-                             }
+                           unsigned char       p1;
+
+                           p1 = *ptr1;
+                           ptr1 += 2;
+                           *ptr3++ = p1;
+                           p1 = *ptr2;
+                           ptr2 += 2;
+                           *ptr3++ = p1;
                         }
-                      else
+                   }
+                 else
+                   {
+                      ptr1++;
+                      for (i = 0; i < w; i += 2)
                         {
-                           for (i = 0; i < (w - 1); i += 2)
-                             {
-                                unsigned int        p1, p2;
-
-                                p1 = *ptr1++;
-                                p2 = *ptr2++;
-                                *ptr3++ =
-                                   ((p1 >> 1) &
-                                    ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)
-                                     | (0x78 << 23) | (0x78 << 18) | (0x78
-                                                                      <<
-                                                                      13)))
-                                   +
-                                   ((p2 >> 1) &
-                                    ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)
-                                     | (0x78 << 23) | (0x78 << 18) | (0x78
-                                                                      <<
-                                                                      13)))
-                                   +
-                                   (p1 & p2 &
-                                    ((0x1 << 10) | (0x1 << 5) | (0x1) |
-                                     (0x1 << 26) | (0x1 << 20) | (0x1 << 16)));
-                             }
-                           {
-                              unsigned short     *pptr1, *pptr2, *pptr3;
-                              unsigned short      pp1, pp2;
-
-                              pptr1 = (unsigned short *)ptr1;
-                              pptr2 = (unsigned short *)ptr2;
-                              pptr3 = (unsigned short *)ptr3;
-                              pp1 = *pptr1;
-                              pp2 = *pptr2;
-                              *pptr3++ =
-                                 ((pp1 >> 1) &
-                                  ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)))
-                                 +
-                                 ((pp2 >> 1) &
-                                  ((0x78 << 7) | (0x78 << 2) | (0x78 >> 3)))
-                                 +
-                                 (pp1 & pp2 &
-                                  ((0x1 << 10) | (0x1 << 5) | (0x1)));
-                           }
+                           unsigned char       p1;
+
+                           p1 = *ptr2;
+                           ptr2 += 2;
+                           *ptr3++ = p1;
+                           p1 = *ptr1;
+                           ptr1 += 2;
+                           *ptr3++ = p1;
                         }
                    }
               }
-            break;
-         default:
-            for (j = 0; j < h; j++)
+            else
               {
-                 unsigned char      *ptr1, *ptr2, *ptr3;
-
-                 ptr1 =
-                    (unsigned char *)(s1->xim->data +
-                                      ((x) *
-                                       ((s1->xim->bits_per_pixel) >> 3)) +
-                                      ((j + y) * s1->xim->bytes_per_line));
-                 ptr2 =
-                    (unsigned char *)(s2->xim->data +
-                                      ((ox) *
-                                       ((s2->xim->bits_per_pixel) >> 3)) +
-                                      ((j + oy) * s2->xim->bytes_per_line));
-                 ptr3 =
-                    (unsigned char *)(dst->xim->data +
-                                      ((ox) *
-                                       ((dst->xim->bits_per_pixel) >> 3)) +
-                                      ((j + oy) * dst->xim->bytes_per_line));
-                 if (!(w & 0x1))
+                 if (j & 0x1)
                    {
-                      if (j & 0x1)
+                      ptr2++;
+                      for (i = 0; i < (w - 1); i += 2)
                         {
-                           ptr2++;
-                           for (i = 0; i < w; i += 2)
-                             {
-                                unsigned char       p1;
-
-                                p1 = *ptr1;
-                                ptr1 += 2;
-                                *ptr3++ = p1;
-                                p1 = *ptr2;
-                                ptr2 += 2;
-                                *ptr3++ = p1;
-                             }
-                        }
-                      else
-                        {
-                           ptr1++;
-                           for (i = 0; i < w; i += 2)
-                             {
-                                unsigned char       p1;
-
-                                p1 = *ptr2;
-                                ptr2 += 2;
-                                *ptr3++ = p1;
-                                p1 = *ptr1;
-                                ptr1 += 2;
-                                *ptr3++ = p1;
-                             }
+                           unsigned char       p1;
+
+                           p1 = *ptr1;
+                           ptr1 += 2;
+                           *ptr3++ = p1;
+                           p1 = *ptr2;
+                           ptr2 += 2;
+                           *ptr3++ = p1;
                         }
+                      *ptr3 = *ptr1;
                    }
                  else
                    {
-                      if (j & 0x1)
-                        {
-                           ptr2++;
-                           for (i = 0; i < (w - 1); i += 2)
-                             {
-                                unsigned char       p1;
-
-                                p1 = *ptr1;
-                                ptr1 += 2;
-                                *ptr3++ = p1;
-                                p1 = *ptr2;
-                                ptr2 += 2;
-                                *ptr3++ = p1;
-                             }
-                           *ptr3 = *ptr1;
-                        }
-                      else
+                      ptr1++;
+                      for (i = 0; i < (w - 1); i += 2)
                         {
-                           ptr1++;
-                           for (i = 0; i < (w - 1); i += 2)
-                             {
-                                unsigned char       p1;
-
-                                p1 = *ptr2;
-                                ptr2 += 2;
-                                *ptr3++ = p1;
-                                p1 = *ptr1;
-                                ptr1 += 2;
-                                *ptr3++ = p1;
-                             }
-                           *ptr3 = *ptr2;
+                           unsigned char       p1;
+
+                           p1 = *ptr2;
+                           ptr2 += 2;
+                           *ptr3++ = p1;
+                           p1 = *ptr1;
+                           ptr1 += 2;
+                           *ptr3++ = p1;
                         }
+                      *ptr3 = *ptr2;
                    }
               }
-            break;
          }
+       break;
+     }
 /* workaround since XCopyArea doesnt always work with shared pixmaps */
-       XShmPutImage(disp, root, gc, dst->xim, ox, oy, x, y, w, h, False);
+   XShmPutImage(disp, root, gc, dst->xim, ox, oy, x, y, w, h, False);
 /*      XCopyArea(disp, dst->pmap, root, gc, ox, oy, w, h, x, y); */
-     }
 /* I dont believe it - you cannot do this to a shared pixmaps to the screen */
 /* XCopyArea(disp, dst->pmap, root, dst->gc, x, y, w, h, x, y); */
 }
 
-#include <X11/bitmaps/flipped_gray>
 #include <X11/bitmaps/gray>
 #include <X11/bitmaps/gray3>
 
+#define DRAW_H_ARROW(_dr, _gc, x1, x2, y1) \
+      if (((x2) - (x1)) >= 12) \
+        { \
+          XDrawLine(disp, _dr, _gc, (x1), (y1), (x1) + 6, (y1) - 3); \
+          XDrawLine(disp, _dr, _gc, (x1), (y1), (x1) + 6, (y1) + 3); \
+          XDrawLine(disp, _dr, _gc, (x2), (y1), (x2) - 6, (y1) - 3); \
+          XDrawLine(disp, _dr, _gc, (x2), (y1), (x2) - 6, (y1) + 3); \
+        } \
+      if ((x2) >= (x1)) \
+        { \
+          XDrawLine(disp, _dr, _gc, (x1), (y1), (x2), (y1)); \
+          Esnprintf(str, sizeof(str), "%i", (x2) - (x1) + 1); \
+          XDrawString(disp, _dr, _gc, ((x1) + (x2)) / 2, (y1) - 10, str, 
strlen(str)); \
+        }
+#define DRAW_V_ARROW(_dr, _gc, y1, y2, x1) \
+      if (((y2) - (y1)) >= 12) \
+        { \
+          XDrawLine(disp, _dr, _gc, (x1), (y1), (x1) + 3, (y1) + 6); \
+          XDrawLine(disp, _dr, _gc, (x1), (y1), (x1) - 3, (y1) + 6); \
+          XDrawLine(disp, _dr, _gc, (x1), (y2), (x1) + 3, (y2) - 6); \
+          XDrawLine(disp, _dr, _gc, (x1), (y2), (x1) - 3, (y2) - 6); \
+        } \
+      if ((y2) >= (y1)) \
+        { \
+          XDrawLine(disp, _dr, _gc, (x1), (y1), (x1), (y2)); \
+          Esnprintf(str, sizeof(str), "%i", (y2) - (y1) + 1); \
+          XDrawString(disp, _dr, _gc, (x1) + 10, ((y1) + (y2)) / 2, str, 
strlen(str)); \
+        }
+#define DO_DRAW_MODE_1(_dr, _gc, _a, _b, _c, _d) \
+      if (!font) \
+        font = XLoadFont(disp, "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*"); \
+      XSetFont(disp, _gc, font); \
+      if (_c < 3) _c = 3; \
+      if (_d < 3) _d = 3; \
+      DRAW_H_ARROW(_dr, _gc, _a + bl, _a + bl + _c - 1, _b + bt + _d - 16); \
+      DRAW_H_ARROW(_dr, _gc, 0, _a - 1, _b + bt + (_d / 2)); \
+      DRAW_H_ARROW(_dr, _gc, _a + _c + bl + br, VRoot.w - 1, _b + bt + (_d / 
2)); \
+      DRAW_V_ARROW(_dr, _gc, _b + bt, _b + bt + _d - 1, _a + bl + 16); \
+      DRAW_V_ARROW(_dr, _gc, 0, _b - 1, _a + bl + (_c / 2)); \
+      DRAW_V_ARROW(_dr, _gc, _b + _d + bt + bb, VRoot.h - 1, _a + bl + (_c / 
2)); \
+      XDrawLine(disp, _dr, _gc, _a, 0, _a, VRoot.h); \
+      XDrawLine(disp, _dr, _gc, _a + _c + bl + br - 1, 0, _a + _c + bl + br - 
1, VRoot.h); \
+      XDrawLine(disp, _dr, _gc, 0, _b, VRoot.w, _b); \
+      XDrawLine(disp, _dr, _gc, 0, _b + _d + bt + bb - 1, VRoot.w, _b + _d + 
bt + bb - 1); \
+      XDrawRectangle(disp, _dr, _gc, _a + bl + 1, _b + bt + 1, _c - 3, _d - 3);
+
+#define DO_DRAW_MODE_2(_dr, _gc, _a, _b, _c, _d) \
+      if (_c < 3) _c = 3; \
+      if (_d < 3) _d = 3; \
+      XDrawRectangle(disp, _dr, _gc, _a, _b, _c + bl + br - 1, _d + bt + bb - 
1); \
+      XDrawRectangle(disp, _dr, _gc, _a + bl + 1, _b + bt + 1, _c - 3, _d - 3);
+
+#define DO_DRAW_MODE_3(_dr, _gc, _a, _b, _c, _d) \
+      XSetFillStyle(disp, _gc, FillStippled); \
+      XSetStipple(disp, _gc, b2); \
+      if ((_c + bl + br > 0) && (bt > 0)) \
+        XFillRectangle(disp, _dr, _gc, _a, _b, _c + bl + br, bt); \
+      if ((_c + bl + br > 0) && (bb > 0)) \
+        XFillRectangle(disp, _dr, _gc, _a, _b + _d + bt, _c + bl + br, bb); \
+      if ((_d > 0) && (bl > 0)) \
+        XFillRectangle(disp, _dr, _gc, _a, _b + bt, bl, _d); \
+      if ((_d > 0) && (br > 0)) \
+        XFillRectangle(disp, _dr, _gc, _a + _c + bl, _b + bt, br, _d); \
+      XSetStipple(disp, _gc, b3); \
+      if ((_c > 0) && (_d > 0)) \
+        XFillRectangle(disp, _dr, _gc, _a + bl + 1, _b + bt + 1, _c - 3, _d - 
3);
+
+#define DO_DRAW_MODE_4(_dr, _gc, _a, _b, _c, _d) \
+      XSetFillStyle(disp, _gc, FillStippled); \
+      XSetStipple(disp, _gc, b2); \
+      XFillRectangle(disp, _dr, _gc, _a, _b, _c + bl + br, _d + bt + bb);
+
 void
 DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, char firstlast)
 {
    static GC           gc = 0;
-   static Pixmap       b1 = 0, b2 = 0, b3 = 0;
+   static Pixmap       b2 = 0, b3 = 0;
    static Font         font = 0;
    Window              root = VRoot.xwin;
    int                 x1, y1, w1, h1, i, j, dx, dy;
@@ -641,21 +675,20 @@
        break;
      case 1:
      case 2:
+       goto do_non_opaque;
      case 3:
      case 4:
-     case 5:
-       if (firstlast == 0)
-          EwinShapeSet(ewin);
-
-       if (!b1)
-          b1 = XCreateBitmapFromData(disp, root, flipped_gray_bits,
-                                     flipped_gray_width, flipped_gray_height);
        if (!b2)
           b2 = XCreateBitmapFromData(disp, root, gray_bits, gray_width,
                                      gray_height);
        if (!b3)
           b3 = XCreateBitmapFromData(disp, root, gray3_bits, gray3_width,
                                      gray3_height);
+       goto do_non_opaque;
+     case 5:
+      do_non_opaque:
+       if (firstlast == 0)
+          EwinShapeSet(ewin);
 
        if ((Mode.mode == MODE_RESIZE) || (Mode.mode == MODE_RESIZE_H)
            || (Mode.mode == MODE_RESIZE_V))
@@ -702,124 +735,53 @@
             gc = EXCreateGC(root,
                             GCFunction | GCForeground | GCSubwindowMode, &gcv);
          }
-#define DRAW_H_ARROW(x1, x2, y1) \
-      if (((x2) - (x1)) >= 12) \
-        { \
-          XDrawLine(disp, root, gc, (x1), (y1), (x1) + 6, (y1) - 3); \
-          XDrawLine(disp, root, gc, (x1), (y1), (x1) + 6, (y1) + 3); \
-          XDrawLine(disp, root, gc, (x2), (y1), (x2) - 6, (y1) - 3); \
-          XDrawLine(disp, root, gc, (x2), (y1), (x2) - 6, (y1) + 3); \
-        } \
-      if ((x2) >= (x1)) \
-        { \
-          XDrawLine(disp, root, gc, (x1), (y1), (x2), (y1)); \
-          Esnprintf(str, sizeof(str), "%i", (x2) - (x1) + 1); \
-          XDrawString(disp, root, gc, ((x1) + (x2)) / 2, (y1) - 10, str, 
strlen(str)); \
-        }
-#define DRAW_V_ARROW(y1, y2, x1) \
-      if (((y2) - (y1)) >= 12) \
-        { \
-          XDrawLine(disp, root, gc, (x1), (y1), (x1) + 3, (y1) + 6); \
-          XDrawLine(disp, root, gc, (x1), (y1), (x1) - 3, (y1) + 6); \
-          XDrawLine(disp, root, gc, (x1), (y2), (x1) + 3, (y2) - 6); \
-          XDrawLine(disp, root, gc, (x1), (y2), (x1) - 3, (y2) - 6); \
-        } \
-      if ((y2) >= (y1)) \
-        { \
-          XDrawLine(disp, root, gc, (x1), (y1), (x1), (y2)); \
-          Esnprintf(str, sizeof(str), "%i", (y2) - (y1) + 1); \
-          XDrawString(disp, root, gc, (x1) + 10, ((y1) + (y2)) / 2, str, 
strlen(str)); \
-        }
-#define DO_DRAW_MODE_1(_a, _b, _c, _d) \
-      if (!font) \
-        font = XLoadFont(disp, "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*"); \
-      XSetFont(disp, gc, font); \
-      if (_c < 3) _c = 3; \
-      if (_d < 3) _d = 3; \
-      DRAW_H_ARROW(_a + bl, _a + bl + _c - 1, _b + bt + _d - 16); \
-      DRAW_H_ARROW(0, _a - 1, _b + bt + (_d / 2)); \
-      DRAW_H_ARROW(_a + _c + bl + br, VRoot.w - 1, _b + bt + (_d / 2)); \
-      DRAW_V_ARROW(_b + bt, _b + bt + _d - 1, _a + bl + 16); \
-      DRAW_V_ARROW(0, _b - 1, _a + bl + (_c / 2)); \
-      DRAW_V_ARROW(_b + _d + bt + bb, VRoot.h - 1, _a + bl + (_c / 2)); \
-      XDrawLine(disp, root, gc, _a, 0, _a, VRoot.h); \
-      XDrawLine(disp, root, gc, _a + _c + bl + br - 1, 0, _a + _c + bl + br - 
1, VRoot.h); \
-      XDrawLine(disp, root, gc, 0, _b, VRoot.w, _b); \
-      XDrawLine(disp, root, gc, 0, _b + _d + bt + bb - 1, VRoot.w, _b + _d + 
bt + bb - 1); \
-      XDrawRectangle(disp, root, gc, _a + bl + 1, _b + bt + 1, _c - 3, _d - 3);
-
-#define DO_DRAW_MODE_2(_a, _b, _c, _d) \
-      if (_c < 3) _c = 3; \
-      if (_d < 3) _d = 3; \
-      XDrawRectangle(disp, root, gc, _a, _b, _c + bl + br - 1, _d + bt + bb - 
1); \
-      XDrawRectangle(disp, root, gc, _a + bl + 1, _b + bt + 1, _c - 3, _d - 3);
-
-#define DO_DRAW_MODE_3(_a, _b, _c, _d) \
-      XSetFillStyle(disp, gc, FillStippled); \
-      XSetStipple(disp, gc, b2); \
-      if ((_c + bl + br > 0) && (bt > 0)) \
-        XFillRectangle(disp, root, gc, _a, _b, _c + bl + br, bt); \
-      if ((_c + bl + br > 0) && (bb > 0)) \
-        XFillRectangle(disp, root, gc, _a, _b + _d + bt, _c + bl + br, bb); \
-      if ((_d > 0) && (bl > 0)) \
-        XFillRectangle(disp, root, gc, _a, _b + bt, bl, _d); \
-      if ((_d > 0) && (br > 0)) \
-        XFillRectangle(disp, root, gc, _a + _c + bl, _b + bt, br, _d); \
-      XSetStipple(disp, gc, b3); \
-      if ((_c > 0) && (_d > 0)) \
-        XFillRectangle(disp, root, gc, _a + bl + 1, _b + bt + 1, _c - 3, _d - 
3);
-
-#define DO_DRAW_MODE_4(_a, _b, _c, _d) \
-      XSetFillStyle(disp, gc, FillStippled); \
-      XSetStipple(disp, gc, b2); \
-      XFillRectangle(disp, root, gc, _a, _b, _c + bl + br, _d + bt + bb);
 
        if (md == 1)
          {
             if (firstlast > 0)
               {
-                 DO_DRAW_MODE_1(x1, y1, w1, h1);
+                 DO_DRAW_MODE_1(root, gc, x1, y1, w1, h1);
               }
             CoordsShow(ewin);
             if (firstlast < 2)
               {
-                 DO_DRAW_MODE_1(x, y, w, h);
+                 DO_DRAW_MODE_1(root, gc, x, y, w, h);
               }
          }
        else if (md == 2)
          {
             if (firstlast > 0)
               {
-                 DO_DRAW_MODE_2(x1, y1, w1, h1);
+                 DO_DRAW_MODE_2(root, gc, x1, y1, w1, h1);
               }
             CoordsShow(ewin);
             if (firstlast < 2)
               {
-                 DO_DRAW_MODE_2(x, y, w, h);
+                 DO_DRAW_MODE_2(root, gc, x, y, w, h);
               }
          }
        else if (md == 3)
          {
             if (firstlast > 0)
               {
-                 DO_DRAW_MODE_3(x1, y1, w1, h1);
+                 DO_DRAW_MODE_3(root, gc, x1, y1, w1, h1);
               }
             CoordsShow(ewin);
             if (firstlast < 2)
               {
-                 DO_DRAW_MODE_3(x, y, w, h);
+                 DO_DRAW_MODE_3(root, gc, x, y, w, h);
               }
          }
        else if (md == 4)
          {
             if (firstlast > 0)
               {
-                 DO_DRAW_MODE_4(x1, y1, w1, h1);
+                 DO_DRAW_MODE_4(root, gc, x1, y1, w1, h1);
               }
             CoordsShow(ewin);
             if (firstlast < 2)
               {
-                 DO_DRAW_MODE_4(x, y, w, h);
+                 DO_DRAW_MODE_4(root, gc, x, y, w, h);
               }
          }
        else if (md == 5)
@@ -841,9 +803,6 @@
                     EDestroyPixImg(draw_pi);
                  EBlendRemoveShape(NULL, 0, 0, 0);
                  EBlendPixImg(NULL, NULL, NULL, NULL, 0, 0, 0, 0);
-                 ewin_pi = NULL;
-                 root_pi = NULL;
-                 draw_pi = NULL;
                  root_pi = ECreatePixImg(root, VRoot.w, VRoot.h);
                  ewin_pi = ECreatePixImg(root, EoGetW(ewin), EoGetH(ewin));
                  draw_pi = ECreatePixImg(root, EoGetW(ewin), EoGetH(ewin));
@@ -861,7 +820,7 @@
                  XCopyArea(disp, root_pi->pmap, ewin_pi->pmap, gc2, x1, y1,
                            EoGetW(ewin), EoGetH(ewin), 0, 0);
                  EXFreeGC(gc2);
-                 EBlendPixImg(ewin, root_pi, ewin_pi, draw_pi, x, y,
+                 EBlendPixImg(EoGetWin(ewin), root_pi, ewin_pi, draw_pi, x, y,
                               EoGetW(ewin), EoGetH(ewin));
               }
             else if (firstlast == 1)
@@ -898,8 +857,8 @@
                     EFillPixmap(root, root_pi->pmap, x, y, wt, ht);
                  if ((adx <= wt) && (ady <= ht))
                    {
-                      EBlendPixImg(ewin, root_pi, ewin_pi, draw_pi, x, y,
-                                   EoGetW(ewin), EoGetH(ewin));
+                      EBlendPixImg(EoGetWin(ewin), root_pi, ewin_pi, draw_pi,
+                                   x, y, EoGetW(ewin), EoGetH(ewin));
                       if (dx > 0)
                          EPastePixmap(root, root_pi->pmap, x1, y1, dx, ht);
                       else if (dx < 0)
@@ -914,10 +873,10 @@
                  else
                    {
                       EPastePixmap(root, root_pi->pmap, x1, y1, wt, ht);
-                      EBlendPixImg(ewin, root_pi, ewin_pi, draw_pi, x, y,
-                                   EoGetW(ewin), EoGetH(ewin));
+                      EBlendPixImg(EoGetWin(ewin), root_pi, ewin_pi, draw_pi,
+                                   x, y, EoGetW(ewin), EoGetH(ewin));
                    }
-                 EBlendRemoveShape(ewin, root_pi->pmap, x, y);
+                 EBlendRemoveShape(EoGetWin(ewin), root_pi->pmap, x, y);
               }
             else if (firstlast == 2)
               {
@@ -941,7 +900,7 @@
                               EoGetH(ewin));
                  if (root_pi)
                     EDestroyPixImg(root_pi);
-                 root_pi->pmap = 0;
+                 root_pi = NULL;
               }
             else if (firstlast == 4)
               {
@@ -951,14 +910,8 @@
                  ht = EoGetH(ewin);
                  root_pi = ECreatePixImg(root, VRoot.w, VRoot.h);
                  EFillPixmap(root, root_pi->pmap, x, y, wt, ht);
-                 EBlendPixImg(ewin, root_pi, ewin_pi, draw_pi, x, y,
+                 EBlendPixImg(EoGetWin(ewin), root_pi, ewin_pi, draw_pi, x, y,
                               EoGetW(ewin), EoGetH(ewin));
-              }
-            else if (firstlast == 5)
-              {
-                 if (root_pi)
-                    EDestroyPixImg(root_pi);
-                 root_pi->pmap = 0;
               }
             CoordsShow(ewin);
          }



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to