X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Ffbdev%2Fgfx.cc;h=ff86d9ca1384b07840e075450f3fe5d04a70246f;hb=9261ecb0ad85bdf8b21e17b7309ddaeb76a57d96;hp=7ebc656f1b13d29f69dc41be10aa433a721b3a58;hpb=e4076629a736e957739c31cd20bbbbb70327023b;p=winnie diff --git a/src/fbdev/gfx.cc b/src/fbdev/gfx.cc index 7ebc656..ff86d9c 100644 --- a/src/fbdev/gfx.cc +++ b/src/fbdev/gfx.cc @@ -1,3 +1,24 @@ +/* +winnie - an experimental window system + +Copyright (C) 2013 Eleni Maria Stea + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +Author: Eleni Maria Stea +*/ + #ifdef WINNIE_FBDEV #include #include @@ -15,11 +36,13 @@ #include "gfx.h" #include "shalloc.h" +#include "winnie.h" #define FRAMEBUFFER_SIZE(xsz, ysz, bpp) ((xsz) * (ysz) * (bpp) / CHAR_BIT) static unsigned char *framebuffer; static int dev_fd; +static int rgb_order[3]; struct Graphics { Rect screen_rect; @@ -36,6 +59,8 @@ bool init_gfx() return false; } + get_subsys()->graphics_offset = (int)((char*)gfx - (char*)get_pool()); + dev_fd = -1; if((dev_fd = open("/dev/fb0", O_RDWR)) == -1) { @@ -59,6 +84,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,6 +133,7 @@ bool init_gfx() void destroy_gfx() { clear_screen(0, 0, 0); + gfx_update(gfx->screen_rect); if(dev_fd != -1) { close(dev_fd); @@ -160,9 +190,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() @@ -173,4 +211,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