MythTV master
drawmethods.h
Go to the documentation of this file.
1#ifndef DRAWMETHODS_H
2#define DRAWMETHODS_H
3
4#include "goomconfig.h"
5#include "libmythbase/mythconfig.h"
6
7#define DRAWMETHOD_NORMAL(adr,col) {*(adr) = (col);}
8
9#if HAVE_MMX
10#include "mmx.h"
11
12#define DRAWMETHOD_PLUS(_out,_backbuf,_col) \
13{\
14movd_m2r (_backbuf, mm0); \
15paddusb_m2r (_col, mm0); \
16movd_r2m (mm0, _out); \
17}
18
19#else
20#define DRAWMETHOD_PLUS(_out,_backbuf,_col) \
21{\
22 int tra=0,i=0;\
23 unsigned char *bra = (unsigned char*)&(_backbuf);\
24 unsigned char *dra = (unsigned char*)&(_out);\
25 unsigned char *cra = (unsigned char*)&(_col);\
26 for (;i<4;i++) {\
27 tra = *cra;\
28 tra += *bra;\
29 if (tra>255) tra=255;\
30 *dra = tra;\
31 ++dra;++cra;++bra;\
32 }\
33}
34#endif
35
36#define DRAWMETHOD_OR(adr,col) {*(adr)|=(col);}
37
38#if HAVE_MMX
39#define DRAWMETHOD_DONE() {__asm__ __volatile__ ("emms");}
40#else
41#define DRAWMETHOD_DONE() {}
42#endif
43
44#ifndef DRAWMETHOD
45#define DRAWMETHOD DRAWMETHOD_PLUS(*p,*p,col)
46
47static void draw_line (int *data, int x1, int y1, int x2, int y2, int col, int screenx, int screeny) {
48 int x = 0; // am, tmp
49 int y = 0;
50 int dx = 0;
51 int dy = 0;
52 int *p = nullptr;
53
54
55 if ((y1 < 0) || (y2 < 0) || (x1 < 0) || (x2 < 0) || (y1 >= screeny) || (y2 >= screeny) || (x1 >= screenx) || (x2 >= screenx))
56 return;
57
58 dx = x2 - x1;
59 dy = y2 - y1;
60 if (x1 > x2) {
61 int tmp = x1;
62 x1 = x2;
63 x2 = tmp;
64 tmp = y1;
65 y1 = y2;
66 y2 = tmp;
67 dx = x2 - x1;
68 dy = y2 - y1;
69 }
70
71 /* vertical line */
72 if (dx == 0) {
73 if (y1 < y2) {
74 p = &(data[(screenx * y1) + x1]);
75 for (y = y1; y <= y2; y++) {
77 p += screenx;
78 }
79 }
80 else {
81 p = &(data[(screenx * y2) + x1]);
82 for (y = y2; y <= y1; y++) {
84 p += screenx;
85 }
86 }
87 return;
88 }
89 /* horizontal line */
90 if (dy == 0) {
91 if (x1 < x2) {
92 p = &(data[(screenx * y1) + x1]);
93 for (x = x1; x <= x2; x++) {
95 p++;
96 }
97 return;
98 }
99 p = &(data[(screenx * y1) + x2]);
100 for (x = x2; x <= x1; x++) {
102 p++;
103 }
104 return;
105 }
106 /* 1 */
107
108 /* 2 */
109 if (y2 > y1) {
110 /* steep */
111 if (dy > dx) {
112 dx = ((dx << 16) / dy);
113 x = x1 << 16;
114 for (y = y1; y <= y2; y++) {
115 int xx = x >> 16;
116 p = &(data[(screenx * y) + xx]);
118#if 0
119 if (xx < (screenx - 1)) {
120 p++;
121 }
122#endif
123 x += dx;
124 }
125 return;
126 }
127 /* shallow */
128 dy = ((dy << 16) / dx);
129 y = y1 << 16;
130 for (x = x1; x <= x2; x++) {
131 int yy = y >> 16;
132 p = &(data[(screenx * yy) + x]);
134 y += dy;
135 }
136 }
137 /* 2 */
138
139 /* 1 */
140 else {
141 /* steep */
142 if (-dy > dx) {
143 dx = ((dx << 16) / -dy);
144 x = (x1 + 1) << 16;
145 for (y = y1; y >= y2; y--) {
146 int xx = x >> 16;
147 p = &(data[(screenx * y) + xx]);
149#if 0
150 if (xx < (screenx - 1)) {
151 p--;
152 }
153#endif
154 x += dx;
155 }
156 return;
157 }
158 /* shallow */
159 dy = ((dy << 16) / dx);
160 y = y1 << 16;
161 for (x = x1; x <= x2; x++) {
162 int yy = y >> 16;
163 p = &(data[(screenx * yy) + x]);
165 y += dy;
166 }
167 return;
168 }
169}
170#endif
171
172#endif // DRAWMETHODS_H
static void draw_line(int *data, int x1, int y1, int x2, int y2, int col, int screenx, int screeny)
Definition: drawmethods.h:47
#define DRAWMETHOD
Definition: drawmethods.h:45
static uint32_t * tmp
Definition: goom_core.cpp:28
static int x1
Definition: mythsocket.cpp:54
static int x2
Definition: mythsocket.cpp:55