socsvn commit: r269715 - soc2014/seiya/bootsplash/sys/dev/fb
seiya at FreeBSD.org
seiya at FreeBSD.org
Wed Jun 18 06:33:24 UTC 2014
Author: seiya
Date: Wed Jun 18 06:33:23 2014
New Revision: 269715
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269715
Log:
bmp: tiny enhance
Modified:
soc2014/seiya/bootsplash/sys/dev/fb/bmp.c
Modified: soc2014/seiya/bootsplash/sys/dev/fb/bmp.c
==============================================================================
--- soc2014/seiya/bootsplash/sys/dev/fb/bmp.c Wed Jun 18 05:35:09 2014 (r269714)
+++ soc2014/seiya/bootsplash/sys/dev/fb/bmp.c Wed Jun 18 06:33:23 2014 (r269715)
@@ -224,6 +224,46 @@
return(0);
}
+/*
+** bmp_draw_line
+**
+** Given (info), set the pixels from (x_origin) to (x_origin) + (count) at (y) to (val)
+**
+*/
+static void
+bmp_draw_line(BMP_INFO *info, int y, int x_origin, int count, int val)
+{
+ int i;
+ int sofs;
+ int newbank;
+
+ /*
+ * range check to avoid explosions
+ */
+ if ((x_origin < 0) || (x_origin + count >= info->swidth) || (y < 0) || (y >= info->sheight))
+ return;
+
+ /*
+ * calculate offset into video memory
+ */
+ sofs = (y * info->adp->va_line_width) + x_origin;
+
+ switch(info->sdepth) {
+ case 1: break; /* TODO */
+ case 4: break; /* TODO */
+
+ case 8:
+ for(i = 0; i < count; i++, sofs++) {
+ newbank = sofs / info->adp->va_window_size;
+ if (info->bank != newbank) {
+ vidd_set_win_org(info->adp, newbank*info->adp->va_window_size);
+ info->bank = newbank;
+ }
+ *(info->vidmem + (sofs % info->adp->va_window_size)) = val;
+ }
+ break;
+ }
+}
/*
** bmp_SetPix
@@ -393,6 +433,7 @@
bmp_DecodeRLE8(BMP_INFO *info, int line, int sx, int width)
{
int i;
+ int count; /* pixels to be drawn at the `y`th line */
int x,y; /* screen position on screen */
y = line;
@@ -405,10 +446,11 @@
* two colour indexes to alternate between for the run
*/
if (*info->index) {
- for (i = 0; i < *info->index && (x - sx) < width; i++, x++)
- bmp_SetPix(info, x, y, *(info->index+1));
-
+ count = ((width - x - sx - 1) > *info->index)? *info->index : (width - x - sx - 1);
+ bmp_draw_line(info, y, x, count, *(info->index+1));
+ x += count;
info->index += 2;
+
/*
* A leading zero is an escape; it may signal the end of the
* bitmap, a cursor move, or some absolute data.
More information about the svn-soc-all
mailing list