X-Git-Url: https://eleni.mutantstargoat.com/git/?a=blobdiff_plain;f=src%2Ffbdev%2Fgfx.cc;h=2b1c32a6d3079570025b2204fb6073d1ab3219ac;hb=50e3f6daf627d72a500b07f053cb34f713f0c650;hp=00e18815c67b6190fc7780dc82d477f71b53055d;hpb=6dc42c0e7292d6d94de640ddd7de3ee5c808e9c2;p=winnie diff --git a/src/fbdev/gfx.cc b/src/fbdev/gfx.cc index 00e1881..2b1c32a 100644 --- a/src/fbdev/gfx.cc +++ b/src/fbdev/gfx.cc @@ -95,12 +95,22 @@ void fill_rect(const Rect &rect, int r, int g, int b) { Rect drect = rect; - if(drect.x < 0) { - drect.x = 0; + if(drect.x < screen_rect.x) { + drect.width -= screen_rect.x - drect.x; + drect.x = screen_rect.x; } - if(drect.y < 0) { - drect.y = 0; + if(drect.y < screen_rect.y) { + drect.height -= screen_rect.y - drect.y; + drect.y = screen_rect.y; + } + + if(drect.x + drect.width >= screen_rect.x + screen_rect.width) { + drect.width = screen_rect.width - drect.x; + } + + if(drect.y + drect.height >= screen_rect.y + screen_rect.height) { + drect.height = screen_rect.height - drect.y; } unsigned char *fb = framebuffer + (drect.x + screen_rect.width * drect.y) * 4;