summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-24 13:25:29 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-24 13:25:29 +0200
commit3294c81695aedef0b59610fe4e0f0cd22f74d67c (patch)
tree5472608e21befc072da4d2176bf964d369547d6f
parentc8f2689dbeca2bf51d41bbf861c495bb4b0c29ce (diff)
downloadabaos-3294c81695aedef0b59610fe4e0f0cd22f74d67c.tar.gz
abaos-3294c81695aedef0b59610fe4e0f0cd22f74d67c.tar.bz2
started to make some things in graphical VGA driver faster
-rw-r--r--src/drivers/video/vga.c22
-rw-r--r--src/gui/desktop.c4
2 files changed, 26 insertions, 0 deletions
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++ ) {