X-Git-Url: https://eleni.mutantstargoat.com/git/?p=winnie;a=blobdiff_plain;f=src%2Ffbdev%2Fgfx.cc;h=e3677d44ead0c5aee1b6ec1a406b03377e5d3836;hp=74dec0c8725616859352ae7a8afa74e926279e31;hb=32869d8ffb64be82541f48166c5e73a6c4336135;hpb=2985bfa49497805b4760c066a6288c4b3752d145 diff --git a/src/fbdev/gfx.cc b/src/fbdev/gfx.cc index 74dec0c..e3677d4 100644 --- a/src/fbdev/gfx.cc +++ b/src/fbdev/gfx.cc @@ -20,6 +20,7 @@ static unsigned char *framebuffer; static int dev_fd; +static int rgb_order[3]; struct Graphics { Rect screen_rect; @@ -59,6 +60,10 @@ bool init_gfx() gfx->screen_rect.height = sinfo.yres_virtual; gfx->color_depth = sinfo.bits_per_pixel; + rgb_order[0] = sinfo.red.offset / 8; + rgb_order[1] = sinfo.green.offset / 8; + rgb_order[2] = sinfo.blue.offset / 8; + set_clipping_rect(gfx->screen_rect); int sz = FRAMEBUFFER_SIZE(gfx->screen_rect.width, gfx->screen_rect.height, gfx->color_depth); @@ -104,7 +109,7 @@ bool init_gfx() void destroy_gfx() { clear_screen(0, 0, 0); - gfx_update(); + gfx_update(gfx->screen_rect); if(dev_fd != -1) { close(dev_fd); @@ -161,9 +166,17 @@ void set_cursor_visibility(bool visible) } } -void gfx_update() +void gfx_update(const Rect &upd_rect) { - memcpy(framebuffer, gfx->pixmap->pixels, gfx->pixmap->width * gfx->pixmap->height * (gfx->color_depth / 8)); + Rect rect = rect_intersection(upd_rect, gfx->screen_rect); + unsigned char *sptr = gfx->pixmap->pixels + (rect.y * gfx->screen_rect.width + rect.x) * 4; + unsigned char *dptr = framebuffer + (rect.y * gfx->screen_rect.width + rect.x) * 4; + + for(int i=0; iscreen_rect.width * 4; + dptr += gfx->screen_rect.width * 4; + } } void wait_vsync() @@ -174,4 +187,11 @@ void wait_vsync() } } +void get_rgb_order(int *r, int *g, int *b) +{ + *r = rgb_order[0]; + *g = rgb_order[1]; + *b = rgb_order[2]; +} + #endif // WINNIE_FBDEV