Rev 5565 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2465 | Serge | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
5565 | serge | 3 | ;; Copyright (C) KolibriOS team 2011-2015. All rights reserved. ;; |
2465 | Serge | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
2434 | Serge | 7 | |
5201 | serge | 8 | $Revision: 5164 $ |
9 | |||
10 | |||
2434 | Serge | 11 | struct BLITTER_BLOCK |
12 | xmin dd ? |
||
13 | ymin dd ? |
||
14 | xmax dd ? |
||
15 | ymax dd ? |
||
16 | ends |
||
17 | |||
18 | |||
19 | struct BLITTER |
||
2467 | Serge | 20 | dc RECT |
21 | sc RECT |
||
2434 | Serge | 22 | dst_x dd ? ; 32 |
23 | dst_y dd ? ; 36 |
||
24 | src_x dd ? ; 40 |
||
25 | src_y dd ? ; 44 |
||
26 | w dd ? ; 48 |
||
27 | h dd ? ; 52 |
||
28 | |||
29 | bitmap dd ? ; 56 |
||
30 | stride dd ? ; 60 |
||
31 | ends |
||
32 | |||
33 | |||
2467 | Serge | 34 | |
2434 | Serge | 35 | align 4 |
2467 | Serge | 36 | block_clip: |
37 | ;esi= clip RECT ptr |
||
38 | ;edi= RECT ptr |
||
39 | ;return code: |
||
40 | ;eax= 0 - draw, 1 - don't draw |
||
2434 | Serge | 41 | |
42 | push ebx |
||
43 | |||
2467 | Serge | 44 | mov eax, [edi+RECT.left] |
45 | mov ebx, [edi+RECT.right] |
||
46 | mov ecx, [esi+RECT.left] ;clip.left |
||
47 | mov edx, [esi+RECT.right] ;clip.right |
||
2434 | Serge | 48 | |
2467 | Serge | 49 | cmp eax, edx ;left >= clip.right |
50 | jge .fail |
||
2434 | Serge | 51 | |
2467 | Serge | 52 | cmp ebx, ecx ;right < clip.left |
53 | jl .fail |
||
2434 | Serge | 54 | |
2467 | Serge | 55 | cmp eax, ecx ;left >= clip.left |
56 | jae @F |
||
2434 | Serge | 57 | |
2467 | Serge | 58 | mov eax, ecx |
59 | @@: |
||
60 | mov [edi+RECT.left], eax |
||
61 | |||
62 | cmp ebx, edx ;right <= clip.right |
||
63 | jle @f |
||
64 | mov ebx, edx |
||
65 | @@: |
||
66 | mov [edi+RECT.right], ebx |
||
67 | |||
68 | mov eax, [edi+RECT.top] |
||
69 | mov ebx, [edi+RECT.bottom] |
||
70 | mov ecx, [esi+RECT.top] ;clip.top |
||
71 | mov edx, [esi+RECT.bottom] ;clip.bottom |
||
72 | |||
73 | cmp eax, edx ;top >= clip.bottom |
||
74 | jge .fail |
||
75 | |||
76 | cmp ebx, ecx ;bottom < clip.top |
||
77 | jl .fail |
||
78 | |||
79 | cmp eax, ecx ;top >= clip.top |
||
80 | jae @F |
||
81 | |||
82 | mov eax, ecx |
||
83 | @@: |
||
84 | mov [edi+RECT.top], eax |
||
85 | |||
86 | cmp ebx, edx ;bottom <= clip.bottom |
||
87 | jle @f |
||
88 | mov ebx, edx |
||
89 | @@: |
||
90 | mov [edi+RECT.bottom], ebx |
||
2434 | Serge | 91 | pop ebx |
2467 | Serge | 92 | xor eax, eax |
2434 | Serge | 93 | ret |
2467 | Serge | 94 | .fail: |
95 | pop ebx |
||
96 | mov eax, 1 |
||
97 | ret |
||
2434 | Serge | 98 | |
2467 | Serge | 99 | |
2434 | Serge | 100 | align 4 |
101 | blit_clip: |
||
102 | |||
2467 | Serge | 103 | .sx0 equ 8 |
104 | .sy0 equ 12 |
||
105 | .sx1 equ 16 |
||
106 | .sy1 equ 20 |
||
2434 | Serge | 107 | |
2467 | Serge | 108 | .dx0 equ 24 |
109 | .dy0 equ 28 |
||
110 | .dx1 equ 32 |
||
111 | .dy1 equ 36 |
||
2434 | Serge | 112 | |
113 | |||
114 | push edi |
||
115 | push esi |
||
116 | push ebx |
||
117 | sub esp, 40 |
||
118 | |||
119 | mov ebx, ecx |
||
120 | mov edx, [ecx+BLITTER.src_x] |
||
121 | mov [esp+.sx0], edx |
||
122 | mov eax, [ecx+BLITTER.src_y] |
||
123 | mov [esp+.sy0], eax |
||
124 | add edx, [ecx+BLITTER.w] |
||
2467 | Serge | 125 | add eax, [ecx+BLITTER.h] |
2434 | Serge | 126 | mov [esp+.sx1], edx |
127 | mov [esp+.sy1], eax |
||
128 | |||
2467 | Serge | 129 | lea edi, [esp+.sx0] |
130 | lea esi, [ebx+BLITTER.sc] |
||
2434 | Serge | 131 | |
132 | call block_clip |
||
2467 | Serge | 133 | test eax, eax |
2434 | Serge | 134 | mov esi, 1 |
2467 | Serge | 135 | jnz .done |
2434 | Serge | 136 | |
137 | mov edi, [esp+.sx0] |
||
138 | mov edx, [ebx+BLITTER.dst_x] |
||
139 | add edx, edi |
||
140 | sub edx, [ebx+BLITTER.src_x] |
||
141 | mov [esp+.dx0], edx |
||
142 | |||
143 | mov ecx, [esp+.sy0] |
||
144 | mov eax, [ebx+BLITTER.dst_y] |
||
145 | add eax, ecx |
||
146 | sub eax, [ebx+BLITTER.src_y] |
||
147 | mov [esp+.dy0], eax |
||
2467 | Serge | 148 | |
2434 | Serge | 149 | sub edx, edi |
150 | add edx, [esp+.sx1] |
||
151 | mov [esp+.dx1], edx |
||
152 | |||
153 | sub eax, ecx |
||
154 | add eax, [esp+.sy1] |
||
155 | mov [esp+.dy1], eax |
||
156 | |||
2467 | Serge | 157 | lea edi, [esp+.dx0] |
158 | lea esi, [ebx+BLITTER.dc] |
||
2434 | Serge | 159 | call block_clip |
160 | test eax, eax |
||
2467 | Serge | 161 | mov esi, 1 |
162 | jnz .done |
||
2434 | Serge | 163 | |
164 | mov edx, [esp+.dx0] |
||
165 | mov eax, [esp+.dx1] |
||
166 | sub eax, edx |
||
167 | mov [ebx+BLITTER.w], eax |
||
168 | |||
169 | mov eax, [esp+.dy0] |
||
170 | mov ecx, [esp+.dy1] |
||
171 | sub ecx, eax |
||
172 | mov [ebx+BLITTER.h], ecx |
||
173 | |||
174 | mov ecx, [ebx+BLITTER.src_x] |
||
175 | add ecx, edx |
||
176 | sub ecx, [ebx+BLITTER.dst_x] |
||
177 | mov [ebx+BLITTER.src_x], ecx |
||
178 | |||
179 | mov ecx, [ebx+BLITTER.src_y] |
||
180 | add ecx, eax |
||
181 | sub ecx, [ebx+BLITTER.dst_y] |
||
182 | mov [ebx+BLITTER.src_y], ecx |
||
183 | mov [ebx+BLITTER.dst_x], edx |
||
184 | mov [ebx+BLITTER.dst_y], eax |
||
185 | xor esi, esi |
||
2467 | Serge | 186 | .done: |
2434 | Serge | 187 | mov eax, esi |
188 | add esp, 40 |
||
189 | pop ebx |
||
190 | pop esi |
||
191 | pop edi |
||
192 | |||
193 | |||
194 | purge .sx0 |
||
195 | purge .sy0 |
||
196 | purge .sx1 |
||
197 | purge .sy1 |
||
198 | |||
199 | purge .dx0 |
||
200 | purge .dy0 |
||
201 | purge .dx1 |
||
202 | purge .dy1 |
||
203 | |||
204 | ret |
||
205 | |||
206 | align 4 |
||
207 | blit_32: |
||
3232 | Serge | 208 | |
209 | .x_y equ 72 |
||
210 | .tmp_x_y equ 76 |
||
211 | |||
212 | |||
2434 | Serge | 213 | push ebp |
214 | push edi |
||
215 | push esi |
||
216 | push ebx |
||
3232 | Serge | 217 | sub esp, 80 |
2434 | Serge | 218 | |
219 | mov eax, [TASK_BASE] |
||
220 | mov ebx, [eax-twdw + WDATA.box.width] |
||
221 | mov edx, [eax-twdw + WDATA.box.height] |
||
2467 | Serge | 222 | inc ebx |
223 | inc edx |
||
2434 | Serge | 224 | |
225 | xor eax, eax |
||
226 | |||
2467 | Serge | 227 | mov [esp+BLITTER.dc.left], eax |
228 | mov [esp+BLITTER.dc.top], eax |
||
229 | mov [esp+BLITTER.dc.right], ebx |
||
230 | mov [esp+BLITTER.dc.bottom], edx |
||
2434 | Serge | 231 | |
2467 | Serge | 232 | mov [esp+BLITTER.sc.left], eax |
233 | mov [esp+BLITTER.sc.top], eax |
||
2434 | Serge | 234 | mov eax, [ecx+24] |
2467 | Serge | 235 | |
236 | mov [esp+BLITTER.sc.right], eax |
||
2434 | Serge | 237 | mov eax, [ecx+28] |
238 | |||
2467 | Serge | 239 | mov [esp+BLITTER.sc.bottom], eax |
240 | |||
2434 | Serge | 241 | mov eax, [ecx] |
242 | mov [esp+BLITTER.dst_x], eax |
||
243 | mov eax, [ecx+4] |
||
244 | mov [esp+BLITTER.dst_y], eax |
||
245 | |||
246 | mov eax, [ecx+16] |
||
247 | mov [esp+BLITTER.src_x], eax |
||
248 | mov eax, [ecx+20] |
||
249 | mov [esp+BLITTER.src_y], eax |
||
250 | mov eax, [ecx+8] |
||
251 | mov [esp+BLITTER.w], eax |
||
252 | mov eax, [ecx+12] |
||
253 | mov [esp+BLITTER.h], eax |
||
254 | |||
255 | |||
256 | mov eax, [ecx+32] |
||
257 | mov [esp+56], eax |
||
258 | mov eax, [ecx+36] |
||
259 | mov [esp+60], eax |
||
260 | |||
261 | mov ecx, esp |
||
262 | call blit_clip |
||
263 | test eax, eax |
||
3232 | Serge | 264 | jne .done |
2434 | Serge | 265 | |
266 | mov eax, [TASK_BASE] |
||
267 | |||
268 | mov ebx, [esp+BLITTER.dst_x] |
||
269 | mov ebp, [esp+BLITTER.dst_y] |
||
270 | add ebx, [eax-twdw + WDATA.box.left] |
||
271 | add ebp, [eax-twdw + WDATA.box.top] |
||
272 | |||
273 | mov ecx, ebx |
||
274 | shl ecx, 16 |
||
275 | mov cx, bp |
||
3232 | Serge | 276 | mov [esp+.x_y], ecx |
2434 | Serge | 277 | |
278 | mov edi, ebp |
||
279 | |||
2987 | Serge | 280 | mov edi, [BPSLine_calc_area+edi*4] |
281 | mov ebp, [d_width_calc_area+ebp*4] |
||
2465 | Serge | 282 | |
2434 | Serge | 283 | add ebp, ebx |
5577 | serge | 284 | add ebp, [_display.win_map] |
2434 | Serge | 285 | |
286 | mov eax, [esp+BLITTER.src_y] |
||
287 | imul eax, [esp+BLITTER.stride] |
||
288 | mov esi, [esp+BLITTER.src_x] |
||
289 | lea esi, [eax+esi*4] |
||
290 | add esi, [esp+BLITTER.bitmap] |
||
291 | |||
292 | mov ecx, [esp+BLITTER.h] |
||
293 | mov edx, [esp+BLITTER.w] |
||
294 | |||
295 | test ecx, ecx ;FIXME check clipping |
||
3232 | Serge | 296 | jz .done |
2434 | Serge | 297 | |
298 | test edx, edx |
||
3232 | Serge | 299 | jz .done |
2434 | Serge | 300 | |
301 | lea edi, [edi+ebx*4] |
||
302 | |||
3232 | Serge | 303 | ; xchg bx, bx |
2987 | Serge | 304 | |
2434 | Serge | 305 | mov ebx, [CURRENT_TASK] |
3232 | Serge | 306 | mov ecx, [esp+80] |
307 | shr ecx, 4 |
||
308 | and ecx, 3 |
||
2987 | Serge | 309 | |
3232 | Serge | 310 | jmp dword [.tbl_32+ecx*4] |
311 | |||
2434 | Serge | 312 | align 4 |
3232 | Serge | 313 | .tbl_32 dd blit_copy_32 |
314 | dd blit_copy_32_bgr |
||
315 | dd blit_trans_32 |
||
316 | dd blit_trans_32_bgr |
||
317 | |||
318 | .done: |
||
319 | add esp, 80 |
||
320 | pop ebx |
||
321 | pop esi |
||
322 | pop edi |
||
323 | pop ebp |
||
324 | ret |
||
325 | |||
326 | align 4 |
||
327 | blit_copy_32_bgr: |
||
328 | mov ebx, 1 |
||
329 | |||
330 | align 4 |
||
331 | blit_copy_32: |
||
332 | |||
2434 | Serge | 333 | .outer32: |
3232 | Serge | 334 | mov eax, [esp+.x_y] |
335 | mov [esp+.tmp_x_y], eax |
||
2434 | Serge | 336 | xor ecx, ecx |
337 | align 4 |
||
338 | .inner32: |
||
339 | cmp [ebp+ecx], bl |
||
2465 | Serge | 340 | jne .skip |
2434 | Serge | 341 | ;-------------------------------------- |
342 | mov eax, [esi+ecx*4] |
||
343 | |||
2465 | Serge | 344 | ; check for hardware cursor |
345 | cmp [_display.select_cursor], select_cursor |
||
346 | je @f |
||
347 | cmp [_display.select_cursor], 0 |
||
348 | jne .no_mouseunder |
||
349 | ;-------------------------------------- |
||
350 | align 4 |
||
351 | @@: |
||
2434 | Serge | 352 | push ecx |
3232 | Serge | 353 | mov ecx, [esp+4+.tmp_x_y] |
2434 | Serge | 354 | |
355 | ; check mouse area for putpixel |
||
356 | call [_display.check_mouse] |
||
357 | pop ecx |
||
3232 | Serge | 358 | |
2465 | Serge | 359 | ;-------------------------------------- |
360 | align 4 |
||
361 | .no_mouseunder: |
||
2434 | Serge | 362 | ; store to real LFB |
363 | mov [LFB_BASE+edi+ecx*4], eax |
||
364 | ;-------------------------------------- |
||
365 | align 4 |
||
2465 | Serge | 366 | .skip: |
3232 | Serge | 367 | add [esp+.tmp_x_y], dword 0x10000 |
2434 | Serge | 368 | inc ecx |
369 | dec edx |
||
370 | jnz .inner32 |
||
371 | |||
372 | add esi, [esp+BLITTER.stride] |
||
5577 | serge | 373 | add edi, [_display.lfb_pitch] |
2434 | Serge | 374 | add ebp, [_display.width] |
3232 | Serge | 375 | inc dword [esp+.x_y] |
2434 | Serge | 376 | |
377 | mov edx, [esp+BLITTER.w] |
||
378 | dec [esp+BLITTER.h] |
||
379 | jnz .outer32 |
||
380 | |||
3232 | Serge | 381 | jmp blit_32.done |
2434 | Serge | 382 | |
2987 | Serge | 383 | |
3232 | Serge | 384 | align 4 |
385 | blit_trans_32_bgr: |
||
386 | mov ebx, 1 |
||
2434 | Serge | 387 | |
388 | align 4 |
||
3232 | Serge | 389 | blit_trans_32: |
390 | |||
391 | .outer32: |
||
392 | mov eax, [esp+.x_y] |
||
393 | mov [esp+.tmp_x_y], eax |
||
2434 | Serge | 394 | xor ecx, ecx |
395 | |||
396 | align 4 |
||
3232 | Serge | 397 | .inner32: |
398 | |||
2434 | Serge | 399 | cmp [ebp+ecx], bl |
3232 | Serge | 400 | jne .skip |
2434 | Serge | 401 | ;-------------------------------------- |
402 | mov eax, [esi+ecx*4] |
||
3232 | Serge | 403 | test eax, 0xFF000000 |
404 | jz .skip |
||
2434 | Serge | 405 | |
2465 | Serge | 406 | ; check for hardware cursor |
407 | cmp [_display.select_cursor], select_cursor |
||
408 | je @f |
||
409 | cmp [_display.select_cursor], 0 |
||
3232 | Serge | 410 | jne .no_mouseunder |
2465 | Serge | 411 | ;-------------------------------------- |
412 | align 4 |
||
413 | @@: |
||
2434 | Serge | 414 | push ecx |
415 | |||
3232 | Serge | 416 | mov ecx, [esp+4+.tmp_x_y] |
2434 | Serge | 417 | |
418 | ; check mouse area for putpixel |
||
419 | call [_display.check_mouse] |
||
420 | pop ecx |
||
2465 | Serge | 421 | ;-------------------------------------- |
422 | align 4 |
||
3232 | Serge | 423 | .no_mouseunder: |
424 | ; store to real LFB |
||
425 | mov [LFB_BASE+edi+ecx*4], eax |
||
2434 | Serge | 426 | ;-------------------------------------- |
427 | align 4 |
||
3232 | Serge | 428 | .skip: |
429 | add [esp+.tmp_x_y], dword 0x10000 |
||
2434 | Serge | 430 | inc ecx |
431 | dec edx |
||
3232 | Serge | 432 | jnz .inner32 |
2434 | Serge | 433 | |
434 | add esi, [esp+BLITTER.stride] |
||
5577 | serge | 435 | add edi, [_display.lfb_pitch] |
2434 | Serge | 436 | add ebp, [_display.width] |
3232 | Serge | 437 | inc dword [esp+.x_y] |
2434 | Serge | 438 | |
439 | mov edx, [esp+BLITTER.w] |
||
440 | dec [esp+BLITTER.h] |
||
3232 | Serge | 441 | jnz .outer32 |
2434 | Serge | 442 | |
3232 | Serge | 443 | jmp blit_32.done=>>=>> |