From 3294c81695aedef0b59610fe4e0f0cd22f74d67c Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 24 Jun 2017 13:25:29 +0200 Subject: started to make some things in graphical VGA driver faster --- src/drivers/video/vga.c | 22 ++++++++++++++++++++++ src/gui/desktop.c | 4 ++++ 2 files changed, 26 insertions(+) (limited to 'src') diff --git a/src/drivers/video/vga.c b/src/drivers/video/vga.c index 5da642a..e30fd19 100644 --- a/src/drivers/video/vga.c +++ b/src/drivers/video/vga.c @@ -322,11 +322,33 @@ void vga_set_pixel( vga_t *vga, const int x, const int y, const vga_color_t colo void vga_draw_rectangle( vga_t *vga, const int x, const int y, const int w, const int h, const vga_color_t color ) { + if( !params_ok( vga, x, y ) ) { + kernel_panic( "Pixel coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)", + x, y, vga->mode.x, vga->mode.y ); + } + + if( !params_ok( vga, x + w, y + h ) ) { + kernel_panic( "Pixel coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)", + x + w, y + h, vga->mode.x, vga->mode.y ); + } + + uint8_t color_idx = get_color_index( color ); + + for( int yy = y; yy < y + h; yy++ ) { + uint8_t *addr = vga->mode.segment + vga->mode.x * yy + x; + for( int xx = x; xx < x + w; xx++ ) { + *addr = color_idx; + addr++; + } + } + + /* very slow, but educative version for( int yy = y; yy < y + h; yy++ ) { for( int xx = x; xx < x + w; xx++ ) { vga_set_pixel( vga, xx, yy, color ); } } + */ } void vga_clear_screen( vga_t *vga, const vga_color_t color ) diff --git a/src/gui/desktop.c b/src/gui/desktop.c index ee4a6e5..506bf4d 100644 --- a/src/gui/desktop.c +++ b/src/gui/desktop.c @@ -37,6 +37,10 @@ void desktop_draw( void *obj, graphics_context_t *context ) ((widget_vtable_t *)(desktop->base.vtable))->draw( obj, context ); + vga_draw_char( context, 'D', desktop->base.base.x, + desktop->base.base.y, desktop->base.base.background_color, + VGA_COLOR_WHITE ); + // TODO: use a mouse bitmap and copy it /* for( int i = 0; i < 4; i++ ) { -- cgit v1.2.3-54-g00ecf