move around - flatter.
[profile/ivi/evas.git] / src / lib / canvas / evas_rectangle.c
1 #include "evas_common.h"
2 #include "evas_private.h"
3
4 void
5 evas_rects_return_difference_rects(Evas_Rectangles *rects, int x, int y, int w, int h, int xx, int yy, int ww, int hh)
6 {
7    unsigned int available = 0;
8
9    if (!RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh))
10      {
11         evas_add_rect(rects, x, y, w, h);
12         evas_add_rect(rects, xx, yy, ww, hh);
13      }
14    else
15      {
16         int x1[4], y1[4], i, j;
17         Evas_Rectangles tmp = { 0, 0, NULL };
18
19         if (x < xx)
20           {
21              x1[0] = x;
22              x1[1] = xx;
23           }
24         else
25           {
26              x1[0] = xx;
27              x1[1] = x;
28           }
29         if ((x + w) < (xx + ww))
30           {
31              x1[2] = x + w;
32              x1[3] = xx + ww;
33           }
34         else
35           {
36              x1[2] = xx + ww;
37              x1[3] = x + w;
38           }
39         if (y < yy)
40           {
41              y1[0] = y;
42              y1[1] = yy;
43           }
44         else
45           {
46              y1[0] = yy;
47              y1[1] = y;
48           }
49         if ((y + h) < (yy + hh))
50           {
51              y1[2] = y + h;
52              y1[3] = yy + hh;
53           }
54         else
55           {
56              y1[2] = yy + hh;
57              y1[3] = y + h;
58           }
59         for (j = 0; j < 3; j++)
60           {
61              for (i = 0; i < 3; i++)
62                {
63                   int intsec1, intsec2;
64                   int tx, ty, tw, th;
65
66                   tx = x1[i];
67                   ty = y1[j];
68                   tw = x1[i + 1] - x1[i];
69                   th = y1[j + 1] - y1[j];
70
71                   intsec1 = (RECTS_INTERSECT(tx, ty, tw, th, x, y, w, h));
72                   intsec2 = (RECTS_INTERSECT(tx, ty, tw, th, xx, yy, ww, hh));
73                   if (intsec1 ^ intsec2)
74                     {
75                        evas_add_rect(rects, tx, ty, tw, th);
76                     }
77                }
78           }
79 /*      if (tmp.count > 0) */
80 /*        { */
81 /*           unsigned int i; */
82
83 /*           for (i = 0; i < tmp.count; ++i) */
84 /*             { */
85 /*                if ((tmp.array[i].w > 0) && (tmp.array[i].h > 0)) */
86 /*                  { */
87 /*                     int intsec1, intsec2; */
88
89 /*                     intsec1 = (RECTS_INTERSECT(tmp.array[i].x, tmp.array[i].y, tmp.array[i].w, tmp.array[i].h, x, y, w, h)); */
90 /*                     intsec2 = (RECTS_INTERSECT(tmp.array[i].x, tmp.array[i].y, tmp.array[i].w, tmp.array[i].h, xx, yy, ww, hh)); */
91 /*                     if (intsec1 ^ intsec2) */
92 /*                       { */
93 /*                          evas_add_rect(rects, tmp.array[i].x, tmp.array[i].y, tmp.array[i].w, tmp.array[i].h); */
94 /*                       } */
95 /*                  } */
96 /*             } */
97 /*           free(tmp.array); */
98 /*        } */
99
100      }
101 }