new fast algoritm for undo,

optimize code

git-svn-id: svn://kolibrios.org@6355 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2016-03-17 19:03:33 +00:00
parent ac1294b91a
commit 5f7bdd499c
3 changed files with 97 additions and 308 deletions

View File

@ -3,7 +3,7 @@
;--------------------------------------------- ;---------------------------------------------
mouse: mouse:
or ecx,-1 or ecx,-1
mcall 9,procinfo mcall SF_THREAD_INFO,procinfo
mov eax,[procinfo+70] ;staus of window mov eax,[procinfo+70] ;staus of window
test eax,100b test eax,100b
@ -210,47 +210,28 @@ mouse_in_work_arrea:
cmp [Activate_instrument],0 cmp [Activate_instrument],0
jnz no_undo___ jnz no_undo___
;------------begin copy for undo------------- ;------------begin copy for undo-------------
inc [number_undo] ;copy bufer number 2 to bufer number 0
cmp [number_undo],1 mov edi,[PointerToCopyPicture2]
jne no_one__ mov esi,[PointerToPicture]
mov ecx,[Picture_SizeX]
mov edi,[PointerToCopyPicture] imul ecx,[Picture_SizeY]
lea ecx,[ecx+ecx*2]
no_one__: mov ebx,ecx
cmp [number_undo],2 shr ecx,2
jne no_two__
mov edi,[PointerToCopyPicture2]
no_two__:
cmp [number_undo],3
jne no_three__
;copy bufer number two to bufer number one
mov esi,[PointerToCopyPicture2]
mov edi,[PointerToCopyPicture]
mov ecx,[Picture_SizeX]
imul ecx,[Picture_SizeY]
lea ecx,[ecx+ecx*2]
add ecx,4
shr ecx,2
inc ecx
cld cld
rep movsd rep movsd
;end copy mov ecx,ebx
dec [number_undo] and ecx,3
mov edi,[PointerToCopyPicture2] rep movsb
;call MovePictureToWorkScreen
no_three__: ;rotate bufers +1
mov esi,[PointerToPicture] and [number_undo],0 ;erase all undo
mov ecx,[Picture_SizeX] mov eax,[PointerToPicture]
imul ecx,[Picture_SizeY] mov ebx,[PointerToCopyPicture]
lea ecx,[ecx+ecx*2] mov ecx,[PointerToCopyPicture2]
add ecx,4 mov [PointerToPicture],ecx
shr ecx,2 mov [PointerToCopyPicture],eax
inc ecx mov [PointerToCopyPicture2],ebx
cld
rep movsd
;--------------end copy for undo------------- ;--------------end copy for undo-------------
no_undo___: no_undo___:
call TakeButtonInstruments call TakeButtonInstruments
@ -263,7 +244,7 @@ no_use_instruments:
;---------get mouse cordinats------------------- ;---------get mouse cordinats-------------------
;----------------------------------------------- ;-----------------------------------------------
GetMouseCoordinats: GetMouseCoordinats:
mcall 37,1 mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
mov ebx,eax mov ebx,eax
shr eax,16 shr eax,16
and ebx,0xffff and ebx,0xffff
@ -274,5 +255,5 @@ GetMouseCoordinats:
;-------get mouse attributs---------------------- ;-------get mouse attributs----------------------
;------------------------------------------------ ;------------------------------------------------
GetMouseClick: GetMouseClick:
mcall 37,2 mcall SF_MOUSE_GET,SSF_BUTTON
ret ret

View File

@ -95,6 +95,61 @@ local .horizontal_width_save
jnz .next_color_save jnz .next_color_save
} }
macro draw_calc_pixels brush
{
local .next_pixel_put
local .vertical_width
local .horizontal_width
local .no_draw_pixel
mov ebx,[ReserveArray]
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
add edi,brush
.next_pixel_put:
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
mov [counter2],5
.vertical_width:
mov [counter],5
.horizontal_width:
xor ecx,ecx
mov cl,byte[edi+ebp]
test cl,cl
jz .no_draw_pixel
mov [eax],si
mov [eax+2],dl
.no_draw_pixel:
add eax,3
inc ebp
dec [counter]
jnz .horizontal_width
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
dec [counter2]
jnz .vertical_width
pop ecx
pop eax
add ebx,4
dec ecx
jnz .next_pixel_put
}
;----------------------------------------------------------- ;-----------------------------------------------------------
;-----instruments of panel(icon's instruments)-------------- ;-----instruments of panel(icon's instruments)--------------
;----------------------------------------------------------- ;-----------------------------------------------------------
@ -723,56 +778,9 @@ TakeButtonInstruments:
square_width_save square_width_save
;draw calculated pixels on work arrea ;draw calculated pixels on work arrea
mov ebx,[ReserveArray] draw_calc_pixels width_pixels
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_line:
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
vertical_width:
and [counter],0
horizontal_width:
xor ecx,ecx
mov cl,byte[width_pixels+edi+ebp]
test cl,cl
jz no_draw_pixel_line
mov [eax],si
mov [eax+2],dl
no_draw_pixel_line:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_line
call MovePictureToWorkScreen call MovePictureToWorkScreen
jmp still jmp still
no_line: no_line:
@ -835,53 +843,7 @@ TakeButtonInstruments:
square_width_save square_width_save
;draw calculated pixels on work arrea ;draw calculated pixels on work arrea
mov ebx,[ReserveArray] draw_calc_pixels width_pixels_rectangle
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_rectangle:
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
vertical_width_rectangle:
and [counter],0
horizontal_width_rectangle:
xor ecx,ecx
mov cl,byte[width_pixels_rectangle+edi+ebp]
test cl,cl
jz no_draw_pixel_rectangle
mov [eax],si
mov [eax+2],dl
no_draw_pixel_rectangle:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width_rectangle
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_rectangle
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_rectangle
call MovePictureToWorkScreen call MovePictureToWorkScreen
jmp still jmp still
@ -1033,53 +995,7 @@ TakeButtonInstruments:
square_width_save square_width_save
;draw calculated pixels on work arrea ;draw calculated pixels on work arrea
mov ebx,[ReserveArray] draw_calc_pixels width_pixels
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_circle:
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
vertical_width_circle:
and [counter],0
horizontal_width_circle:
xor ecx,ecx
mov cl,byte[width_pixels+edi+ebp]
test cl,cl
jz no_draw_pixel_circle
mov [eax],si
mov [eax+2],dl
no_draw_pixel_circle:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width_circle
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_circle
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_circle
call MovePictureToWorkScreen call MovePictureToWorkScreen
jmp still jmp still
@ -1715,53 +1631,7 @@ TakeButtonInstruments:
square_width_save square_width_save
;draw calculated pixels on work arrea ;draw calculated pixels on work arrea
mov ebx,[ReserveArray] draw_calc_pixels width_pixels
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_konture:
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
vertical_width_konture:
and [counter],0
horizontal_width_konture:
xor ecx,ecx
mov cl,byte[width_pixels+edi+ebp]
test cl,cl
jz no_draw_pixel_konture
mov [eax],si
mov [eax+2],dl
no_draw_pixel_konture:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width_konture
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_konture
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_konture
mov eax,[ScreenX] mov eax,[ScreenX]
mov ebx,[ScreenY] mov ebx,[ScreenY]
@ -1913,53 +1783,7 @@ TakeButtonInstruments:
square_width_save square_width_save
;draw calculated pixels on work arrea ;draw calculated pixels on work arrea
mov ebx,[ReserveArray] draw_calc_pixels width_pixels
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
next_pixel_put_ellips:
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
vertical_width_ellips:
and [counter],0
horizontal_width_ellips:
xor ecx,ecx
mov cl,byte[width_pixels+edi+ebp]
test cl,cl
jz no_draw_pixel_ellips
mov [eax],si
mov [eax+2],dl
no_draw_pixel_ellips:
add eax,3
inc ebp
inc [counter]
cmp [counter],5
jne horizontal_width_ellips
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],5
jne vertical_width_ellips
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_ellips
call MovePictureToWorkScreen call MovePictureToWorkScreen
jmp still jmp still

View File

@ -255,47 +255,31 @@ no_save:
cmp [number_menu],5 cmp [number_menu],5
jne no_exit_program jne no_exit_program
mov eax,-1 mcall SF_TERMINATE_PROCESS
mcall
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
no_exit_program: no_exit_program:
no_file: no_file:
;|||||||||||||||||||||||||||||EDIT||||||||||||||||||||||||| ;|||||||||||||||||||||||||||||EDIT|||||||||||||||||||||||||
;<<<<<<<<<<UNDO>>>>>>>>>> ;<<<<<<<<<<UNDO>>>>>>>>>>
cmp [number_panel],6 cmp [number_panel],6
jne still ;no_edit jne still ;no_edit
cmp [number_menu],1 cmp [number_menu],1
jne no_undo jne no_undo
cmp [number_undo],1 cmp [number_undo],2 ;2 - maximum undo count
jne no_one____ jge no_undo
mov esi,[PointerToCopyPicture] ;rotate bufers -1
inc [number_undo]
mov eax,[PointerToPicture]
mov ebx,[PointerToCopyPicture]
mov ecx,[PointerToCopyPicture2]
mov [PointerToPicture],ebx
mov [PointerToCopyPicture],ecx
mov [PointerToCopyPicture2],eax
no_one____: call MovePictureToWorkScreen
cmp [number_undo],2
jne no_two____
mov esi,[PointerToCopyPicture2]
no_two____:
mov edi,[PointerToPicture]
mov ecx,[Picture_SizeX]
imul ecx,[Picture_SizeY]
lea ecx,[ecx+ecx*2]
add ecx,4
shr ecx,2
cld
rep movsd
call MovePictureToWorkScreen
dec [number_undo]
jnz no_null_undo
mov [number_undo],1
no_null_undo:
and [number_panel],0 and [number_panel],0
and [number_menu],0 and [number_menu],0
jmp still jmp still