Font smoothing options

git-svn-id: svn://kolibrios.org@5847 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2015-10-15 15:16:30 +00:00
parent f8bce77141
commit fbdb5951a3
2 changed files with 72 additions and 89 deletions

View File

@ -249,44 +249,44 @@ drawChar:
inc esi
cmp [fontSmoothing], 0
jz .nextPixel
.checkLeftSubP: ; subpixel smoothing
.checkLeftSM: ; smoothing
bsf eax, edx
dec eax
js .checkRightSubP
js .checkRightSM
bt [ebx], eax
jc .checkRightSubP
jc .checkRightSM
dec eax
js .checkLeftDownSubP
js .checkLeftDownSM
bt [ebx], eax
jc .checkRightSubP
.checkLeftDownSubP:
jc .checkRightSM
.checkLeftDownSM:
inc eax
bt [ebx+1], eax
jnc .checkLeftUpSubP
jnc .checkLeftUpSM
inc eax
bt [ebx+1], eax
jnc @f
bt [ebx-1], eax
jc .checkRightSubP
jc .checkRightSM
dec eax
dec eax
js @f
bt [ebx+1], eax
jnc @f
inc eax
.checkLeftUpSubP:
.checkLeftUpSM:
bt [ebx-1], eax
jnc .checkRightSubP
jnc .checkRightSM
inc eax
bt [ebx-1], eax
jnc @f
bt [ebx+1], eax
jc .checkRightSubP
jc .checkRightSM
dec eax
dec eax
js @f
bt [ebx-1], eax
jc .checkRightSubP
jc .checkRightSM
@@:
mov ecx, [esp+20+deltaToScreen]
mov eax, [edi-4]
@ -301,6 +301,11 @@ drawChar:
push ebx edx
mov ebx, ebp
xor ecx, ecx
cmp [fontSmoothing], 1
jnz .subpixelLeft
call antiAliasing
jmp @f
.subpixelLeft:
mov cl, bl
lea edx, [ecx*8+ecx]
lea edx, [ecx*2+edx]
@ -332,9 +337,10 @@ drawChar:
shr ecx, 3
mov al, cl
rol eax, 16
@@:
mov [edi-4], eax
pop edx ebx
.checkRightSubP:
.checkRightSM:
bsf eax, edx
inc eax
bt [ebx], eax
@ -343,9 +349,9 @@ drawChar:
bt [ebx], eax
jc .nextPixel
dec eax
.checkRightDownSubP:
.checkRightDownSM:
bt [ebx+1], eax
jnc .checkRightUpSubP
jnc .checkRightUpSM
dec eax
bt [ebx+1], eax
jnc @f
@ -356,7 +362,7 @@ drawChar:
bt [ebx+1], eax
jnc @f
dec eax
.checkRightUpSubP:
.checkRightUpSM:
bt [ebx-1], eax
jnc .nextPixel
dec eax
@ -382,6 +388,11 @@ drawChar:
push ebx edx
mov ebx, ebp
xor ecx, ecx
cmp [fontSmoothing], 1
jnz .subpixelRight
call antiAliasing
jmp @f
.subpixelRight:
mov cl, al
mov edx, ecx
shl ecx, 3
@ -413,6 +424,7 @@ drawChar:
shr edx, 4
mov al, dl
rol eax, 16
@@:
mov [edi+4], eax
pop edx ebx
jmp .nextPixel
@ -756,7 +768,25 @@ drawChar:
jnz drawChar
ret
fontSmoothing db 1
antiAliasing:
mov bp, 3
@@:
mov cl, al
mov dl, bl
lea ecx, [ecx*2+ecx]
add ecx, edx
shr ecx, 2
mov al, cl
ror eax, 8
ror ebx, 8
dec bp
jnz @b
ror eax, 8
ror ebx, 8
mov ebp, ebx
ret
fontSmoothing db 2
font1:
if lang eq sp
file 'char_sp.mt'

View File

@ -30,11 +30,8 @@ uglobal
draw_limits RECT
endg
align 4
;------------------------------------------------------------------------------
syscall_draw_window: ;///// system function 0 /////////////////////////////////
;------------------------------------------------------------------------------
;? <description>.
;------------------------------------------------------------------------------
mov eax, edx
shr eax, 24
@ -53,18 +50,14 @@ syscall_draw_window: ;///// system function 0 /////////////////////////////////
call drawwindow_I
jmp window._.draw_window_caption.2
;--------------------------------------
align 4
@@:
dec al
jnz @f
; type II - only reserve area, no draw
; call sys_window_mouse
; call [draw_pointer]
call __sys_draw_pointer
jmp .exit
;--------------------------------------
align 4
@@:
dec al
jnz @f
@ -72,11 +65,9 @@ align 4
; type III - new style
call drawwindow_III
jmp window._.draw_window_caption.2
; type IV & V - skinned window (resizable & not)
;--------------------------------------
align 4
@@:
; type IV & V - skinned window (resizable & not)
mov eax, [TASK_COUNT]
movzx eax, word[WIN_POS + eax * 2]
cmp eax, [CURRENT_TASK]
@ -86,12 +77,9 @@ align 4
call drawwindow_IV
jmp window._.draw_window_caption.2
;--------------------------------------
align 4
.exit:
ret
;------------------------------------------------------------------------------
align 4
;------------------------------------------------------------------------------
syscall_display_settings: ;///// system function 48 ///////////////////////////
;------------------------------------------------------------------------------
;; Redraw screen:
@ -135,45 +123,35 @@ syscall_display_settings: ;///// system function 48 ///////////////////////////
;< ecx = pointer to FileInfoBlock struct
;> eax = FS error code
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Set font smoothing:
;; Get font smoothing:
;< ebx = 9
;< ecx = 0 (off) or !0 (on)
;> eax = 0 off, 1 on, 2 subpixel
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Set font smoothing:
;< ebx = 10
;< ecx = 0 off, 1 on, 2 subpixel
;------------------------------------------------------------------------------
cmp ebx, .sizeof.ftable / 4
ja @f
jmp [.ftable + ebx * 4]
;--------------------------------------
align 4
@@:
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.00:
xor eax, eax
inc ebx
cmp [windowtypechanged], ebx
jne .exit
jne @f
mov [windowtypechanged], eax
jmp syscall_display_settings._.redraw_whole_screen
;--------------------------------------
align 4
.exit:
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.01:
and ecx, 1
cmp ecx, [buttontype]
je .exit
je @f
mov [buttontype], ecx
mov [windowtypechanged], ebx
;--------------------------------------
align 4
.exit:
@@:
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.02:
dec ebx
mov esi, ecx
@ -187,7 +165,6 @@ syscall_display_settings.02:
mov [windowtypechanged], ebx
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.03:
mov edi, ecx
cmp edx, 192
@ -199,13 +176,11 @@ syscall_display_settings.03:
rep movsb
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.04:
mov eax, [_skinh]
mov [esp + 32], eax
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.05:
mov eax, [screen_workarea.left - 2]
mov ax, word[screen_workarea.right]
@ -215,10 +190,8 @@ syscall_display_settings.05:
mov [esp + 20], eax
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.06:
xor esi, esi
mov edi, [_display.width]
dec edi
mov eax, ecx
@ -230,19 +203,13 @@ syscall_display_settings.06:
or eax, eax
jge @f
xor eax, eax
;--------------------------------------
align 4
@@:
mov [screen_workarea.left], eax
cmp ebx, edi
jle @f
mov ebx, edi
;--------------------------------------
align 4
@@:
mov [screen_workarea.right], ebx
;--------------------------------------
align 4
.check_horizontal:
mov edi, [_display.height]
dec edi
@ -255,59 +222,48 @@ align 4
or eax, eax
jge @f
xor eax, eax
;--------------------------------------
align 4
@@:
mov [screen_workarea.top], eax
cmp ebx, edi
jle @f
mov ebx, edi
;--------------------------------------
align 4
@@:
mov [screen_workarea.bottom], ebx
;--------------------------------------
align 4
.check_if_redraw_needed:
or esi, esi
jz .exit
jz @f
call repos_windows
jmp syscall_display_settings._.calculate_whole_screen
;--------------------------------------
align 4
.exit:
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.07:
mov eax, [_skinmargins + 0]
mov [esp + 32], eax
mov eax, [_skinmargins + 4]
mov [esp + 20], eax
@@:
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.08:
mov ebx, ecx
call read_skin_file
mov [esp + 32], eax
test eax, eax
jnz .exit
jnz @b
call syscall_display_settings._.calculate_whole_screen
jmp syscall_display_settings._.redraw_whole_screen
;--------------------------------------
align 4
.exit:
;------------------------------------------------------------------------------
syscall_display_settings.09:
xor eax, eax
mov al, [fontSmoothing]
mov [esp + 32], eax
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings.09:
syscall_display_settings.10:
mov [fontSmoothing], cl
ret
;------------------------------------------------------------------------------
align 4
syscall_display_settings._.calculate_whole_screen:
xor eax, eax
xor ebx, ebx
@ -317,7 +273,6 @@ syscall_display_settings._.calculate_whole_screen:
dec edx
jmp calculatescreen
;------------------------------------------------------------------------------
align 4
syscall_display_settings._.redraw_whole_screen:
xor eax, eax
mov [draw_limits.left], eax
@ -331,8 +286,6 @@ syscall_display_settings._.redraw_whole_screen:
mov eax, window_data
jmp redrawscreen
;------------------------------------------------------------------------------
align 4
;------------------------------------------------------------------------------
syscall_set_window_shape: ;///// system function 50 ///////////////////////////
;------------------------------------------------------------------------------
;; Set window shape address:
@ -1447,7 +1400,7 @@ sys_window_moving_handler: ;///////////////////////////////////////////////////
iglobal
FuncTable syscall_display_settings, ftable, \
00, 01, 02, 03, 04, 05, 06, 07, 08, 09
00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10
align 4
window_topleft dd \