r1968 - in trunk/user/microwin/src
dslinux_amadeus at dslinux.in-berlin.de
dslinux_amadeus at dslinux.in-berlin.de
Sun Oct 7 22:43:53 CEST 2007
Author: amadeus
Date: 2007-10-07 22:43:48 +0200 (Sun, 07 Oct 2007)
New Revision: 1968
Log:
Optimize the drawing of monocolor bitmaps (fonts, symbols)
Modified: trunk/user/microwin/src/drivers/fblin16.c
===================================================================
--- trunk/user/microwin/src/drivers/fblin16.c 2007-10-07 20:39:39 UTC (rev 1967)
+++ trunk/user/microwin/src/drivers/fblin16.c 2007-10-07 20:43:48 UTC (rev 1968)
@@ -1041,7 +1041,58 @@
}
#endif /* MW_FEATURE_PSDOP_BITMAP_BYTES_MSB_FIRST */
+#if MW_FEATURE_PSDOP_BITMAP_MWIMAGE
+/*
+ * Draws a mono bitmap to screen (e.g. a mono font).
+ * This variant takes the bitmap as an array of MWIMAGEBITS,
+ * where the Most Significant Bit in each MWIMAGEBITS is
+ * used to set the left-most of the 16 pixels
+ * controlled by that MWIMAGEBITS.
+ *
+ * Params:
+ * dstx, dsty - Destination for top left of image
+ * dstw, dsth - Image size
+ * pixels - The bitmap. Format: ADDR16, MSB is drawn first.
+ * fg_color - The color to draw "1" bits in, in the display format.
+ * bg_color - The color to draw "0" bits in, in the display format.
+ * gr_usebg - If zero, then "0" bits are transparent. If nonzero,
+ * then "0" bits are bg_color.
+ */
+static void linear16_drawarea_bitmap_mwimage(PSD psd, driver_gc_t * gc)
+{
+ ADDR16 dst = ((ADDR16) psd->addr) + (psd->linelen * gc->dsty) + gc->dstx;
+ ADDR16 src = gc->pixels;
+ MWCOORD height = gc->dsth;
+ MWCOORD width = gc->dstw;
+ MWPIXELVAL foreground = gc->fg_color;
+ MWPIXELVAL background = gc->bg_color;
+ int usebg = gc->gr_usebg;
+ MWCOORD advance = psd->linelen - gc->dstw;
+ unsigned int bitcount = 0;
+ MWIMAGEBITS bitvalue;
+ while (height > 0) {
+ if (!bitcount) {
+ bitcount = MWIMAGE_BITSPERIMAGE;
+ bitvalue = *src++;
+ }
+ if (MWIMAGE_TESTBIT(bitvalue))
+ *dst = foreground;
+ else
+ if(usebg) *dst = background;
+ dst++;
+ bitvalue = MWIMAGE_SHIFTBIT(bitvalue);
+ bitcount--;
+ if (!--width) {
+ width = gc->dstw;
+ --height;
+ bitcount = 0;
+ dst += advance;
+ }
+ }
+}
+#endif /* MW_FEATURE_PSDOP_BITMAP_MWIMAGE */
+
#if MW_FEATURE_PSDOP_ALPHAMAP
/* FIXME should make linear16_drawarea_alphamap() work in 5/5/5 mode
@@ -1146,9 +1197,15 @@
#define COLOR_MASK_G_565 0x07E0U
#define COLOR_MASK_B_565 0x001FU
+#if NDSDRIVER
+#define COLOR_MASK_B_555 0x7C00U
+#define COLOR_MASK_G_555 0x03E0U
+#define COLOR_MASK_R_555 0x001FU
+#else
#define COLOR_MASK_R_555 0x7C00U
#define COLOR_MASK_G_555 0x03E0U
#define COLOR_MASK_B_555 0x001FU
+#endif
DRAWON;
if (psd->pixtype == MWPF_TRUECOLOR565) {
@@ -1295,11 +1352,11 @@
rdst = dst;
rsrc = src16;
for (x = 0; x < gc->dstw; x++) {
- pcol = *rsrc++ & ~(ALPHA_1B);
+ pcol = *rsrc++;
if (pcol == gc->bg_color)
rdst++;
else
- *rdst++ = pcol | ALPHA_1B;
+ *rdst++ = pcol;
}
dst += psd->linelen;
src16 += gc->src_linelen;
@@ -1363,6 +1420,11 @@
break;
#endif /* MW_FEATURE_PSDOP_BITMAP_BYTES_MSB_FIRST */
+#if MW_FEATURE_PSDOP_BITMAP_MWIMAGE
+ case PSDOP_BITMAP_MWIMAGE:
+ linear16_drawarea_bitmap_mwimage(psd, gc);
+ break;
+#endif /* MW_FEATURE_PSDOP_BITMAP_MWIMAGE */
}
}
Modified: trunk/user/microwin/src/engine/devdraw.c
===================================================================
--- trunk/user/microwin/src/engine/devdraw.c 2007-10-07 20:39:39 UTC (rev 1967)
+++ trunk/user/microwin/src/engine/devdraw.c 2007-10-07 20:43:48 UTC (rev 1968)
@@ -558,23 +558,31 @@
drawbitmap(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height,
const MWIMAGEBITS *imagebits)
{
+#if MW_FEATURE_PSDOP_BITMAP_MWIMAGE
+ driver_gc_t gc;
+#else
MWCOORD minx;
MWCOORD maxx;
MWIMAGEBITS bitvalue = 0; /* bitmap word value */
int bitcount; /* number of bits left in bitmap word */
-
+#endif
if (width <= 0 || height <= 0)
return;
+#if MW_FEATURE_PSDOP_BITMAP_MWIMAGE
+ gc.dstx = x;
+ gc.dsty = y;
+ gc.dstw = width;
+ gc.dsth = height;
+ gc.pixels = (MWIMAGEBITS *)imagebits;
+ gc.fg_color = gr_foreground;
+ gc.bg_color = gr_background;
+ gc.gr_usebg = gr_usebg;
+ psd->DrawArea(psd, &gc, PSDOP_BITMAP_MWIMAGE);
+#else
if (gr_usebg)
psd->FillRect(psd, x, y, x + width - 1, y + height - 1,
gr_background);
-
- /* FIXME think of the speedups if this existed...
- psd->DrawBitmap(psd, x, y, width, height, imagebits, gr_foreground);
- return;
- */
-
minx = x;
maxx = x + width - 1;
bitcount = 0;
@@ -595,6 +603,7 @@
bitcount = 0;
}
}
+#endif
}
void
Modified: trunk/user/microwin/src/include/device.h
===================================================================
--- trunk/user/microwin/src/include/device.h 2007-10-07 20:39:39 UTC (rev 1967)
+++ trunk/user/microwin/src/include/device.h 2007-10-07 20:43:48 UTC (rev 1968)
@@ -65,9 +65,10 @@
/* Which low-level psd->DrawArea routines to include. */
#define MW_FEATURE_PSDOP_COPY 1
#define MW_FEATURE_PSDOP_ALPHAMAP 0
-#define MW_FEATURE_PSDOP_ALPHACOL 0
+#define MW_FEATURE_PSDOP_ALPHACOL 1
#define MW_FEATURE_PSDOP_BITMAP_BYTES_LSB_FIRST 0
#define MW_FEATURE_PSDOP_BITMAP_BYTES_MSB_FIRST 1
+#define MW_FEATURE_PSDOP_BITMAP_MWIMAGE 1
/* max char height/width must be >= 16 and a multiple of sizeof(MWIMAGEBITS)*/
#define MAX_CHAR_HEIGHT 128 /* maximum text bitmap height*/
@@ -263,6 +264,26 @@
#define PSDOP_BITMAP_BYTES_MSB_FIRST 6
#endif /* MW_FEATURE_PSDOP_BITMAP_BYTES_MSB_FIRST */
+#if MW_FEATURE_PSDOP_BITMAP_MWIMAGE
+/*
+ * Draws a mono bitmap to screen (e.g. a mono font).
+ * This variant takes the bitmap as an array of MWIMAGEBITS,
+ * where the Most Significant Bit in each MWIMAGEBITS is
+ * used to set the left-most of the 16 pixels
+ * controlled by that MWIMAGEBITS.
+ *
+ * Params:
+ * dstx, dsty - Destination for top left of image
+ * dstw, dsth - Image size
+ * pixels - The bitmap. Format: ADDR16, MSB is drawn first.
+ * fg_color - The color to draw "1" bits in, in the display format.
+ * bg_color - The color to draw "0" bits in, in the display format.
+ * gr_usebg - If zero, then "0" bits are transparent. If nonzero,
+ * then "0" bits are bg_color.
+ */
+#define PSDOP_BITMAP_MWIMAGE 7
+#endif /* MW_FEATURE_PSDOP_BITMAP_MWIMAGE */
+
/* common blitter parameter structure*/
typedef struct {
PSD dstpsd; /* dst drawable*/
More information about the dslinux-commit
mailing list