X-Git-Url: https://eleni.mutantstargoat.com/git/?p=winnie;a=blobdiff_plain;f=src%2Ffbdev%2Fgfx.cc;h=422312c43211dd9c9279d63a414ccd0866759033;hp=742b6c687b48611461bfa537934e635dee65cb57;hb=59cd3a77c4517e387f4c2e21e8b62a9017370116;hpb=695cf39b73ecc76cbbc39e54f844ae55f4a9f938 diff --git a/src/fbdev/gfx.cc b/src/fbdev/gfx.cc index 742b6c6..422312c 100644 --- a/src/fbdev/gfx.cc +++ b/src/fbdev/gfx.cc @@ -20,6 +20,7 @@ static unsigned char *framebuffer; static int dev_fd = -1; static Rect screen_rect; + static int color_depth; // bits per pixel static Pixmap *pixmap; @@ -47,6 +48,8 @@ bool init_gfx() screen_rect.height = sinfo.yres_virtual; color_depth = sinfo.bits_per_pixel; + set_clipping_rect(screen_rect); + int sz = FRAMEBUFFER_SIZE(screen_rect.width, screen_rect.height, color_depth); framebuffer = (unsigned char*)mmap(0, sz, PROT_READ | PROT_WRITE, MAP_SHARED, dev_fd, 0); @@ -114,43 +117,6 @@ int get_color_depth() return color_depth; } -void clear_screen(int r, int g, int b) -{ - fill_rect(screen_rect, r, g, b); -} - -void fill_rect(const Rect &rect, int r, int g, int b) -{ - Rect drect = rect; - - if(drect.x < screen_rect.x) { - drect.width -= screen_rect.x - drect.x; - drect.x = screen_rect.x; - } - - 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; - 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