Subversion Repositories Kolibri OS

Rev

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