X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fgfx.cc;h=5c04d1edb3b2856719071f2f0ea75d1d34842cf0;hb=5449bf8fbca1d2cfbefa0386df7109afb2a5aa34;hp=7b3513d139897e9b3e35e80c8b65540e80451d5d;hpb=f71618aebfa6b8754dd056689a6c5821b755972c;p=winnie diff --git a/src/gfx.cc b/src/gfx.cc index 7b3513d..5c04d1e 100644 --- a/src/gfx.cc +++ b/src/gfx.cc @@ -58,7 +58,12 @@ bool init_gfx() void destroy_gfx() { - close(dev_fd); + clear_screen(0, 0, 0); + + if(dev_fd != -1) { + close(dev_fd); + } + dev_fd = -1; munmap(framebuffer, FRAMEBUFFER_SIZE(screen_rect.width, screen_rect.height, color_depth)); @@ -87,7 +92,7 @@ void clear_screen(int r, int g, int b) void fill_rect(const Rect &rect, int r, int g, int b) { - unsigned char *fb = framebuffer + (rect.x + screen_rect.width * rect.y) * 4; + unsigned char *fb = framebuffer + (rect.x + screen_rect.width * rect.y) * 4; for(int i=0; i= dest_rect.width) { + width -= xend - dest_rect.width; + } + + int yend = dest_y + height; + if(yend >= dest_rect.height) { + height -= yend - dest_rect.height; + } + + if(width <= 0 || height <= 0) { + return; + } + + unsigned char *sptr = src_img + (src_rect.y * src_rect.width + src_rect.x) * 4; + unsigned char *dptr = dest_img + (dest_y * dest_rect.width + dest_x) * 4; + + for(int i=0; i= dest_rect.width) { + width -= xend - dest_rect.width; + } + + int yend = dest_y + height; + if(yend >= dest_rect.height) { + height -= yend - dest_rect.height; + } + + if(width <= 0 || height <= 0) { + return; + } + + unsigned char *sptr = src_img + (src_rect.y * src_rect.width + src_rect.x) * 4; + unsigned char *dptr = dest_img + (dest_y * dest_rect.width + dest_x) * 4; + + for(int i=0; i