2 ===================================================================
3 --- src/odk_osd.c (Revision 3677)
4 +++ src/odk_osd.c (Arbeitskopie)
6 #include "odk_private.h"
11 -#define VALIDATE_POINT(x,y) { \
13 - || (x >= odk->osd.width)) { \
14 - fatal ("x-value is outside " \
15 - "the valid drawing " \
16 - "area: 0 <= %d <= %d", \
17 - x, odk->osd.width); \
19 - assert (x < odk->osd.width); \
22 - || (y >= odk->osd.height)) { \
23 - fatal ("y-value is outside " \
24 - "the valid drawing " \
25 - "area: 0 <= %d <= %d", \
26 - y, odk->osd.height); \
28 - assert (y < odk->osd.height); \
30 +#define VALIDATE_POINT(x,y) { \
31 + if (((x) < 0) || ((x) >= odk->osd.width)) { \
32 + debug ("x-value is outside " \
33 + "the valid drawing " \
34 + "area: 0 <= %d < %d", \
35 + x, odk->osd.width); \
38 + if (((y) < 0) || ((y) >= odk->osd.height)) {\
39 + debug ("y-value is outside " \
40 + "the valid drawing " \
41 + "area: 0 <= %d < %d", \
42 + y, odk->osd.height); \
47 -#define VALIDATE_POINT(x,y) { \
49 - || (x >= odk->osd.width)) { \
53 - || (y >= odk->osd.height)) { \
59 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
61 @@ -1294,11 +1276,11 @@
62 case OSD_VECTOR_ARROW_DOWN:
66 + int y1 = y + (h / 2);
69 + int y2 = y + (h / 2);
71 - int y3 = y + (h / 2);
73 odk_draw_triangle (odk, x1, y1, x2, y2, x3, y3, color, true);
76 @@ -1438,24 +1420,26 @@
88 swap_points (point_t * p1, point_t * p2)
102 -line_draw (odk_t * odk, int minx, int miny, int maxx, int maxy, point_t * p1,
103 - point_t * p2, int color)
104 +line_draw (odk_t * odk, int minx, int miny, int maxx, int maxy,
105 + point_t * p1, point_t * p2, int color)
109 @@ -1488,7 +1472,9 @@
110 if (!(odk->osd.hscale && odk->osd.vscale))
114 + /* This is necessary for this code to work in some versions of gcc. I have
115 + * no idea why this is the case though... */
116 + volatile point_t p[3];
118 p[0].x = round ((double) x1 * odk->osd.hscale);
119 p[0].y = round ((double) y1 * odk->osd.vscale);
120 @@ -1502,47 +1488,55 @@
123 if (p[i].y > p[j].y) {
124 - swap_points (&p[i], &p[j]);
125 + swap_points ((point_t *) & p[i], (point_t *) & p[j]);
127 - else if ((p[i].y == p[j].y)
128 - && (p[i].x > p[j].x)) {
129 - swap_points (&p[i], &p[j]);
130 + else if ((p[i].y == p[j].y) && (p[i].x > p[j].x)) {
131 + swap_points ((point_t *) & p[i], (point_t *) & p[j]);
137 assert (p[0].y <= p[1].y);
138 assert (p[1].y <= p[2].y);
141 int minx = odk->osd.width;
143 int miny = odk->osd.height;
145 for (i = 0; i < 3; i++) {
147 + if (p[i].x < minx) {
151 + if (p[i].x > maxx) {
155 + if (p[i].y < miny) {
159 + if (p[i].y > maxy) {
165 - point_t *A = &p[0];
166 - point_t *B = &p[1];
167 - point_t *C = &p[2];
168 + point_t *A = (point_t *) & p[0];
169 + point_t *B = (point_t *) & p[1];
170 + point_t *C = (point_t *) & p[2];
173 - if (B->y - A->y > 0)
175 + if (B->y - A->y > 0) {
176 dx1 = (B->x - A->x) / (B->y - A->y);
178 - if (C->y - A->y > 0)
181 + if (C->y - A->y > 0) {
182 dx2 = (C->x - A->x) / (C->y - A->y);
184 - if (C->y - B->y > 0)
187 + if (C->y - B->y > 0) {
188 dx3 = (C->x - B->x) / (C->y - B->y);
193 @@ -1553,20 +1547,24 @@
197 - for (; S->y <= B->y; S->y++, E->y++, S->x += dx2, E->x += dx1)
198 + for (; S->y <= B->y; S->y++, E->y++, S->x += dx2, E->x += dx1) {
199 line_draw (odk, minx, miny, maxx, maxy, S, E, color);
203 - for (; S->y <= C->y; S->y++, E->y++, S->x += dx2, E->x += dx3)
204 + for (; S->y <= C->y; S->y++, E->y++, S->x += dx2, E->x += dx3) {
205 line_draw (odk, minx, miny, maxx, maxy, S, E, color);
209 - for (; S->y <= B->y; S->y++, E->y++, S->x += dx1, E->x += dx2)
210 + for (; S->y <= B->y; S->y++, E->y++, S->x += dx1, E->x += dx2) {
211 line_draw (odk, minx, miny, maxx, maxy, S, E, color);
215 - for (; S->y <= C->y; S->y++, E->y++, S->x += dx3, E->x += dx2)
216 + for (; S->y <= C->y; S->y++, E->y++, S->x += dx3, E->x += dx2) {
217 line_draw (odk, minx, miny, maxx, maxy, S, E, color);