update functions 'buf2d_img_hdiv2', 'buf2d_img_wdiv2' and 'buf2d_bit_blt_transp'

git-svn-id: svn://kolibrios.org@2927 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2012-08-17 17:54:03 +00:00
parent 19109c0aad
commit ed2d3499be

View File

@ -1747,24 +1747,70 @@ align 4
proc buf_img_wdiv2, buf_struc:dword proc buf_img_wdiv2, buf_struc:dword
pushad pushad
mov edi,dword[buf_struc] mov edi,dword[buf_struc]
cmp buf2d_bits,8
jne @f
mov eax,buf2d_w
mov ecx,buf2d_h
imul ecx,eax
stdcall img_8b_wdiv2, buf2d_data,ecx
@@:
cmp buf2d_bits,24 cmp buf2d_bits,24
jne .end_draw_24 jne @f
mov eax,buf2d_w mov eax,buf2d_w
mov ecx,buf2d_h mov ecx,buf2d_h
imul ecx,eax imul ecx,eax
stdcall img_rgb24_wdiv2, buf2d_data,ecx stdcall img_rgb24_wdiv2, buf2d_data,ecx
.end_draw_24: @@:
cmp buf2d_bits,32 cmp buf2d_bits,32
jne .end_draw_32 jne @f
mov eax,buf2d_w mov eax,buf2d_w
mov ecx,buf2d_h mov ecx,buf2d_h
imul ecx,eax imul ecx,eax
stdcall img_rgb32_wdiv2, buf2d_data,ecx stdcall img_rgba32_wdiv2, buf2d_data,ecx
.end_draw_32: @@:
popad popad
ret ret
endp endp
;input:
;data_8b - pointer to rgb data
;size - count img pixels (size img data / 3(rgb) )
align 4
proc img_8b_wdiv2 data_8b:dword, size:dword
mov eax,dword[data_8b]
mov ecx,dword[size] ;ecx = size
cld
@@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
shr byte[eax],1
inc eax
loop @b
mov eax,dword[data_8b]
mov ecx,dword[size] ;ecx = size
shr ecx,1
@@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
mov bl,byte[eax+1] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
add byte[eax],bl
add eax,2
loop @b
mov eax,dword[data_8b]
inc eax
mov ebx,eax
inc ebx
mov ecx,dword[size] ;ecx = size
shr ecx,1
dec ecx ;«¨è­¨© ¯¨ªá¥«ì
@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
mov dl,byte[ebx]
mov byte[eax],dl
inc eax
add ebx,2
loop @b
ret
endp
;input: ;input:
;data_rgb - pointer to rgb data ;data_rgb - pointer to rgb data
;size - count img pixels (size img data / 3(rgb) ) ;size - count img pixels (size img data / 3(rgb) )
@ -1810,13 +1856,13 @@ proc img_rgb24_wdiv2 data_rgb:dword, size:dword
endp endp
;input: ;input:
;data_rgb - pointer to rgb data ;data_rgba - pointer to rgba data
;size - count img pixels (size img data / 3(rgb) ) ;size - count img pixels (size img data / 4(rgba) )
align 4 align 4
proc img_rgb32_wdiv2 data_rgb:dword, size:dword proc img_rgba32_wdiv2 data_rgba:dword, size:dword
mov eax,dword[data_rgb] mov eax,dword[data_rgba]
mov eax,dword[data_rgb] mov eax,dword[data_rgba]
mov ebx,eax mov ebx,eax
add ebx,4 add ebx,4
mov ecx,dword[size] ;ecx = size mov ecx,dword[size] ;ecx = size
@ -1828,7 +1874,7 @@ proc img_rgb32_wdiv2 data_rgb:dword, size:dword
add ebx,8 add ebx,8
loop @b loop @b
mov eax,dword[data_rgb] mov eax,dword[data_rgba]
add eax,4 add eax,4
mov ebx,eax mov ebx,eax
add ebx,4 add ebx,4
@ -1849,25 +1895,95 @@ align 4
proc buf_img_hdiv2, buf_struc:dword proc buf_img_hdiv2, buf_struc:dword
pushad pushad
mov edi,dword[buf_struc] mov edi,dword[buf_struc]
cmp buf2d_bits,8
jne @f
mov eax,buf2d_w
mov ecx,buf2d_h
imul ecx,eax
stdcall img_8b_hdiv2, buf2d_data,ecx,eax
@@:
cmp buf2d_bits,24 cmp buf2d_bits,24
jne .end_draw_24 jne @f
mov eax,buf2d_w mov eax,buf2d_w
mov ecx,buf2d_h mov ecx,buf2d_h
imul ecx,eax imul ecx,eax
stdcall img_rgb24_hdiv2, buf2d_data,ecx,eax stdcall img_rgb24_hdiv2, buf2d_data,ecx,eax
.end_draw_24: @@:
cmp buf2d_bits,32 cmp buf2d_bits,32
jne .end_draw_32 jne @f
mov eax,buf2d_w mov eax,buf2d_w
mov ecx,buf2d_h mov ecx,buf2d_h
imul ecx,eax imul ecx,eax
shl eax,2 shl eax,2
stdcall img_rgb32_hdiv2, buf2d_data,ecx,eax stdcall img_rgba32_hdiv2, buf2d_data,ecx,eax
.end_draw_32: @@:
popad popad
ret ret
endp endp
;input:
;data_8b - pointer to 8 bit data
;size - count img pixels (size img data)
;size_w - width img in pixels
align 4
proc img_8b_hdiv2, data_8b:dword, size:dword, size_w:dword
mov eax,dword[data_8b] ;eax =
mov ecx,dword[size]
cld
@@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
shr byte[eax],1
inc eax
loop @b
mov eax,dword[data_8b] ;eax =
mov esi,dword[size_w]
mov ebx,esi
add ebx,eax
mov ecx,dword[size] ;ecx = size
shr ecx,1
xor edi,edi
@@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
mov dl,byte[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
add byte[eax],dl
inc eax
inc ebx
inc edi
cmp edi,dword[size_w]
jl .old_line
add eax,esi
add ebx,esi
xor edi,edi
.old_line:
loop @b
mov eax,dword[data_8b] ;eax =
add eax,esi ;esi = width*3(rgb)
mov ebx,eax
add ebx,esi
mov ecx,dword[size] ;ecx = size
shr ecx,1
sub ecx,dword[size_w] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
xor edi,edi
@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
mov dl,byte[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
mov byte[eax],dl
inc eax
inc ebx
inc edi
cmp edi,dword[size_w]
jl .old_line_2
add ebx,esi
xor edi,edi
.old_line_2:
loop @b
ret
endp
;input: ;input:
;data_rgb - pointer to rgb data ;data_rgb - pointer to rgb data
;size - count img pixels (size img data / 3(rgb) ) ;size - count img pixels (size img data / 3(rgb) )
@ -1938,13 +2054,13 @@ proc img_rgb24_hdiv2, data_rgb:dword, size:dword, size_w:dword
endp endp
;input: ;input:
;data_rgb - pointer to rgb data ;data_rgba - pointer to rgba data
;size - count img pixels (size img data / 3(rgb) ) ;size - count img pixels (size img data / 4(rgba) )
;size_w_b - width img in bytes ;size_w_b - width img in bytes
align 4 align 4
proc img_rgb32_hdiv2, data_rgb:dword, size:dword, size_w_b:dword proc img_rgba32_hdiv2, data_rgba:dword, size:dword, size_w_b:dword
mov eax,dword[data_rgb] ;eax = mov eax,dword[data_rgba] ;eax =
mov ebx,dword[size_w_b] mov ebx,dword[size_w_b]
add ebx,eax add ebx,eax
mov ecx,dword[size] ;ecx = size mov ecx,dword[size] ;ecx = size
@ -1966,7 +2082,7 @@ proc img_rgb32_hdiv2, data_rgb:dword, size:dword, size_w_b:dword
loop @b loop @b
mov eax,dword[data_rgb] ;eax = mov eax,dword[data_rgba] ;eax =
mov ebx,dword[size_w_b] mov ebx,dword[size_w_b]
add eax,ebx add eax,ebx
add ebx,eax add ebx,eax
@ -2012,6 +2128,8 @@ endl
movzx esi,byte[ebx+3] movzx esi,byte[ebx+3]
cmp esi,255 cmp esi,255
je .c1z je .c1z
cmp edi,esi
je .c0_c1
;¯¥à¥¢®à ç¨¢ ¥¬ §­ ç¥­¨ï ¯à®§à ç­®á⥩ ;¯¥à¥¢®à ç¨¢ ¥¬ §­ ç¥­¨ï ¯à®§à ç­®á⥩
neg edi neg edi
@ -2072,6 +2190,17 @@ push eax ebx
pop ebx eax pop ebx eax
jmp .end_f jmp .end_f
.c0_c1: ;¥á«¨ ¯à®§à ç­®á⨠®¡®¨å 梥⮢ ᮢ¯ ¤ îâ
mov edx,dword[eax]
shr edx,1
and edx,011111110111111101111111b
mov esi,dword[ebx]
shr esi,1
and esi,011111110111111101111111b
add edx,esi
ror edi,8 ;¯¥à¥¬¥é ¥¬ §­ ç¥­¨¥ ¯à®§à ç­®á⨠¢ áâ à訩 ¡ ©â edi
or edx,edi
jmp .end_f
.c0z: ;¥á«¨ 梥⠢ eax ¯à®§à ç­ë© .c0z: ;¥á«¨ 梥⠢ eax ¯à®§à ç­ë©
mov edx,dword[ebx] mov edx,dword[ebx]
movzx edi,byte[ebx+3] movzx edi,byte[ebx+3]
@ -2423,7 +2552,7 @@ combine_colors_0:
align 4 align 4
proc buf_bit_blt_transp, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword proc buf_bit_blt_transp, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
locals locals
right_bytes dd ? lost_bytes dd ?
endl endl
pushad pushad
@ -2476,21 +2605,48 @@ proc buf_bit_blt_transp, buf_destination:dword, coord_x:dword, coord_y:dword, bu
sub ebx,eax sub ebx,eax
mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥ mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
mov [right_bytes],0 mov dword[lost_bytes],0
mov ecx,[coord_x] mov ecx,[coord_x]
cmp ecx,0
jge @f
neg ecx
;inc ecx
cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
shl ecx,2
mov [lost_bytes],ecx
add esi,ecx
shr ecx,2
sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
lea ecx,[ecx+ecx*2]
add edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
xor ecx,ecx
@@:
cmp ecx,ebx cmp ecx,ebx
jl @f jle @f
sub ecx,ebx sub ecx,ebx
sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à  add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã shl ecx,2 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
mov [right_bytes],ecx add [lost_bytes],ecx
@@: @@:
; mov [right_bytes],0
; mov ecx,[coord_x]
; cmp ecx,ebx
; jl @f
; sub ecx,ebx
; sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
; add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
; shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
; mov [right_bytes],ecx
; @@:
lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨ lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
cld cld
cmp [right_bytes],0 cmp [lost_bytes],0
jg .copy_1 jg .copy_1
.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥ .copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
mov ecx,eax mov ecx,eax
@ -2512,7 +2668,7 @@ proc buf_bit_blt_transp, buf_destination:dword, coord_x:dword, coord_y:dword, bu
add esi,4 add esi,4
loop @b loop @b
add edi,ebx add edi,ebx
add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã add esi,[lost_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
dec edx dec edx
cmp edx,0 cmp edx,0
jg .copy_1 jg .copy_1
@ -2632,7 +2788,7 @@ proc buf_bit_blt_alpha, buf_destination:dword, coord_x:dword, coord_y:dword, buf
;inc ecx ;inc ecx
cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨ cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w) jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
add [lost_bytes],ecx mov [lost_bytes],ecx
sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à  add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
add esi,ecx add esi,ecx