updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / oxine-vdr / oxine_0.7.1_triangle.patch
blobb9576d71c5cc8c6327e513df1bb5522599a945b5
1 Index: src/odk_osd.c
2 ===================================================================
3 --- src/odk_osd.c (Revision 3677)
4 +++ src/odk_osd.c (Arbeitskopie)
5 @@ -57,40 +57,22 @@
6 #include "odk_private.h"
7 #include "utils.h"
10 -#ifdef DEBUG
11 -#define VALIDATE_POINT(x,y) { \
12 - if ((x < 0) \
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); \
18 - assert (x >= 0); \
19 - assert (x < odk->osd.width); \
20 - } \
21 - if ((y < 0) \
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); \
27 - assert (y >= 0); \
28 - assert (y < odk->osd.height); \
29 - } \
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); \
36 + return; \
37 + } \
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); \
43 + return; \
44 + } \
46 -#else
47 -#define VALIDATE_POINT(x,y) { \
48 - if ((x < 0) \
49 - || (x >= odk->osd.width)) { \
50 - return; \
51 - } \
52 - if ((y < 0) \
53 - || (y >= odk->osd.height)) { \
54 - return; \
55 - } \
57 -#endif
59 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
61 @@ -1294,11 +1276,11 @@
62 case OSD_VECTOR_ARROW_DOWN:
64 int x1 = x;
65 - int y1 = y;
66 + int y1 = y + (h / 2);
67 int x2 = x + w;
68 - int y2 = y;
69 + int y2 = y + (h / 2);
70 int x3 = x + (w / 2);
71 - int y3 = y + (h / 2);
72 + int y3 = y + h;
73 odk_draw_triangle (odk, x1, y1, x2, y2, x3, y3, color, true);
76 @@ -1438,24 +1420,26 @@
79 typedef struct {
80 - double x;
81 - double y;
82 + int x;
83 + int y;
84 } point_t;
87 static void
88 swap_points (point_t * p1, point_t * p2)
90 - double x = p1->x;
91 - double y = p1->y;
92 + int x = p1->x;
93 + int y = p1->y;
94 p1->x = p2->x;
95 p1->y = p2->y;
96 p2->x = x;
97 p2->y = y;
101 static void
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)
107 if (p1->x > maxx)
108 p1->x = maxx;
109 @@ -1488,7 +1472,9 @@
110 if (!(odk->osd.hscale && odk->osd.vscale))
111 return;
113 - point_t p[3];
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 @@
121 int j = i;
122 for (; j < 3; j++) {
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]);
136 +#ifdef DEBUG
137 assert (p[0].y <= p[1].y);
138 assert (p[1].y <= p[2].y);
139 +#endif
141 int minx = odk->osd.width;
142 int maxx = 0;
143 int miny = odk->osd.height;
144 int maxy = 0;
145 for (i = 0; i < 3; i++) {
146 - if (p[i].x < minx)
147 + if (p[i].x < minx) {
148 minx = p[i].x;
149 - if (p[i].x > maxx)
151 + if (p[i].x > maxx) {
152 maxx = p[i].x;
153 - if (p[i].y < miny)
155 + if (p[i].y < miny) {
156 miny = p[i].y;
157 - if (p[i].y > maxy)
159 + if (p[i].y > maxy) {
160 maxy = p[i].y;
164 if (filled) {
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];
172 - double dx1 = 0;
173 - if (B->y - A->y > 0)
174 + int dx1 = 0;
175 + if (B->y - A->y > 0) {
176 dx1 = (B->x - A->x) / (B->y - A->y);
177 - double dx2 = 0;
178 - if (C->y - A->y > 0)
180 + int dx2 = 0;
181 + if (C->y - A->y > 0) {
182 dx2 = (C->x - A->x) / (C->y - A->y);
183 - double dx3 = 0;
184 - if (C->y - B->y > 0)
186 + int dx3 = 0;
187 + if (C->y - B->y > 0) {
188 dx3 = (C->x - B->x) / (C->y - B->y);
191 point_t s;
192 point_t *S = &s;
193 @@ -1553,20 +1547,24 @@
194 E->x = A->x;
195 E->y = A->y;
196 if (dx1 > dx2) {
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);
201 E->x = B->x;
202 E->y = B->y;
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);
208 else {
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);
213 S->x = B->x;
214 S->y = B->y;
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);