Rev 882 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 882 | Rev 1002 | ||
---|---|---|---|
1 | #include |
1 | #include |
2 | 2 | ||
3 | 3 | ||
4 | static void HLine(char *addr,int width, color_t color) |
4 | static void HLine(char *addr,int width, color_t color) |
5 | { |
5 | { |
6 | __m64 dst_color; |
6 | __m64 dst_color; |
7 | 7 | ||
8 | dst_color = _mm_cvtsi32_si64(color); |
8 | dst_color = _mm_cvtsi32_si64(color); |
9 | dst_color = _mm_unpacklo_pi32(dst_color, dst_color); |
9 | dst_color = _mm_unpacklo_pi32(dst_color, dst_color); |
10 | 10 | ||
11 | while (width >= 8) |
11 | while (width >= 8) |
12 | { |
12 | { |
13 | __asm__ __volatile__ ( |
13 | __asm__ __volatile__ ( |
14 | "movq %[clr], (%0)\n\t" |
14 | "movq %[clr], (%0)\n\t" |
15 | "movq %[clr], 8(%0)\n\t" |
15 | "movq %[clr], 8(%0)\n\t" |
16 | "movq %[clr], 16(%0)\n\t" |
16 | "movq %[clr], 16(%0)\n\t" |
17 | "movq %[clr], 24(%0)\n\t" |
17 | "movq %[clr], 24(%0)\n\t" |
18 | :: "r" (addr), [clr] "y" (dst_color)); |
18 | :: "r" (addr), [clr] "y" (dst_color)); |
19 | addr += 32; |
19 | addr += 32; |
20 | width -= 8; |
20 | width -= 8; |
21 | } |
21 | } |
22 | if (width >= 4) |
22 | if (width >= 4) |
23 | { |
23 | { |
24 | __asm__ __volatile__ ( |
24 | __asm__ __volatile__ ( |
25 | "movq %[clr], (%0)\n\t" |
25 | "movq %[clr], (%0)\n\t" |
26 | "movq %[clr], 8(%0)\n\t" |
26 | "movq %[clr], 8(%0)\n\t" |
27 | :: "r" (addr), [clr] "y" (dst_color)); |
27 | :: "r" (addr), [clr] "y" (dst_color)); |
28 | addr += 16; |
28 | addr += 16; |
29 | width -= 4; |
29 | width -= 4; |
30 | } |
30 | } |
31 | if (width >= 2) |
31 | if (width >= 2) |
32 | { |
32 | { |
33 | __asm__ __volatile__ ( |
33 | __asm__ __volatile__ ( |
34 | "movq %[clr], (%0)\n\t" |
34 | "movq %[clr], (%0)\n\t" |
35 | :: "r" (addr), [clr] "y" (dst_color)); |
35 | :: "r" (addr), [clr] "y" (dst_color)); |
36 | addr += 8; |
36 | addr += 8; |
37 | width -= 2; |
37 | width -= 2; |
38 | } |
38 | } |
39 | if ( width ) |
39 | if ( width ) |
40 | __asm__ __volatile__ ( |
40 | __asm__ __volatile__ ( |
41 | "movd %[clr], (%0)\n\t" |
41 | "movd %[clr], (%0)\n\t" |
42 | :: "r" (addr), [clr] "y" (dst_color)); |
42 | :: "r" (addr), [clr] "y" (dst_color)); |
43 | 43 | ||
44 | _mm_empty(); |
44 | _mm_empty(); |
45 | } |
45 | } |
46 | 46 | ||
47 | static void pxDraw(char *dst_addr, int pitch, int w, int h, color_t dst_color) |
47 | static void pxDraw(char *dst_addr, int pitch, int w, int h, color_t dst_color) |
48 | { |
48 | { |
49 | __m64 color; |
49 | __m64 color; |
50 | 50 | ||
51 | color = _mm_cvtsi32_si64(dst_color); |
51 | color = _mm_cvtsi32_si64(dst_color); |
52 | color = _mm_unpacklo_pi32(color, color); |
52 | color = _mm_unpacklo_pi32(color, color); |
53 | 53 | ||
54 | while(h--) |
54 | while(h--) |
55 | { |
55 | { |
56 | char *tmp_dst =dst_addr; |
56 | char *tmp_dst =dst_addr; |
57 | int width = w; |
57 | int width = w; |
58 | dst_addr += pitch; |
58 | dst_addr += pitch; |
59 | 59 | ||
60 | while(width >= 8) |
60 | while(width >= 8) |
61 | { |
61 | { |
62 | __asm__ __volatile__ |
62 | __asm__ __volatile__ |
63 | ("movq %[clr], (%0)\n\t" |
63 | ("movq %[clr], (%0)\n\t" |
64 | "movq %[clr], 8(%0)\n\t" |
64 | "movq %[clr], 8(%0)\n\t" |
65 | "movq %[clr], 16(%0)\n\t" |
65 | "movq %[clr], 16(%0)\n\t" |
66 | "movq %[clr], 24(%0)\n\t" |
66 | "movq %[clr], 24(%0)\n\t" |
67 | :: "r" (tmp_dst), [clr] "y" (color)); |
67 | :: "r" (tmp_dst), [clr] "y" (color)); |
68 | tmp_dst += 32; |
68 | tmp_dst += 32; |
69 | width -= 8; |
69 | width -= 8; |
70 | }; |
70 | }; |
71 | if(width >= 4) |
71 | if(width >= 4) |
72 | { |
72 | { |
73 | __asm__ __volatile__ |
73 | __asm__ __volatile__ |
74 | ("movq %[clr], (%0)\n\t" |
74 | ("movq %[clr], (%0)\n\t" |
75 | "movq %[clr], 8(%0)\n\t" |
75 | "movq %[clr], 8(%0)\n\t" |
76 | :: "r" (tmp_dst), [clr] "y" (color)); |
76 | :: "r" (tmp_dst), [clr] "y" (color)); |
77 | tmp_dst += 16; |
77 | tmp_dst += 16; |
78 | width -= 4; |
78 | width -= 4; |
79 | }; |
79 | }; |
80 | 80 | ||
81 | if (width >= 2) |
81 | if (width >= 2) |
82 | { |
82 | { |
83 | __asm__ __volatile__ |
83 | __asm__ __volatile__ |
84 | ("movq %[clr], (%0)\n\t" |
84 | ("movq %[clr], (%0)\n\t" |
85 | :: "r" (tmp_dst), [clr] "y" (color)); |
85 | :: "r" (tmp_dst), [clr] "y" (color)); |
86 | tmp_dst += 8; |
86 | tmp_dst += 8; |
87 | width -= 2; |
87 | width -= 2; |
88 | }; |
88 | }; |
89 | if(width) |
89 | if(width) |
90 | __asm__ __volatile__ |
90 | __asm__ __volatile__ |
91 | ("movd %[clr], (%0)\n\t" |
91 | ("movd %[clr], (%0)\n\t" |
92 | :: "r" (tmp_dst), [clr] "y" (color)); |
92 | :: "r" (tmp_dst), [clr] "y" (color)); |
93 | }; |
93 | }; |
94 | _mm_empty(); |
94 | _mm_empty(); |
95 | }; |
95 | }; |
96 | 96 | ||
97 | int ClearPixmap(pixmap_t *pixmap, color_t color) |
97 | int ClearPixmap(pixmap_t *pixmap, color_t color) |
98 | { |
98 | { |
99 | if( (srv_hw2d != 0) && |
99 | if( (srv_hw2d != 0) && |
100 | ( ((int)pixmap == -1) || |
100 | ( ((int)pixmap == -1) || |
101 | ( (pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
101 | ( (pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
102 | { |
102 | { |
103 | ioctl_t io; |
103 | ioctl_t io; |
104 | 104 | ||
105 | if((int)pixmap != -1) |
105 | if((int)pixmap != -1) |
106 | pixmap = (pixmap_t*)pixmap->handle; |
106 | pixmap = (pixmap_t*)pixmap->handle; |
107 | 107 | ||
108 | io.handle = srv_hw2d; |
108 | io.handle = srv_hw2d; |
109 | io.io_code = PX_CLEAR; |
109 | io.io_code = PX_CLEAR; |
110 | io.input = &pixmap; |
110 | io.input = &pixmap; |
111 | io.inp_size = 2; |
111 | io.inp_size = 2; |
112 | io.output = NULL; |
112 | io.output = NULL; |
113 | io.out_size = 0; |
113 | io.out_size = 0; |
114 | 114 | ||
115 | return call_service(&io); |
115 | return call_service(&io); |
116 | } |
116 | } |
117 | 117 | ||
118 | pixmap = (pixmap == (void*)-1) ? &scrn_pixmap : pixmap ; |
118 | pixmap = (pixmap == (void*)-1) ? &scrn_pixmap : pixmap ; |
119 | 119 | ||
120 | pxDraw(pixmap->mapped, pixmap->pitch, |
120 | pxDraw(pixmap->mapped, pixmap->pitch, |
121 | pixmap->width, pixmap->height, color); |
121 | pixmap->width, pixmap->height, color); |
122 | return ERR_OK; |
122 | return ERR_OK; |
123 | }; |
123 | }; |
124 | 124 | ||
125 | int Line(pixmap_t *pixmap, int x0, int y0, int x1, int y1, color_t color) |
125 | int Line(pixmap_t *pixmap, int x0, int y0, int x1, int y1, color_t color) |
126 | { |
126 | { |
127 | 127 | ||
128 | clip_t clip; |
128 | clip_t clip; |
129 | 129 | ||
130 | if( (srv_hw2d != 0) && |
130 | if( (srv_hw2d != 0) && |
131 | ( (pixmap == (void*)-1) || |
131 | ( (pixmap == (void*)-1) || |
132 | ( (pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
132 | ( (pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
133 | { |
133 | { |
134 | ioctl_t io; |
134 | ioctl_t io; |
135 | 135 | ||
136 | if((int)pixmap != -1) |
136 | if((int)pixmap != -1) |
137 | pixmap = (pixmap_t*)pixmap->handle; |
137 | pixmap = (pixmap_t*)pixmap->handle; |
138 | 138 | ||
139 | io.handle = srv_hw2d; |
139 | io.handle = srv_hw2d; |
140 | io.io_code = PX_LINE; |
140 | io.io_code = PX_LINE; |
141 | io.input = &pixmap; |
141 | io.input = &pixmap; |
142 | io.inp_size = 6; |
142 | io.inp_size = 6; |
143 | io.output = NULL; |
143 | io.output = NULL; |
144 | io.out_size = 0; |
144 | io.out_size = 0; |
145 | 145 | ||
146 | return call_service(&io); |
146 | return call_service(&io); |
147 | } |
147 | } |
148 | 148 | ||
149 | pixmap = (pixmap == (void*)-1) ? &scrn_pixmap : pixmap ; |
149 | pixmap = (pixmap == (void*)-1) ? &scrn_pixmap : pixmap ; |
150 | 150 | ||
151 | clip.xmin = 0; |
151 | clip.xmin = 0; |
152 | clip.ymin = 0; |
152 | clip.ymin = 0; |
153 | clip.xmax = pixmap->width-1; |
153 | clip.xmax = pixmap->width-1; |
154 | clip.ymax = pixmap->height-1; |
154 | clip.ymax = pixmap->height-1; |
155 | 155 | ||
156 | if ( !LineClip( &clip, &x0, &y0, &x1, &y1 )) |
156 | if ( !LineClip( &clip, &x0, &y0, &x1, &y1 )) |
157 | { |
157 | { |
158 | int dx, dy; |
158 | int dx, dy; |
159 | int sx, sy; |
159 | int sx, sy; |
160 | int e, e1, e2, e3; |
160 | int e, e1, e2, e3; |
161 | 161 | ||
162 | char *addr; |
162 | char *addr; |
163 | 163 | ||
164 | dx = x1 - x0; |
164 | dx = x1 - x0; |
165 | dy = y1 - y0; |
165 | dy = y1 - y0; |
166 | 166 | ||
167 | if( dx || dy) |
167 | if( dx || dy) |
168 | { |
168 | { |
169 | if( dy == 0 ) |
169 | if( dy == 0 ) |
170 | { |
170 | { |
171 | if (dx < 0) |
171 | if (dx < 0) |
172 | { |
172 | { |
173 | dx = -dx; |
173 | dx = -dx; |
174 | x0 = x1; |
174 | x0 = x1; |
175 | }; |
175 | }; |
176 | 176 | ||
177 | addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
177 | addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
178 | HLine(addr, dx, color); |
178 | HLine(addr, dx, color); |
179 | 179 | ||
180 | return ERR_OK; |
180 | return ERR_OK; |
181 | }; |
181 | }; |
182 | if( dx == 0 ) |
182 | if( dx == 0 ) |
183 | { |
183 | { |
184 | if (dy < 0) |
184 | if (dy < 0) |
185 | { |
185 | { |
186 | dy = -dy; |
186 | dy = -dy; |
187 | y0 = y1; |
187 | y0 = y1; |
188 | }; |
188 | }; |
189 | addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
189 | addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
190 | 190 | ||
191 | while ( dy-- ) |
191 | while ( dy-- ) |
192 | { |
192 | { |
193 | *(color_t*)addr = color; |
193 | *(color_t*)addr = color; |
194 | addr += pixmap->pitch; |
194 | addr += pixmap->pitch; |
195 | } |
195 | } |
196 | return ERR_OK; |
196 | return ERR_OK; |
197 | } |
197 | } |
198 | 198 | ||
199 | sx = 4; |
199 | sx = 4; |
200 | if ( dx < 0 ) |
200 | if ( dx < 0 ) |
201 | { |
201 | { |
202 | dx = -dx; |
202 | dx = -dx; |
203 | sx = -sx; |
203 | sx = -sx; |
204 | } |
204 | } |
205 | sy = pixmap->pitch; |
205 | sy = pixmap->pitch; |
206 | if ( dy < 0 ) |
206 | if ( dy < 0 ) |
207 | { |
207 | { |
208 | dy = -dy; |
208 | dy = -dy; |
209 | sy = -sy; |
209 | sy = -sy; |
210 | }; |
210 | }; |
211 | 211 | ||
212 | addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
212 | addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
213 | 213 | ||
214 | if (dx > dy) |
214 | if (dx > dy) |
215 | { |
215 | { |
216 | e1 = dy << 1; |
216 | e1 = dy << 1; |
217 | e2 = e1 - (dx << 1); |
217 | e2 = e1 - (dx << 1); |
218 | e = e1 - dx; |
218 | e = e1 - dx; |
219 | 219 | ||
220 | e3 = e2 - e1; |
220 | e3 = e2 - e1; |
221 | e = e - e1; |
221 | e = e - e1; |
222 | 222 | ||
223 | 223 | ||
224 | while (dx--) |
224 | while (dx--) |
225 | { |
225 | { |
226 | *(color_t*)addr = color; |
226 | *(color_t*)addr = color; |
227 | addr += sx; |
227 | addr += sx; |
228 | e += e1; |
228 | e += e1; |
229 | if (e >= 0) |
229 | if (e >= 0) |
230 | { |
230 | { |
231 | addr += sy; |
231 | addr += sy; |
232 | e += e3; |
232 | e += e3; |
233 | } |
233 | } |
234 | } |
234 | } |
235 | } |
235 | } |
236 | else |
236 | else |
237 | { |
237 | { |
238 | e1 = dx << 1; |
238 | e1 = dx << 1; |
239 | e2 = e1 - (dy << 1); |
239 | e2 = e1 - (dy << 1); |
240 | e = e1 - dy; |
240 | e = e1 - dy; |
241 | e3 = e2 - e1; |
241 | e3 = e2 - e1; |
242 | e = e - e1; |
242 | e = e - e1; |
243 | 243 | ||
244 | while (dy--) |
244 | while (dy--) |
245 | { |
245 | { |
246 | *(color_t*)addr = color; |
246 | *(color_t*)addr = color; |
247 | addr += sy; |
247 | addr += sy; |
248 | e += e1; |
248 | e += e1; |
249 | if (e >= 0) |
249 | if (e >= 0) |
250 | { |
250 | { |
251 | addr += sx; |
251 | addr += sx; |
252 | e += e3; |
252 | e += e3; |
253 | } |
253 | } |
254 | } |
254 | } |
255 | } |
255 | } |
256 | } /* ( dx || dy ) */ |
256 | } /* ( dx || dy ) */ |
257 | } |
257 | } |
258 | return ERR_OK; |
258 | return ERR_OK; |
259 | } |
259 | } |
260 | 260 | ||
261 | int DrawRect(pixmap_t *pixmap, int xorg, int yorg, |
261 | int DrawRect(pixmap_t *pixmap, int xorg, int yorg, |
262 | int width, int height, |
262 | int width, int height, |
263 | color_t dst_color, color_t border) |
263 | color_t dst_color, color_t border) |
264 | { |
264 | { |
265 | 265 | ||
266 | if( ( width <= 0 ) || ( height<=0 ) ) |
266 | if( ( width <= 0 ) || ( height<=0 ) ) |
267 | return ERR_PARAM; |
267 | return ERR_PARAM; |
268 | 268 | ||
269 | /* if "hardware acceleration present" and |
269 | /* if "hardware acceleration present" and |
270 | "destinastion is primary screen or local videomemory" |
270 | "destinastion is primary screen or local videomemory" |
271 | */ |
271 | */ |
272 | 272 | ||
273 | if( (srv_hw2d != 0) && |
273 | if( (srv_hw2d != 0) && |
274 | ( (pixmap == (void*)-1) || |
274 | ( (pixmap == (void*)-1) || |
275 | ( (pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
275 | ( (pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
276 | { |
276 | { |
277 | ioctl_t io; |
277 | ioctl_t io; |
278 | 278 | ||
279 | if((int)pixmap != -1) |
279 | if((int)pixmap != -1) |
280 | pixmap = (pixmap_t*)pixmap->handle; |
280 | pixmap = (pixmap_t*)pixmap->handle; |
281 | 281 | ||
282 | io.handle = srv_hw2d; |
282 | io.handle = srv_hw2d; |
283 | io.io_code = PX_DRAW_RECT; |
283 | io.io_code = PX_DRAW_RECT; |
284 | io.input = &pixmap; |
284 | io.input = &pixmap; |
285 | io.inp_size = 7; |
285 | io.inp_size = 7; |
286 | io.output = NULL; |
286 | io.output = NULL; |
287 | io.out_size = 0; |
287 | io.out_size = 0; |
288 | 288 | ||
289 | return call_service(&io); |
289 | return call_service(&io); |
290 | } |
290 | } |
291 | else |
291 | else |
292 | /* no acceleration or destination in system memory */ |
292 | /* no acceleration or destination in system memory */ |
293 | { |
293 | { |
294 | clip_t clip; |
294 | clip_t clip; |
295 | int x0, y0, x1, y1, xend, yend; |
295 | int x0, y0, x1, y1, xend, yend; |
296 | 296 | ||
297 | pixmap = (pixmap == (void*)-1) ? &scrn_pixmap : pixmap ; |
297 | pixmap = (pixmap == (void*)-1) ? &scrn_pixmap : pixmap ; |
298 | 298 | ||
299 | x0 = xorg; |
299 | x0 = xorg; |
300 | y0 = yorg; |
300 | y0 = yorg; |
301 | 301 | ||
302 | xend = x1 = x0 + width - 1; |
302 | xend = x1 = x0 + width - 1; |
303 | yend = y1 = y0 + height - 1; |
303 | yend = y1 = y0 + height - 1; |
304 | 304 | ||
305 | clip.xmin = 0; |
305 | clip.xmin = 0; |
306 | clip.ymin = 0; |
306 | clip.ymin = 0; |
307 | clip.xmax = pixmap->width-1; |
307 | clip.xmax = pixmap->width-1; |
308 | clip.ymax = pixmap->height-1; |
308 | clip.ymax = pixmap->height-1; |
309 | 309 | ||
310 | if( ! BlockClip( &clip, &x0, &y0, &x1, &y1)) |
310 | if( ! BlockClip( &clip, &x0, &y0, &x1, &y1)) |
311 | { |
311 | { |
312 | int w, h; |
312 | int w, h; |
313 | 313 | ||
314 | char *dst_addr; |
314 | char *dst_addr; |
315 | 315 | ||
316 | w = x1 - x0 + 1; |
316 | w = x1 - x0 + 1; |
317 | h = y1 - y0 + 1; |
317 | h = y1 - y0 + 1; |
318 | 318 | ||
319 | if( (dst_color == border) || |
319 | if( (dst_color == border) || |
320 | ((border & 0xFF000000)==0)) |
320 | ((border & 0xFF000000)==0)) |
321 | { |
321 | { |
322 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
322 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
323 | pxDraw(dst_addr, pixmap->pitch, w, h, dst_color); |
323 | pxDraw(dst_addr, pixmap->pitch, w, h, dst_color); |
324 | } |
324 | } |
325 | else |
325 | else |
326 | { |
326 | { |
327 | if( y0 == yorg) |
327 | if( y0 == yorg) |
328 | { |
328 | { |
329 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
329 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
330 | HLine(dst_addr, w, border); |
330 | HLine(dst_addr, w, border); |
331 | y0++; |
331 | y0++; |
332 | h--; |
332 | h--; |
333 | } |
333 | } |
334 | if( y1 == yend ) |
334 | if( y1 == yend ) |
335 | { |
335 | { |
336 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y1 + x0*4]; |
336 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y1 + x0*4]; |
337 | HLine(dst_addr, w, border); |
337 | HLine(dst_addr, w, border); |
338 | h--; |
338 | h--; |
339 | } |
339 | } |
340 | if( (h > 0) && (x0 == xorg)) |
340 | if( (h > 0) && (x0 == xorg)) |
341 | { |
341 | { |
342 | int dy = h; |
342 | int dy = h; |
343 | 343 | ||
344 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
344 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
345 | 345 | ||
346 | while ( dy-- ) |
346 | while ( dy-- ) |
347 | { |
347 | { |
348 | *(color_t*)dst_addr = border; |
348 | *(color_t*)dst_addr = border; |
349 | dst_addr += pixmap->pitch; |
349 | dst_addr += pixmap->pitch; |
350 | } |
350 | } |
351 | x0++; |
351 | x0++; |
352 | w--; |
352 | w--; |
353 | } |
353 | } |
354 | if( (h > 0) && (x1 == xend)) |
354 | if( (h > 0) && (x1 == xend)) |
355 | { |
355 | { |
356 | int dy = h; |
356 | int dy = h; |
357 | 357 | ||
358 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x1*4]; |
358 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x1*4]; |
359 | 359 | ||
360 | while ( dy-- ) |
360 | while ( dy-- ) |
361 | { |
361 | { |
362 | *(color_t*)dst_addr = border; |
362 | *(color_t*)dst_addr = border; |
363 | dst_addr += pixmap->pitch; |
363 | dst_addr += pixmap->pitch; |
364 | } |
364 | } |
365 | w--; |
365 | w--; |
366 | } |
366 | } |
367 | if( (w > 0) && (h > 0) ) |
367 | if( (w > 0) && (h > 0) ) |
368 | { |
368 | { |
369 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
369 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
370 | pxDraw(dst_addr, pixmap->pitch, w, h, dst_color); |
370 | pxDraw(dst_addr, pixmap->pitch, w, h, dst_color); |
371 | } |
371 | } |
372 | } |
372 | } |
373 | }; |
373 | }; |
374 | }; |
374 | }; |
375 | return ERR_OK; |
375 | return ERR_OK; |
376 | }; |
376 | }; |
377 | 377 | ||
378 | int FillRect(pixmap_t *pixmap, int xorg, int yorg, |
378 | int FillRect(pixmap_t *pixmap, int xorg, int yorg, |
379 | int width, int height, |
379 | int width, int height, |
380 | brush_t *dst_brush, color_t border) |
380 | brush_t *dst_brush, color_t border) |
381 | { |
381 | { |
382 | if( ( width <= 0 ) || ( height<=0 ) ) |
382 | if( ( width <= 0 ) || ( height<=0 ) ) |
383 | return ERR_PARAM; |
383 | return ERR_PARAM; |
384 | 384 | ||
385 | /* if "hardware acceleration present" and |
385 | /* if "hardware acceleration present" and |
386 | "destinastion is primary screen or local videomemory" |
386 | "destinastion is primary screen or local videomemory" |
387 | */ |
387 | */ |
388 | 388 | ||
389 | if( (srv_hw2d != 0) && |
389 | if( (srv_hw2d != 0) && |
390 | ( (pixmap == (void*)-1) || |
390 | ( (pixmap == (void*)-1) || |
391 | ( (pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
391 | ( (pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
392 | { |
392 | { |
393 | fill_t fill; |
393 | fill_t fill; |
394 | ioctl_t io; |
394 | ioctl_t io; |
395 | 395 | ||
396 | fill.dstpix = ((int)pixmap == -1) ? (pixmap_t*)-1 : (pixmap_t*)pixmap->handle; |
396 | fill.dstpix = ((int)pixmap == -1) ? (pixmap_t*)-1 : (pixmap_t*)pixmap->handle; |
397 | fill.x = xorg; |
397 | fill.x = xorg; |
398 | fill.y = yorg; |
398 | fill.y = yorg; |
399 | fill.w = width; |
399 | fill.w = width; |
400 | fill.h = height; |
400 | fill.h = height; |
401 | fill.bkcolor = dst_brush->bkcolor; |
401 | fill.bkcolor = dst_brush->bkcolor; |
402 | fill.fcolor = dst_brush->fcolor; |
402 | fill.fcolor = dst_brush->fcolor; |
403 | fill.bmp0 = dst_brush->bmp[0]; |
403 | fill.bmp0 = dst_brush->bmp[0]; |
404 | fill.bmp1 = dst_brush->bmp[1]; |
404 | fill.bmp1 = dst_brush->bmp[1]; |
405 | fill.border = border; |
405 | fill.border = border; |
406 | 406 | ||
407 | io.handle = srv_hw2d; |
407 | io.handle = srv_hw2d; |
408 | io.io_code = PX_FILL_RECT; |
408 | io.io_code = PX_FILL_RECT; |
409 | io.input = &fill; |
409 | io.input = &fill; |
410 | io.inp_size = 10; |
410 | io.inp_size = 10; |
411 | io.output = NULL; |
411 | io.output = NULL; |
412 | io.out_size = 0; |
412 | io.out_size = 0; |
413 | 413 | ||
414 | return call_service(&io); |
414 | return call_service(&io); |
415 | } |
415 | } |
416 | else |
416 | else |
417 | /* no acceleration or destination in system memory */ |
417 | /* no acceleration or destination in system memory */ |
418 | { |
418 | { |
419 | clip_t clip; |
419 | clip_t clip; |
420 | int x0, y0, x1, y1, xend, yend; |
420 | int x0, y0, x1, y1, xend, yend; |
421 | 421 | ||
422 | pixmap = (pixmap == (void*)-1) ? &scrn_pixmap : pixmap ; |
422 | pixmap = (pixmap == (void*)-1) ? &scrn_pixmap : pixmap ; |
423 | 423 | ||
424 | x0 = xorg; |
424 | x0 = xorg; |
425 | y0 = yorg; |
425 | y0 = yorg; |
426 | x1 = xend = x0 + width - 1; |
426 | x1 = xend = x0 + width - 1; |
427 | y1 = yend = y0 + height - 1; |
427 | y1 = yend = y0 + height - 1; |
428 | 428 | ||
429 | clip.xmin = 0; |
429 | clip.xmin = 0; |
430 | clip.ymin = 0; |
430 | clip.ymin = 0; |
431 | clip.xmax = pixmap->width-1; |
431 | clip.xmax = pixmap->width-1; |
432 | clip.ymax = pixmap->height-1; |
432 | clip.ymax = pixmap->height-1; |
433 | 433 | ||
434 | if( ! BlockClip( &clip, &x0, &y0, &x1, &y1)) |
434 | if( ! BlockClip( &clip, &x0, &y0, &x1, &y1)) |
435 | { |
435 | { |
436 | int w, h, bh, bm_y; |
436 | int w, h, bh, bm_y; |
437 | 437 | ||
438 | __m64 clr_bb, clr_bf, clr_fb, clr_ff; |
438 | __m64 clr_bb, clr_bf, clr_fb, clr_ff; |
439 | char *dst_addr; |
439 | char *dst_addr; |
440 | 440 | ||
441 | clr_bb = _mm_cvtsi32_si64(dst_brush->bkcolor); |
441 | clr_bb = _mm_cvtsi32_si64(dst_brush->bkcolor); |
442 | clr_ff = _mm_cvtsi32_si64(dst_brush->fcolor); |
442 | clr_ff = _mm_cvtsi32_si64(dst_brush->fcolor); |
443 | 443 | ||
444 | clr_bb = _mm_unpacklo_pi32(clr_bb, clr_bb); |
444 | clr_bb = _mm_unpacklo_pi32(clr_bb, clr_bb); |
445 | clr_ff = _mm_unpacklo_pi32(clr_ff, clr_ff); |
445 | clr_ff = _mm_unpacklo_pi32(clr_ff, clr_ff); |
446 | 446 | ||
447 | clr_bf = _mm_unpacklo_pi32(clr_ff, clr_bb); |
447 | clr_bf = _mm_unpacklo_pi32(clr_ff, clr_bb); |
448 | clr_fb = _mm_unpacklo_pi32(clr_bb, clr_ff); |
448 | clr_fb = _mm_unpacklo_pi32(clr_bb, clr_ff); |
449 | 449 | ||
450 | w = x1 -x0 + 1; |
450 | w = x1 -x0 + 1; |
451 | bh = h = y1 -y0 + 1; |
451 | bh = h = y1 -y0 + 1; |
452 | 452 | ||
453 | dst_addr = & ((char*)(pixmap->mapped))[pixmap->pitch*y0+x0*4]; |
453 | dst_addr = & ((char*)(pixmap->mapped))[pixmap->pitch*y0+x0*4]; |
454 | 454 | ||
455 | bm_y = y0 & 7; |
455 | bm_y = y0 & 7; |
456 | 456 | ||
457 | while(h--) |
457 | while(h--) |
458 | { |
458 | { |
459 | u8_t mask = dst_brush->bits[bm_y]; |
459 | u8_t mask = dst_brush->bits[bm_y]; |
460 | 460 | ||
461 | char *tmp_dst = dst_addr; |
461 | char *tmp_dst = dst_addr; |
462 | int width = w; |
462 | int width = w; |
463 | dst_addr += pixmap->pitch; |
463 | dst_addr += pixmap->pitch; |
464 | bm_y = (bm_y+1) & 7; |
464 | bm_y = (bm_y+1) & 7; |
465 | 465 | ||
466 | while(width>=2) |
466 | while(width>=2) |
467 | { |
467 | { |
468 | __asm__ __volatile__ |
468 | __asm__ __volatile__ |
469 | ("rolb $2, %0 \n\t" |
469 | ("rolb $2, %0 \n\t" |
470 | :"+g" (mask):"g"(mask) |
470 | :"+g" (mask):"g"(mask) |
471 | :"cc"); |
471 | :"cc"); |
472 | 472 | ||
473 | switch( mask & 3 ) |
473 | switch( mask & 3 ) |
474 | { |
474 | { |
475 | case 0: |
475 | case 0: |
476 | __asm__ __volatile__ |
476 | __asm__ __volatile__ |
477 | ("movq %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_bb)); |
477 | ("movq %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_bb)); |
478 | break; |
478 | break; |
479 | 479 | ||
480 | case 1: |
480 | case 1: |
481 | __asm__ __volatile__ |
481 | __asm__ __volatile__ |
482 | ("movq %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_fb)); |
482 | ("movq %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_fb)); |
483 | break; |
483 | break; |
484 | 484 | ||
485 | case 2: |
485 | case 2: |
486 | __asm__ __volatile__ |
486 | __asm__ __volatile__ |
487 | ("movq %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_bf)); |
487 | ("movq %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_bf)); |
488 | break; |
488 | break; |
489 | 489 | ||
490 | case 3: |
490 | case 3: |
491 | __asm__ __volatile__ |
491 | __asm__ __volatile__ |
492 | ("movq %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_ff)); |
492 | ("movq %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_ff)); |
493 | break; |
493 | break; |
494 | } |
494 | } |
495 | width -=2; |
495 | width -=2; |
496 | tmp_dst +=8; |
496 | tmp_dst +=8; |
497 | } |
497 | } |
498 | if( width ) |
498 | if( width ) |
499 | if( mask & 1 ) |
499 | if( mask & 1 ) |
500 | __asm__ __volatile__ |
500 | __asm__ __volatile__ |
501 | ("movd %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_ff)); |
501 | ("movd %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_ff)); |
502 | else |
502 | else |
503 | __asm__ __volatile__ |
503 | __asm__ __volatile__ |
504 | ("movd %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_bb)); |
504 | ("movd %[clr], (%0)\n\t" :: "r" (tmp_dst), [clr] "y" (clr_bb)); |
505 | }; |
505 | }; |
506 | 506 | ||
507 | if( (border & 0xFF000000) != 0) |
507 | if( (border & 0xFF000000) != 0) |
508 | { |
508 | { |
509 | if( y0 == yorg) |
509 | if( y0 == yorg) |
510 | { |
510 | { |
511 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
511 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
512 | HLine(dst_addr, w, border); |
512 | HLine(dst_addr, w, border); |
513 | y0++; |
513 | y0++; |
514 | bh--; |
514 | bh--; |
515 | } |
515 | } |
516 | if( y1 == yend ) |
516 | if( y1 == yend ) |
517 | { |
517 | { |
518 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y1 + x0*4]; |
518 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y1 + x0*4]; |
519 | HLine(dst_addr, w, border); |
519 | HLine(dst_addr, w, border); |
520 | bh--; |
520 | bh--; |
521 | } |
521 | } |
522 | if( (bh > 0) && (x0 == xorg)) |
522 | if( (bh > 0) && (x0 == xorg)) |
523 | { |
523 | { |
524 | int dy = bh; |
524 | int dy = bh; |
525 | 525 | ||
526 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
526 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x0*4]; |
527 | 527 | ||
528 | while ( dy-- ) |
528 | while ( dy-- ) |
529 | { |
529 | { |
530 | *(color_t*)dst_addr = border; |
530 | *(color_t*)dst_addr = border; |
531 | dst_addr += pixmap->pitch; |
531 | dst_addr += pixmap->pitch; |
532 | } |
532 | } |
533 | } |
533 | } |
534 | if( (bh > 0) && (x1 == xend)) |
534 | if( (bh > 0) && (x1 == xend)) |
535 | { |
535 | { |
536 | int dy = bh; |
536 | int dy = bh; |
537 | 537 | ||
538 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x1*4]; |
538 | dst_addr = &((char*)(pixmap->mapped))[pixmap->pitch*y0 + x1*4]; |
539 | 539 | ||
540 | while ( dy-- ) |
540 | while ( dy-- ) |
541 | { |
541 | { |
542 | *(color_t*)dst_addr = border; |
542 | *(color_t*)dst_addr = border; |
543 | dst_addr += pixmap->pitch; |
543 | dst_addr += pixmap->pitch; |
544 | } |
544 | } |
545 | } |
545 | } |
546 | }; |
546 | }; |
547 | 547 | ||
548 | _mm_empty(); |
548 | _mm_empty(); |
549 | }; |
549 | }; |
550 | }; |
550 | }; |
551 | return ERR_OK; |
551 | return ERR_OK; |
552 | }; |
552 | }; |
553 | 553 | ||
554 | 554 | ||
555 | int Blit(pixmap_t *dst_pixmap, int dst_x, int dst_y, |
555 | int Blit(pixmap_t *dst_pixmap, int dst_x, int dst_y, |
556 | pixmap_t *src_pixmap, int src_x, int src_y, |
556 | pixmap_t *src_pixmap, int src_x, int src_y, |
557 | int width, int height) |
557 | int width, int height) |
558 | { |
558 | { |
559 | 559 | ||
560 | clip_t src_clip, dst_clip; |
560 | clip_t src_clip, dst_clip; |
561 | 561 | ||
562 | if( ( width <= 0 ) || ( height<=0 ) ) |
562 | if( ( width <= 0 ) || ( height<=0 ) ) |
563 | return ERR_PARAM; |
563 | return ERR_PARAM; |
564 | 564 | ||
565 | /* if "hardware acceleration present" and |
565 | /* if "hardware acceleration present" and |
566 | "destinastion is primary screen or local videomemory" and |
566 | "destinastion is primary screen or local videomemory" |
567 | "source is primary screen or local videomemory" |
567 | */ |
568 | */ |
- | |
569 | if( (srv_hw2d != 0) && |
568 | if( (srv_hw2d != 0) && |
570 | ( (dst_pixmap == (void*)-1) || |
569 | ( (dst_pixmap == (void*)-1) || |
571 | ( (dst_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) && |
570 | ( (dst_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) /* && |
572 | ( (src_pixmap == (void*)-1) || |
571 | ( (src_pixmap == (void*)-1) || |
573 | ( (src_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
572 | ( (src_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) */ ) |
574 | { |
573 | { |
575 | ioctl_t io; |
574 | ioctl_t io; |
576 | pxblit_t *blit = (pxblit_t*)&dst_pixmap; |
575 | pxblit_t *blit = (pxblit_t*)&dst_pixmap; |
577 | 576 | ||
578 | if((int)dst_pixmap != -1) |
577 | if((int)dst_pixmap != -1) |
579 | blit->dst_pixmap = (pixmap_t*)dst_pixmap->handle; |
578 | blit->dst_pixmap = (pixmap_t*)dst_pixmap->handle; |
580 | 579 | ||
581 | if((int)src_pixmap != -1) |
580 | if( (int)src_pixmap != -1 && |
- | 581 | (src_pixmap->flags & PX_MEM_MASK) != PX_MEM_SYSTEM) |
|
582 | blit->src_pixmap = (pixmap_t*)src_pixmap->handle; |
582 | blit->src_pixmap = (pixmap_t*)src_pixmap->handle; |
583 | 583 | ||
584 | io.handle = srv_hw2d; |
584 | io.handle = srv_hw2d; |
585 | io.io_code = PX_BLIT; |
585 | io.io_code = PX_BLIT; |
586 | io.input = blit; |
586 | io.input = blit; |
587 | io.inp_size = 8; |
587 | io.inp_size = 8; |
588 | io.output = NULL; |
588 | io.output = NULL; |
589 | io.out_size = 0; |
589 | io.out_size = 0; |
590 | 590 | ||
591 | return call_service(&io); |
591 | return call_service(&io); |
592 | } |
592 | } |
593 | 593 | ||
594 | dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ; |
594 | dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ; |
595 | src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ; |
595 | src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ; |
596 | 596 | ||
597 | src_clip.xmin = 0; |
597 | src_clip.xmin = 0; |
598 | src_clip.ymin = 0; |
598 | src_clip.ymin = 0; |
599 | src_clip.xmax = src_pixmap->width-1; |
599 | src_clip.xmax = src_pixmap->width-1; |
600 | src_clip.ymax = src_pixmap->height-1; |
600 | src_clip.ymax = src_pixmap->height-1; |
601 | 601 | ||
602 | dst_clip.xmin = 0; |
602 | dst_clip.xmin = 0; |
603 | dst_clip.ymin = 0; |
603 | dst_clip.ymin = 0; |
604 | dst_clip.xmax = dst_pixmap->width-1; |
604 | dst_clip.xmax = dst_pixmap->width-1; |
605 | dst_clip.ymax = dst_pixmap->height-1; |
605 | dst_clip.ymax = dst_pixmap->height-1; |
606 | 606 | ||
607 | if( !blit_clip(&dst_clip, &dst_x, &dst_y, |
607 | if( !blit_clip(&dst_clip, &dst_x, &dst_y, |
608 | &src_clip, &src_x, &src_y, |
608 | &src_clip, &src_x, &src_y, |
609 | &width, &height) ) |
609 | &width, &height) ) |
610 | { |
610 | { |
611 | color_t *src_addr = &((color_t*)(src_pixmap->mapped))[src_pixmap->pitch*src_y/4+src_x]; |
611 | color_t *src_addr = &((color_t*)(src_pixmap->mapped))[src_pixmap->pitch*src_y/4+src_x]; |
612 | color_t *dst_addr = &((color_t*)(dst_pixmap->mapped))[dst_pixmap->pitch*dst_y/4+dst_x]; |
612 | color_t *dst_addr = &((color_t*)(dst_pixmap->mapped))[dst_pixmap->pitch*dst_y/4+dst_x]; |
613 | 613 | ||
614 | while( height-- ) |
614 | while( height-- ) |
615 | { |
615 | { |
616 | int w = width; |
616 | int w = width; |
617 | color_t *tmp_src = src_addr; |
617 | color_t *tmp_src = src_addr; |
618 | color_t *tmp_dst = dst_addr; |
618 | color_t *tmp_dst = dst_addr; |
619 | 619 | ||
620 | src_addr += src_pixmap->pitch/4; |
620 | src_addr += src_pixmap->pitch/4; |
621 | dst_addr += dst_pixmap->pitch/4; |
621 | dst_addr += dst_pixmap->pitch/4; |
622 | 622 | ||
623 | while( w >= 8) |
623 | while( w >= 8) |
624 | { |
624 | { |
625 | __asm__ __volatile__ ( |
625 | __asm__ __volatile__ ( |
626 | "movq (%0), %%mm0\n" |
626 | "movq (%0), %%mm0\n" |
627 | "movq 8(%0), %%mm1\n" |
627 | "movq 8(%0), %%mm1\n" |
628 | "movq 16(%0), %%mm2\n" |
628 | "movq 16(%0), %%mm2\n" |
629 | "movq 24(%0), %%mm3\n" |
629 | "movq 24(%0), %%mm3\n" |
630 | "movq %%mm0, (%1)\n" |
630 | "movq %%mm0, (%1)\n" |
631 | "movq %%mm1, 8(%1)\n" |
631 | "movq %%mm1, 8(%1)\n" |
632 | "movq %%mm2, 16(%1)\n" |
632 | "movq %%mm2, 16(%1)\n" |
633 | "movq %%mm3, 24(%1)\n" |
633 | "movq %%mm3, 24(%1)\n" |
634 | :: "r" (tmp_src), "r" (tmp_dst) |
634 | :: "r" (tmp_src), "r" (tmp_dst) |
635 | : "memory", "%mm0", "%mm1", "%mm2", "%mm3"); |
635 | : "memory", "%mm0", "%mm1", "%mm2", "%mm3"); |
636 | w -= 8; |
636 | w -= 8; |
637 | tmp_src += 8; |
637 | tmp_src += 8; |
638 | tmp_dst += 8; |
638 | tmp_dst += 8; |
639 | }; |
639 | }; |
640 | if( w >= 4 ) |
640 | if( w >= 4 ) |
641 | { |
641 | { |
642 | __asm__ __volatile__ ( |
642 | __asm__ __volatile__ ( |
643 | "movq (%0), %%mm0\n" |
643 | "movq (%0), %%mm0\n" |
644 | "movq 8(%0), %%mm1\n" |
644 | "movq 8(%0), %%mm1\n" |
645 | "movq %%mm0, (%1)\n" |
645 | "movq %%mm0, (%1)\n" |
646 | "movq %%mm1, 8(%1)\n" |
646 | "movq %%mm1, 8(%1)\n" |
647 | :: "r" (tmp_src), "r" (tmp_dst) |
647 | :: "r" (tmp_src), "r" (tmp_dst) |
648 | : "memory", "%mm0", "%mm1"); |
648 | : "memory", "%mm0", "%mm1"); |
649 | w -= 4; |
649 | w -= 4; |
650 | tmp_src += 4; |
650 | tmp_src += 4; |
651 | tmp_dst += 4; |
651 | tmp_dst += 4; |
652 | }; |
652 | }; |
653 | if( w >= 2 ) |
653 | if( w >= 2 ) |
654 | { |
654 | { |
655 | __asm__ __volatile__ ( |
655 | __asm__ __volatile__ ( |
656 | "movq (%0), %%mm0\n" |
656 | "movq (%0), %%mm0\n" |
657 | "movq %%mm0, (%1)\n" |
657 | "movq %%mm0, (%1)\n" |
658 | :: "r" (tmp_src), "r" (tmp_dst) |
658 | :: "r" (tmp_src), "r" (tmp_dst) |
659 | : "memory", "%mm0"); |
659 | : "memory", "%mm0"); |
660 | w -= 2; |
660 | w -= 2; |
661 | tmp_src += 2; |
661 | tmp_src += 2; |
662 | tmp_dst += 2; |
662 | tmp_dst += 2; |
663 | }; |
663 | }; |
664 | if( w ) |
664 | if( w ) |
665 | *tmp_dst = *tmp_src; |
665 | *tmp_dst = *tmp_src; |
666 | }; |
666 | }; |
667 | }; |
667 | }; |
668 | return ERR_OK; |
668 | return ERR_OK; |
669 | }; |
669 | }; |
670 | 670 | ||
671 | int TransparentBlit(pixmap_t *dst_pixmap, int dst_x, int dst_y, |
671 | int TransparentBlit(pixmap_t *dst_pixmap, int dst_x, int dst_y, |
672 | pixmap_t *src_pixmap, int src_x, int src_y, |
672 | pixmap_t *src_pixmap, int src_x, int src_y, |
673 | int width, int height, color_t key) |
673 | int width, int height, color_t key) |
674 | { |
674 | { |
675 | clip_t src_clip, dst_clip; |
675 | clip_t src_clip, dst_clip; |
676 | 676 | ||
677 | /* if "hardware acceleration present" and |
677 | /* if "hardware acceleration present" and |
678 | "destinastion is primary screen or local videomemory" and |
678 | "destinastion is primary screen or local videomemory" and |
679 | "source is primary screen or local videomemory" |
679 | "source is primary screen or local videomemory" |
680 | */ |
680 | */ |
681 | 681 | ||
682 | if( (srv_hw2d != 0) && |
682 | if( (srv_hw2d != 0) && |
683 | ( (dst_pixmap == (void*)-1) || |
683 | ( (dst_pixmap == (void*)-1) || |
684 | ( (dst_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) && |
684 | ( (dst_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) && |
685 | ( (src_pixmap == (void*)-1) || |
685 | ( (src_pixmap == (void*)-1) || |
686 | ( (src_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
686 | ( (src_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
687 | { |
687 | { |
688 | ioctl_t io; |
688 | ioctl_t io; |
689 | pxblit_t *blit = (pxblit_t*)&dst_pixmap; |
689 | pxblit_t *blit = (pxblit_t*)&dst_pixmap; |
690 | 690 | ||
691 | if((int)dst_pixmap != -1) |
691 | if((int)dst_pixmap != -1) |
692 | blit->dst_pixmap = (pixmap_t*)dst_pixmap->handle; |
692 | blit->dst_pixmap = (pixmap_t*)dst_pixmap->handle; |
693 | 693 | ||
694 | if((int)src_pixmap != -1) |
694 | if((int)src_pixmap != -1) |
695 | blit->src_pixmap = (pixmap_t*)src_pixmap->handle; |
695 | blit->src_pixmap = (pixmap_t*)src_pixmap->handle; |
696 | 696 | ||
697 | io.handle = srv_hw2d; |
697 | io.handle = srv_hw2d; |
698 | io.io_code = PX_BLIT_TRANSPARENT; |
698 | io.io_code = PX_BLIT_TRANSPARENT; |
699 | io.input = blit; |
699 | io.input = blit; |
700 | io.inp_size = 9; |
700 | io.inp_size = 9; |
701 | io.output = NULL; |
701 | io.output = NULL; |
702 | io.out_size = 0; |
702 | io.out_size = 0; |
703 | 703 | ||
704 | return call_service(&io); |
704 | return call_service(&io); |
705 | }; |
705 | }; |
706 | 706 | ||
- | 707 | dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ; |
|
- | 708 | src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ; |
|
- | 709 | ||
707 | src_clip.xmin = 0; |
710 | src_clip.xmin = 0; |
708 | src_clip.ymin = 0; |
711 | src_clip.ymin = 0; |
709 | src_clip.xmax = src_pixmap->width-1; |
712 | src_clip.xmax = src_pixmap->width-1; |
710 | src_clip.ymax = src_pixmap->height-1; |
713 | src_clip.ymax = src_pixmap->height-1; |
711 | 714 | ||
712 | dst_clip.xmin = 0; |
715 | dst_clip.xmin = 0; |
713 | dst_clip.ymin = 0; |
716 | dst_clip.ymin = 0; |
714 | dst_clip.xmax = dst_pixmap->width-1; |
717 | dst_clip.xmax = dst_pixmap->width-1; |
715 | dst_clip.ymax = dst_pixmap->height-1; |
718 | dst_clip.ymax = dst_pixmap->height-1; |
716 | 719 | ||
717 | 720 | ||
718 | if( !blit_clip(&dst_clip, &dst_x, &dst_y, |
721 | if( !blit_clip(&dst_clip, &dst_x, &dst_y, |
719 | &src_clip, &src_x, &src_y, |
722 | &src_clip, &src_x, &src_y, |
720 | &width, &height) ) |
723 | &width, &height) ) |
721 | { |
724 | { |
722 | __m64 clr_key; |
725 | __m64 clr_key; |
723 | 726 | ||
724 | dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ; |
- | |
725 | src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ; |
- | |
726 | 727 | ||
727 | color_t *src_addr = &((color_t*)(src_pixmap->mapped))[src_pixmap->pitch*src_y/4+src_x]; |
728 | color_t *src_addr = &((color_t*)(src_pixmap->mapped))[src_pixmap->pitch*src_y/4+src_x]; |
728 | color_t *dst_addr = &((color_t*)(dst_pixmap->mapped))[dst_pixmap->pitch*dst_y/4+dst_x]; |
729 | color_t *dst_addr = &((color_t*)(dst_pixmap->mapped))[dst_pixmap->pitch*dst_y/4+dst_x]; |
729 | 730 | ||
730 | clr_key = _mm_cvtsi32_si64(key); |
731 | clr_key = _mm_cvtsi32_si64(key); |
731 | clr_key = _mm_unpacklo_pi32(clr_key, clr_key); |
732 | clr_key = _mm_unpacklo_pi32(clr_key, clr_key); |
732 | 733 | ||
733 | while( height-- ) |
734 | while( height-- ) |
734 | { |
735 | { |
735 | int w = width; |
736 | int w = width; |
736 | color_t *tmp_src = src_addr; |
737 | color_t *tmp_src = src_addr; |
737 | color_t *tmp_dst = dst_addr; |
738 | color_t *tmp_dst = dst_addr; |
738 | 739 | ||
739 | src_addr += src_pixmap->pitch/4; |
740 | src_addr += src_pixmap->pitch/4; |
740 | dst_addr += dst_pixmap->pitch/4; |
741 | dst_addr += dst_pixmap->pitch/4; |
741 | 742 | ||
742 | while( w >= 2) |
743 | while( w >= 2) |
743 | { |
744 | { |
744 | __asm__ __volatile__ ( |
745 | __asm__ __volatile__ ( |
745 | "movq %[clr_key], %%mm0 \n\t" |
746 | "movq %[clr_key], %%mm0 \n\t" |
746 | "pcmpeqd %[src_clr], %%mm0 \n\t" |
747 | "pcmpeqd %[src_clr], %%mm0 \n\t" |
747 | "pand %%mm0, %[dst_clr] \n\t" |
748 | "pand %%mm0, %[dst_clr] \n\t" |
748 | "pandn %[src_clr], %%mm0 \n\t" |
749 | "pandn %[src_clr], %%mm0 \n\t" |
749 | "por %%mm0, %[dst_clr] \n\t" |
750 | "por %%mm0, %[dst_clr] \n\t" |
750 | "movq %[dst_clr], (%0)" |
751 | "movq %[dst_clr], (%0)" |
751 | :: "r" (tmp_dst), |
752 | :: "r" (tmp_dst), |
752 | [src_clr] "y" (*(__m64*)tmp_src), |
753 | [src_clr] "y" (*(__m64*)tmp_src), |
753 | [dst_clr] "y" (*(__m64*)tmp_dst), |
754 | [dst_clr] "y" (*(__m64*)tmp_dst), |
754 | [clr_key] "y" (clr_key) |
755 | [clr_key] "y" (clr_key) |
755 | :"memory","mm0"); |
756 | :"memory","mm0"); |
756 | 757 | ||
757 | w -= 2; |
758 | w -= 2; |
758 | tmp_src += 2; |
759 | tmp_src += 2; |
759 | tmp_dst += 2; |
760 | tmp_dst += 2; |
760 | }; |
761 | }; |
761 | if( w && (*tmp_src != key) ) |
762 | if( w && (*tmp_src != key) ) |
762 | *tmp_dst = *tmp_src; |
763 | *tmp_dst = *tmp_src; |
763 | }; |
764 | }; |
764 | }; |
765 | }; |
765 | return ERR_OK; |
766 | return ERR_OK; |
766 | }=0>=>=0>=>=0>=>><>><>><>><>>>>> |
767 | } |
767 | 768 | ||
- | 769 | unsigned long long m_0080 = 0x0080008000800080ULL; |
|
- | 770 | ||
- | 771 | int BlitAlpha(pixmap_t *dst_pixmap, int dst_x, int dst_y, |
|
- | 772 | pixmap_t *src_pixmap, int src_x, int src_y, |
|
- | 773 | int width, int height, u32_t alpha) |
|
- | 774 | { |
|
- | 775 | clip_t src_clip, dst_clip; |
|
- | 776 | ||
- | 777 | if( (srv_hw2d != 0) && |
|
- | 778 | ( (dst_pixmap == (void*)-1) || |
|
- | 779 | ( (dst_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) && |
|
- | 780 | ( (src_pixmap == (void*)-1) || |
|
- | 781 | ( (src_pixmap->flags & PX_MEM_MASK)==PX_MEM_LOCAL) ) ) |
|
- | 782 | { |
|
- | 783 | ioctl_t io; |
|
- | 784 | pxblit_t *blit = (pxblit_t*)&dst_pixmap; |
|
- | 785 | ||
- | 786 | if((int)dst_pixmap != -1) |
|
- | 787 | blit->dst_pixmap = (pixmap_t*)dst_pixmap->handle; |
|
- | 788 | ||
- | 789 | if((int)src_pixmap != -1) |
|
- | 790 | blit->src_pixmap = (pixmap_t*)src_pixmap->handle; |
|
- | 791 | ||
- | 792 | io.handle = srv_hw2d; |
|
- | 793 | io.io_code = PX_BLIT_ALPHA; |
|
- | 794 | io.input = blit; |
|
- | 795 | io.inp_size = 9; |
|
- | 796 | io.output = NULL; |
|
- | 797 | io.out_size = 0; |
|
- | 798 | ||
- | 799 | return call_service(&io); |
|
- | 800 | }; |
|
- | 801 | ||
- | 802 | dst_pixmap = (dst_pixmap == (void*)-1) ? &scrn_pixmap : dst_pixmap ; |
|
- | 803 | src_pixmap = (src_pixmap == (void*)-1) ? &scrn_pixmap : src_pixmap ; |
|
- | 804 | ||
- | 805 | src_clip.xmin = 0; |
|
- | 806 | src_clip.ymin = 0; |
|
- | 807 | src_clip.xmax = src_pixmap->width-1; |
|
- | 808 | src_clip.ymax = src_pixmap->height-1; |
|
- | 809 | ||
- | 810 | dst_clip.xmin = 0; |
|
- | 811 | dst_clip.ymin = 0; |
|
- | 812 | dst_clip.xmax = dst_pixmap->width-1; |
|
- | 813 | dst_clip.ymax = dst_pixmap->height-1; |
|
- | 814 | ||
- | 815 | ||
- | 816 | if( !blit_clip(&dst_clip, &dst_x, &dst_y, |
|
- | 817 | &src_clip, &src_x, &src_y, |
|
- | 818 | &width, &height) ) |
|
- | 819 | { |
|
- | 820 | __m64 m_alpha; |
|
- | 821 | __m64 m_one_alpha; |
|
- | 822 | ||
- | 823 | color_t *src_addr = &((color_t*)(src_pixmap->mapped))[src_pixmap->pitch*src_y/4+src_x]; |
|
- | 824 | color_t *dst_addr = &((color_t*)(dst_pixmap->mapped))[dst_pixmap->pitch*dst_y/4+dst_x]; |
|
- | 825 | ||
- | 826 | m_alpha = _mm_cvtsi32_si64((alpha << 16) | alpha); |
|
- | 827 | m_alpha = _mm_unpacklo_pi32(m_alpha, m_alpha); |
|
- | 828 | m_one_alpha = _mm_subs_pu16((__m64)0x00FF00FF00FF00FFULL, m_alpha); |
|
- | 829 | ||
- | 830 | while( height-- ) |
|
- | 831 | { |
|
- | 832 | int w = width; |
|
- | 833 | color_t *tmp_src = src_addr; |
|
- | 834 | color_t *tmp_dst = dst_addr; |
|
- | 835 | ||
- | 836 | src_addr += src_pixmap->pitch/4; |
|
- | 837 | dst_addr += dst_pixmap->pitch/4; |
|
- | 838 | ||
- | 839 | while( w-- ) |
|
- | 840 | { |
|
- | 841 | __asm__ __volatile__ ( |
|
- | 842 | "movd (%0), %%mm0 \n\t" |
|
- | 843 | "pxor %%mm1, %%mm1 \n\t" |
|
- | 844 | "punpcklbw %%mm1, %%mm0 \n\t" |
|
- | 845 | "pmullw %[clr_key], %%mm0 \n\t" |
|
- | 846 | // "paddw %[m_0080], %%mm0 \n\t" |
|
- | 847 | ||
- | 848 | "movd (%1), %%mm2 \n\t" |
|
- | 849 | "punpcklbw %%mm1, %%mm2 \n\t" |
|
- | 850 | "pmullw %[m_one_alpha], %%mm2 \n\t" |
|
- | 851 | // "paddw %[m_0080], %%mm2 \n\t" |
|
- | 852 | ||
- | 853 | "paddw %%mm2, %%mm0 \n\t" |
|
- | 854 | "psrlw $8, %%mm0 \n\t" |
|
- | 855 | "packuswb %%mm0, %%mm0 \n\t" |
|
- | 856 | "movd %%mm0, (%1)" |
|
- | 857 | :: "r" (tmp_src), |
|
- | 858 | "r" (tmp_dst), |
|
- | 859 | [clr_key] "y" (m_alpha), |
|
- | 860 | [m_one_alpha] "y" (m_one_alpha) |
|
- | 861 | :"memory","mm0", "mm1", "mm2"); |
|
- | 862 | ||
- | 863 | tmp_src++; |
|
- | 864 | tmp_dst++; |
|
- | 865 | }; |
|
- | 866 | // if( w && (*tmp_src != alpha) ) |
|
- | 867 | // *tmp_dst = *tmp_src; |
|
- | 868 | }; |
|
- | 869 | }; |
|
- | 870 | return ERR_OK; |
|
- | 871 | }><>=0>=>=0>=>=0>=>><>><>><>><>>>>> |