advansed color blend for font smoothing

git-svn-id: svn://kolibrios.org@5839 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2015-10-11 12:44:21 +00:00
parent ffaece082b
commit ed1aad3b68

View File

@ -36,6 +36,9 @@ dtext:
mov ebp, [_display.width] mov ebp, [_display.width]
xor edi, edi xor edi, edi
jmp @f jmp @f
.ret:
add esp, 28
ret
.redirect: .redirect:
mov ebp, [edi] mov ebp, [edi]
add edi, 8 add edi, 8
@ -92,6 +95,7 @@ dtext:
bt ebx, 28 bt ebx, 28
jc .drawUTF8 jc .drawUTF8
; Stack map:
; char counter +0 ; char counter +0
fontMultiplier = 4 fontMultiplier = 4
widthX = 8 widthX = 8
@ -101,7 +105,7 @@ widthX = 8
; background +24 ; background +24
deltaToScreen = 28 deltaToScreen = 28
; temp buffer height +32 ; temp buffer height +32
; temp buffer +36 ; temp buffer pointer +36
.drawUTF16: .drawUTF16:
dec dword [esp] dec dword [esp]
@ -127,6 +131,7 @@ deltaToScreen = 28
add edi, esi add edi, esi
pop esi pop esi
jmp .drawUTF16 jmp .drawUTF16
.drawUTF8: .drawUTF8:
dec dword [esp] dec dword [esp]
js .done js .done
@ -166,6 +171,7 @@ deltaToScreen = 28
add edi, esi add edi, esi
pop esi pop esi
jmp .drawUTF8 jmp .drawUTF8
.draw866: .draw866:
dec dword [esp] dec dword [esp]
js .done js .done
@ -184,6 +190,7 @@ deltaToScreen = 28
add edi, esi add edi, esi
pop esi pop esi
jmp .draw866 jmp .draw866
.done: .done:
mov ecx, edi mov ecx, edi
pop eax eax eax esi edx ebx ebp ebp ebp pop eax eax eax esi edx ebx ebp ebp ebp
@ -192,7 +199,7 @@ deltaToScreen = 28
jnz @f jnz @f
pop eax pop eax
ret ret
@@: @@: ; redraw from buffer to screen
push eax push eax
sub ecx, edi sub ecx, edi
shr ecx, 2 shr ecx, 2
@ -224,10 +231,8 @@ deltaToScreen = 28
add esp, 12 add esp, 12
call kernel_free call kernel_free
ret ret
.ret:
add esp, 28
ret
; scaling/smoothing algorithm
drawChar: drawChar:
mov dl, [ebx] mov dl, [ebx]
.raw: .raw:
@ -244,7 +249,7 @@ drawChar:
inc esi inc esi
cmp [fontSmoothing], 0 cmp [fontSmoothing], 0
jz .nextPixel jz .nextPixel
.checkLeftSubP: .checkLeftSubP: ; subpixel smoothing
bsf eax, edx bsf eax, edx
dec eax dec eax
js .checkRightSubP js .checkRightSubP
@ -293,21 +298,42 @@ drawChar:
call syscall_getpixel call syscall_getpixel
popa popa
@@: @@:
mov ecx, eax push ebx edx
mov eax, ebp mov ebx, ebp
shr al, 1 xor ecx, ecx
shr cl, 1 mov cl, bl
add al, cl lea edx, [ecx*8+ecx]
shr ah, 2 lea edx, [ecx*2+edx]
shr ch, 2 mov cl, al
add ah, ch lea ecx, [ecx*4+ecx]
add ah, ch add edx, ecx
add ah, ch shr edx, 4
ror eax, 8 mov al, dl
ror ecx, 8
mov ah, ch xor ecx, ecx
rol eax, 8 mov cl, ah
lea edx, [ecx*8+ecx]
lea edx, [ecx*2+edx]
mov cl, bh
lea ecx, [ecx*4+ecx]
add edx, ecx
shr edx, 4
mov ah, dl
rol eax, 16
rol ebx, 16
xor ecx, ecx
mov cl, al
mov edx, ecx
shl ecx, 3
sub ecx, edx
mov dl, bl
add ecx, edx
shr ecx, 3
mov al, cl
rol eax, 16
mov [edi-4], eax mov [edi-4], eax
pop edx ebx
.checkRightSubP: .checkRightSubP:
bsf eax, edx bsf eax, edx
inc eax inc eax
@ -353,23 +379,45 @@ drawChar:
call syscall_getpixel call syscall_getpixel
popa popa
@@: @@:
mov ecx, eax push ebx edx
mov eax, ebp mov ebx, ebp
shr ah, 2 xor ecx, ecx
shr ch, 2 mov cl, al
add ah, ch mov edx, ecx
add ah, ch shl ecx, 3
add ah, ch sub ecx, edx
mov dl, bl
add ecx, edx
shr ecx, 3
mov al, cl mov al, cl
ror eax, 8
ror ecx, 8 xor ecx, ecx
shr ah, 1 mov cl, ah
shr ch, 1 lea edx, [ecx*8+ecx]
add ah, ch lea edx, [ecx*2+edx]
rol eax, 8 mov cl, bh
lea ecx, [ecx*4+ecx]
add edx, ecx
shr edx, 4
mov ah, dl
rol ebx, 16
rol eax, 16
xor ecx, ecx
mov cl, bl
lea edx, [ecx*8+ecx]
lea edx, [ecx*2+edx]
mov cl, al
lea ecx, [ecx*4+ecx]
add edx, ecx
shr edx, 4
mov al, dl
rol eax, 16
mov [edi+4], eax mov [edi+4], eax
pop edx ebx
jmp .nextPixel jmp .nextPixel
.square:
.square: ; scaling
mov eax, esi mov eax, esi
@@: @@:
mov [edi+eax*4], ebp mov [edi+eax*4], ebp
@ -405,6 +453,7 @@ drawChar:
bt [ebx-2], eax bt [ebx-2], eax
jc .downRightLow jc .downRightLow
jmp .downRightHigh jmp .downRightHigh
@@: @@:
bt [ebx-1], eax bt [ebx-1], eax
jc .checkLeftUp jc .checkLeftUp
@ -437,6 +486,7 @@ drawChar:
inc esi inc esi
mov edi, [esp] mov edi, [esp]
jmp .checkLeftUp jmp .checkLeftUp
.downRightHigh: .downRightHigh:
imul ecx, esi imul ecx, esi
shl ecx, 2 shl ecx, 2
@ -487,6 +537,7 @@ drawChar:
bt [ebx+2], eax bt [ebx+2], eax
jc .upRightLow jc .upRightLow
jmp .upRightHigh jmp .upRightHigh
@@: @@:
bt [ebx+1], eax bt [ebx+1], eax
jc .checkRight jc .checkRight
@ -515,6 +566,7 @@ drawChar:
jns .drawUpRight jns .drawUpRight
mov edi, [esp] mov edi, [esp]
jmp .checkRight jmp .checkRight
.upRightHigh: .upRightHigh:
imul ecx, esi imul ecx, esi
shl ecx, 2 shl ecx, 2
@ -563,6 +615,7 @@ drawChar:
bt [ebx-2], eax bt [ebx-2], eax
jc .downLeftLow jc .downLeftLow
jmp .downLeftHigh jmp .downLeftHigh
@@: @@:
bt [ebx-1], eax bt [ebx-1], eax
jc .checkRightUp jc .checkRightUp
@ -592,6 +645,7 @@ drawChar:
inc esi inc esi
mov edi, [esp] mov edi, [esp]
jmp .checkRightUp jmp .checkRightUp
.downLeftHigh: .downLeftHigh:
imul ecx, esi imul ecx, esi
shl ecx, 2 shl ecx, 2
@ -639,6 +693,7 @@ drawChar:
bt [ebx+2], eax bt [ebx+2], eax
jc .upLeftLow jc .upLeftLow
jmp .upLeftHigh jmp .upLeftHigh
@@: @@:
bt [ebx+1], eax bt [ebx+1], eax
jc .nextPixel jc .nextPixel
@ -663,6 +718,7 @@ drawChar:
dec ecx dec ecx
jns .drawUpLeft jns .drawUpLeft
jmp .nextPixel jmp .nextPixel
.upLeftHigh: .upLeftHigh:
imul ecx, esi imul ecx, esi
shl ecx, 2 shl ecx, 2
@ -690,6 +746,7 @@ drawChar:
btr edx, eax btr edx, eax
pop edi pop edi
jmp .raw jmp .raw
.nextRaw: .nextRaw:
inc ebx inc ebx
mov eax, [esp+16+widthX] mov eax, [esp+16+widthX]