From edb11c7e8a0e6a42853ccdeca7b67793fd9d9a8f Mon Sep 17 00:00:00 2001 From: IgorA Date: Mon, 12 Sep 2011 22:34:41 +0000 Subject: [PATCH] 'buf2d.obj' functions 'buf_rect_by_size' and 'buf_filled_rect_by_size' work faster (optimize function 'buf_line_h') git-svn-id: svn://kolibrios.org@2177 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../develop/libraries/buf2d/trunk/buf2d.asm | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/programs/develop/libraries/buf2d/trunk/buf2d.asm b/programs/develop/libraries/buf2d/trunk/buf2d.asm index 7d9c61f41a..d526caff48 100644 --- a/programs/develop/libraries/buf2d/trunk/buf2d.asm +++ b/programs/develop/libraries/buf2d/trunk/buf2d.asm @@ -1068,19 +1068,44 @@ proc buf_line_h, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword cmp buf2d_bits,24 jne .end24 - mov ebx,dword[coord_x0] mov ecx,dword[coord_y0] - mov edx,dword[color] + bt ecx,31 + jc .end24 ;если координата y0 отрицательная + cmp ecx,buf2d_h + jge .end24 ;если координата y0 больше высоты буфера + + mov ebx,dword[coord_x0] mov esi,dword[coord_x1] cmp ebx,esi jle @f xchg ebx,esi ;если x0 > x1 то меняем местами x0 и x1 + @@: + cmp esi,buf2d_w + jl @f + mov esi,buf2d_w + ;dec esi + @@: + ;в eax вычисляем начало 1-й точки линии в буфере изображения + mov eax,buf2d_w ;size x + imul eax,ecx ;size_x*y + add eax,ebx ;size_x*y+x + lea eax,[eax+eax*2] ;(size_x*y+x)*3 + add eax,buf2d_data ;ptr+(size_x*y+x)*3 + + mov edx,dword[color] @@: ;цикл по оси x от x0 до x1 cmp ebx,esi jge @f - call draw_pixel - inc ebx + bt ebx,31 + jc .otr_x + mov word[eax],dx ;copy pixel color + ror edx,16 + mov byte[eax+2],dl + ror edx,16 + .otr_x: + add eax,3 + inc ebx jmp @b @@: .end24: