X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fgfx.cc;h=45c918befc4602d9300e797b76777ebbf4b5aed8;hb=d114b136897ca569d819da5f9b75bd08f9cbe2c0;hp=226d26954369b37c945bfe69dd6494bcb0b4a1d2;hpb=094e53b80e5576db6c86bb7dc6141b0cff7fa665;p=winnie diff --git a/src/gfx.cc b/src/gfx.cc index 226d269..45c918b 100644 --- a/src/gfx.cc +++ b/src/gfx.cc @@ -92,6 +92,14 @@ void clear_screen(int r, int g, int b) void fill_rect(const Rect &rect, int r, int g, int b) { + if(rect.x < 0) { + rect.x = 0; + } + + if(rect.y < 0) { + rect.y = 0; + } + 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; } - if(dest_y < screen_rect.y) { - dest_rect.y = screen_rect.y; + int yend = dest_y + height; + if(yend >= dest_rect.height) { + height -= yend - dest_rect.height; } - //TODO :p zzz + 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