Skip to content

Commit

Permalink
Terminal: Fix flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
fido2020 committed Feb 3, 2021
1 parent 6c5aeb1 commit 673f1cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 5 additions & 1 deletion Applications/Terminal/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,13 @@ int main(int argc, char** argv){
for(int i = 0; i < len; i++){
PrintChar(_buf[i]);
}

paintAll = true;
}

window->Paint();
if(paintAll){
window->Paint();
}

//poll(fds.data(), fds.size(), -1);
}
Expand Down
16 changes: 6 additions & 10 deletions LibLemon/src/gfx/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ namespace Lemon::Graphics{
int i = 0;

if(offset.y < 0){
i += offset.y;
i += -offset.y;
offset.y = 0;
}

for(; i < src->height && i < dest->height - offset.y; i++){
if(rowSize <= 0) return;

memcpy_optimized(dest->buffer + ((i+offset.y)*(dest->width*4) + offset.x*4), src->buffer + i*src->width*4 + rowOffset, rowSize);
memcpy_optimized(dest->buffer + ((i + offset.y) * (dest->width * 4) + offset.x * 4), src->buffer + i * src->width * 4 + rowOffset, rowSize);
}
}

Expand All @@ -250,27 +250,23 @@ namespace Lemon::Graphics{
int rowSize = srcWidth;

if(offset.x < 0){
rowOffset += abs(offset.x);
rowOffset -= offset.x;
rowSize += offset.x;
offset.x = 0;
}

if(rowOffset + rowSize >= src->width){
rowSize = src->width - rowOffset;
}

if(offset.x + rowSize >= dest->width){
rowSize = dest->width - offset.x;
}

if(rowSize <= 0 || rowOffset >= src->width) return;

int i = 0;

if(offset.y < 0){
i += abs(offset.y);
i -= offset.y;
offset.y = 0;
}

if(rowSize <= 0 || rowOffset >= src->width) return;

unsigned destPitch = dest->width << 2;
unsigned srcPitch = src->width << 2;
Expand Down
8 changes: 5 additions & 3 deletions LibLemon/src/gfx/sse2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,16 @@ memcpy_optimized:

.pad2: ; pad out the end
mov rcx, rdx
jz .ret
jz ._ret

.pad2l:
lodsd
stosd
loop .pad2l

._ret:
sfence
.ret:

ret

.largecpyloopua:
Expand Down Expand Up @@ -160,9 +161,10 @@ memcpy_optimized:
stosd
loop .pad2lua

sfence

.retua:
sfence
ret

memcpy_sse2:
Expand Down

0 comments on commit 673f1cf

Please sign in to comment.