From 9bfd9fb6a7c568b56a5ef525a2b76351780bae66 Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 18 Oct 2018 18:37:31 +0200 Subject: in-kernel bmp loader --- userspace/init.c | 24 +++++++---- video/compositor.c | 118 +++++++++++++++++++++++++++++++++++++++++------------ video/compositor.h | 9 ++++ 3 files changed, 115 insertions(+), 36 deletions(-) diff --git a/userspace/init.c b/userspace/init.c index 255b274..e432ef9 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -4,11 +4,11 @@ * * */ +#define LAUNCH_COUNT 0 static char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; static char *argv1[]={"xterm","/bin/fsh",0}; /* -#define LAUNCH_COUNT 3 char *argv1[][4]={ {"/bin/xterm","xterm","/bin/fsh",0}, @@ -17,24 +17,30 @@ char *argv1[][4]={ }; */ -void fork_and_exec(char **argv) +void fork_and_exec() { int pid=fork(); - if(!pid) //child { - execve(argv[0],&argv[1],env1); + execve("/bin/xterm",argv1,env1); } } int main(int argc, char **argv) { - execve("/bin/xterm",argv1,env1); - /* + int pid=fork(); + for(int i=0;i>8; uint8_t src_r=(color&0xff0000)>>16; + uint8_t src_a=(color&0xff000000)>>24; - uint8_t out_r=((src_r*(0xff-a))>>8)+((a*dst_r)>>8); - uint8_t out_g=((src_g*(0xff-a))>>8)+((a*dst_g)>>8); - uint8_t out_b=((src_b*(0xff-a))>>8)+((a*dst_b)>>8); + uint8_t out_r=((src_r*(src_a))>>8)+(((0xff-src_a)*dst_r)>>8); + uint8_t out_g=((src_g*(src_a))>>8)+(((0xff-src_a)*dst_g)>>8); + uint8_t out_b=((src_b*(src_a))>>8)+(((0xff-src_a)*dst_b)>>8); put_pixel(dst, x,y,(out_r<<16)+(out_g<<8)+out_b); } @@ -162,7 +167,6 @@ static void cpy_rect(uint8_t *src, uint16_t src_x, uint16_t src_y, if(transp&&transp_key==val)continue; // TODO: quick workaround for arrow black if(alpha) - put_pixel_alpha(dst,dst_x+x,dst_y+y,val); else put_pixel(dst,dst_x+x,dst_y+y,val); @@ -508,12 +512,20 @@ void compositor_kb_handle(char c) void compositor_mouse_handle(int16_t diff_x,int16_t diff_y, uint8_t key) { // klog("%d %d %d",diff_x,diff_y,key); - static uint8_t lastkey; + static uint8_t lastkey=0; + + if(!(key&2)&&(lastkey&2)) // right mouse click + { + lastkey=key; + klog("tell init to spawn new foolshell"); + fd_write(get_tty(1),'0'); // tell init to spawn new xterm + } mouse_x+=diff_x; mouse_y+=diff_y; mouse_k=key; + if(mouse_x<0)mouse_x=0; if(mouse_y<0)mouse_y=0; @@ -642,13 +654,62 @@ void compositor_mouse_handle(int16_t diff_x,int16_t diff_y, uint8_t key) lastkey=key; } + +/** THIS CAN LOAD WINDOWS ARGB BITMAPS WITH BITMAPINFOHEADER */ +void load_bmp(uint8_t *dst,char *filename) +{ + + klog("loading bitmap %s",filename); + fd dat=mount_file_open(filename); + char B=fd_read(&dat); // 0x0 + char M=fd_read(&dat); // 0x1 + //klog("id = %c%c",M,B); + if(M!='M'||B!='B')kpanic("not a (windows) bitmap!"); + + uint32_t size=(fd_read(&dat))+(fd_read(&dat)<<8)+(fd_read(&dat)<<16)+(fd_read(&dat)<<24); //0x02 + klog("bytes = 0x%08x",size); + + // skip next 4 reserved bytes + fd_read(&dat); + fd_read(&dat); + fd_read(&dat); + fd_read(&dat); + + uint32_t off=(fd_read(&dat))+(fd_read(&dat)<<8)+(fd_read(&dat)<<16)+(fd_read(&dat)<<24); //0x0a + //klog("offset = 0x%08X",off); + + // skip next 4 bytes + fd_read(&dat); + fd_read(&dat); + fd_read(&dat); + fd_read(&dat); + + uint32_t w=(fd_read(&dat))+(fd_read(&dat)<<8)+(fd_read(&dat)<<16)+(fd_read(&dat)<<24); //0x12 + uint32_t h=(fd_read(&dat))+(fd_read(&dat)<<8)+(fd_read(&dat)<<16)+(fd_read(&dat)<<24); //0x16 + klog("width=%d,height=%d",w,h); + + for(int i=0;i=vesa_width)continue; + if(y>=vesa_height)continue; + put_pixel_alpha(dst,x,y,val); + } + } + +} + // load background image or generate one if (param == 0) void compositor_set_background(char *ppm_raw_filename) { // TODO: think about funny things to do with timer and update // some generated / or modified bg regularly // // uint64_t t=timer_get_ms()/333; // - klog("loading theme..."); fd bg=mount_file_open(ppm_raw_filename); @@ -663,33 +724,36 @@ void compositor_set_background(char *ppm_raw_filename) if(x>=vesa_width)continue; if(y>=vesa_height)continue; put_pixel(icon_data,x,y,val); + put_pixel(bgimage,x,y,val); i++; } } + klog("finished"); // generating simple background... - int center_x=vesa_width/2; - int center_y=vesa_height/2; - - int max_dist = center_x*center_x+center_y*center_y; + int center_x=vesa_width/2; + int center_y=vesa_height/2; + int max_dist = center_x*center_x+center_y*center_y; - for(int x=0;x #include "ringbuffer.h" +/** + * @file + * + * Super Light composting window manager for Fool 0S. + * Can be run directly on a 32bit or 24bit Framebuffer. + * + * + */ + void compositor_wake(); void compositor_wake2(); void compositor_init(uint16_t width, uint16_t height,uint16_t bpp, uint16_t pitch); -- cgit v1.2.3