blitter optimization

git-svn-id: svn://kolibrios.org@2988 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2012-10-12 18:30:58 +00:00
parent 9ebd3255c3
commit dfe456e039

View File

@ -14,8 +14,8 @@ ends
struct BLITTER struct BLITTER
dc BLITTER_BLOCK dc RECT
sc BLITTER_BLOCK sc RECT
dst_x dd ? ; 32 dst_x dd ? ; 32
dst_y dd ? ; 36 dst_y dd ? ; 36
src_x dd ? ; 40 src_x dd ? ; 40
@ -28,145 +28,84 @@ struct BLITTER
ends ends
align 4
__L1OutCode:
push ebx
mov ebx, 8
cmp edx, [eax]
jl .L2
xor ebx, ebx
cmp edx, [eax+8]
setg bl
sal ebx, 2
.L2:
cmp ecx, [eax+4]
jge .L3
or ebx, 1
jmp .L4
.L3:
cmp ecx, [eax+12]
jle .L4
or ebx, 2
.L4:
mov eax, ebx
pop ebx
ret
align 4 align 4
block_clip: block_clip:
push ebp ;esi= clip RECT ptr
push edi ;edi= RECT ptr
push esi ;return code:
;eax= 0 - draw, 1 - don't draw
push ebx push ebx
sub esp, 4
mov ebx, eax mov eax, [edi+RECT.left]
mov [esp], edx mov ebx, [edi+RECT.right]
mov ebp, ecx mov ecx, [esi+RECT.left] ;clip.left
mov ecx, [ecx] mov edx, [esi+RECT.right] ;clip.right
mov edx, [edx]
call __L1OutCode
mov esi, eax cmp eax, edx ;left >= clip.right
mov edx, [esp+28] jge .fail
mov ecx, [edx]
.L21:
mov eax, [esp+24]
mov edx, [eax]
mov eax, ebx
call __L1OutCode
mov edi, eax cmp ebx, ecx ;right < clip.left
.L20: jl .fail
mov eax, edi
and eax, esi cmp eax, ecx ;left >= clip.left
jne .L9 jae @F
cmp esi, edi
je .L9 mov eax, ecx
test esi, esi @@:
jne .L10 mov [edi+RECT.left], eax
test edi, 1
je .L11 cmp ebx, edx ;right <= clip.right
mov eax, [ebx+4] jle @f
jmp .L25 mov ebx, edx
.L11: @@:
test edi, 2 mov [edi+RECT.right], ebx
je .L13
mov eax, [ebx+12] mov eax, [edi+RECT.top]
.L25: mov ebx, [edi+RECT.bottom]
mov edx, [esp+28] mov ecx, [esi+RECT.top] ;clip.top
jmp .L22 mov edx, [esi+RECT.bottom] ;clip.bottom
.L13:
test edi, 4 cmp eax, edx ;top >= clip.bottom
je .L14 jge .fail
mov eax, [ebx+8]
jmp .L26 cmp ebx, ecx ;bottom < clip.top
.L14: jl .fail
and edi, 8
je .L12 cmp eax, ecx ;top >= clip.top
mov eax, [ebx] jae @F
.L26:
mov edx, [esp+24] mov eax, ecx
.L22: @@:
mov [edx], eax mov [edi+RECT.top], eax
.L12:
mov eax, [esp+28] cmp ebx, edx ;bottom <= clip.bottom
mov ecx, [eax] jle @f
jmp .L21 mov ebx, edx
.L10: @@:
test esi, 1 mov [edi+RECT.bottom], ebx
je .L16
mov eax, [ebx+4]
jmp .L23
.L16:
test esi, 2
je .L18
mov eax, [ebx+12]
.L23:
mov [ebp+0], eax
jmp .L17
.L18:
test esi, 4
je .L19
mov eax, [ebx+8]
jmp .L24
.L19:
and esi, 8
je .L17
mov eax, [ebx]
.L24:
mov edx, [esp]
mov [edx], eax
.L17:
mov ecx, [ebp+0]
mov eax, [esp]
mov edx, [eax]
mov eax, ebx
call __L1OutCode
mov esi, eax
jmp .L20
.L9:
add esp, 4
pop ebx pop ebx
pop esi xor eax, eax
pop edi
pop ebp
ret ret
.fail:
pop ebx
mov eax, 1
ret
align 4 align 4
blit_clip: blit_clip:
.sx0 equ 36 .sx0 equ 8
.sy0 equ 32 .sy0 equ 12
.sx1 equ 28 .sx1 equ 16
.sy1 equ 24 .sy1 equ 20
.dx0 equ 20 .dx0 equ 24
.dy0 equ 16 .dy0 equ 28
.dx1 equ 12 .dx1 equ 32
.dy1 equ 8 .dy1 equ 36
push edi push edi
@ -180,25 +119,17 @@ blit_clip:
mov eax, [ecx+BLITTER.src_y] mov eax, [ecx+BLITTER.src_y]
mov [esp+.sy0], eax mov [esp+.sy0], eax
add edx, [ecx+BLITTER.w] add edx, [ecx+BLITTER.w]
dec edx
mov [esp+.sx1], edx
add eax, [ecx+BLITTER.h] add eax, [ecx+BLITTER.h]
dec eax mov [esp+.sx1], edx
mov [esp+.sy1], eax mov [esp+.sy1], eax
lea ecx, [esp+.sy0] lea edi, [esp+.sx0]
lea edx, [esp+.sx0] lea esi, [ebx+BLITTER.sc]
lea eax, [ebx+BLITTER.sc]
lea esi, [esp+.sy1]
mov [esp+4], esi
lea esi, [esp+.sx1]
mov [esp], esi
call block_clip call block_clip
mov esi, 1
test eax, eax test eax, eax
jne .L28 mov esi, 1
jnz .done
mov edi, [esp+.sx0] mov edi, [esp+.sx0]
mov edx, [ebx+BLITTER.dst_x] mov edx, [ebx+BLITTER.dst_x]
@ -211,6 +142,7 @@ blit_clip:
add eax, ecx add eax, ecx
sub eax, [ebx+BLITTER.src_y] sub eax, [ebx+BLITTER.src_y]
mov [esp+.dy0], eax mov [esp+.dy0], eax
sub edx, edi sub edx, edi
add edx, [esp+.sx1] add edx, [esp+.sx1]
mov [esp+.dx1], edx mov [esp+.dx1], edx
@ -219,26 +151,20 @@ blit_clip:
add eax, [esp+.sy1] add eax, [esp+.sy1]
mov [esp+.dy1], eax mov [esp+.dy1], eax
lea ecx, [esp+.dy0] lea edi, [esp+.dx0]
lea edx, [esp+.dx0] lea esi, [ebx+BLITTER.dc]
lea eax, [esp+.dy1]
mov [esp+4], eax
lea eax, [esp+.dx1]
mov [esp], eax
mov eax, ebx
call block_clip call block_clip
test eax, eax test eax, eax
jne .L28 mov esi, 1
jnz .done
mov edx, [esp+.dx0] mov edx, [esp+.dx0]
mov eax, [esp+.dx1] mov eax, [esp+.dx1]
inc eax
sub eax, edx sub eax, edx
mov [ebx+BLITTER.w], eax mov [ebx+BLITTER.w], eax
mov eax, [esp+.dy0] mov eax, [esp+.dy0]
mov ecx, [esp+.dy1] mov ecx, [esp+.dy1]
inc ecx
sub ecx, eax sub ecx, eax
mov [ebx+BLITTER.h], ecx mov [ebx+BLITTER.h], ecx
@ -254,7 +180,7 @@ blit_clip:
mov [ebx+BLITTER.dst_x], edx mov [ebx+BLITTER.dst_x], edx
mov [ebx+BLITTER.dst_y], eax mov [ebx+BLITTER.dst_y], eax
xor esi, esi xor esi, esi
.L28: .done:
mov eax, esi mov eax, esi
add esp, 40 add esp, 40
pop ebx pop ebx
@ -274,10 +200,7 @@ purge .dy1
ret ret
align 4 align 4
blit_32: blit_32:
push ebp push ebp
push edi push edi
@ -288,22 +211,24 @@ blit_32:
mov eax, [TASK_BASE] mov eax, [TASK_BASE]
mov ebx, [eax-twdw + WDATA.box.width] mov ebx, [eax-twdw + WDATA.box.width]
mov edx, [eax-twdw + WDATA.box.height] mov edx, [eax-twdw + WDATA.box.height]
inc ebx
inc edx
xor eax, eax xor eax, eax
mov [esp+BLITTER.dc.xmin], eax mov [esp+BLITTER.dc.left], eax
mov [esp+BLITTER.dc.ymin], eax mov [esp+BLITTER.dc.top], eax
mov [esp+BLITTER.dc.xmax], ebx mov [esp+BLITTER.dc.right], ebx
mov [esp+BLITTER.dc.ymax], edx mov [esp+BLITTER.dc.bottom], edx
mov [esp+BLITTER.sc.xmin], eax mov [esp+BLITTER.sc.left], eax
mov [esp+BLITTER.sc.ymin], eax mov [esp+BLITTER.sc.top], eax
mov eax, [ecx+24] mov eax, [ecx+24]
dec eax
mov [esp+BLITTER.sc.xmax], eax mov [esp+BLITTER.sc.right], eax
mov eax, [ecx+28] mov eax, [ecx+28]
dec eax
mov [esp+BLITTER.sc.ymax], eax mov [esp+BLITTER.sc.bottom], eax
mov eax, [ecx] mov eax, [ecx]
mov [esp+BLITTER.dst_x], eax mov [esp+BLITTER.dst_x], eax
@ -429,7 +354,7 @@ align 4
.done: .done:
; call [draw_pointer] ; call [draw_pointer]
call __sys_draw_pointer ; call __sys_draw_pointer
.L57: .L57:
add esp, 72 add esp, 72
pop ebx pop ebx