gfx_p.h

Go to the documentation of this file.
00001 
00041 /*#*
00042  *#* $Log$
00043  *#* Revision 1.7  2006/07/19 12:56:26  bernie
00044  *#* Convert to new Doxygen style.
00045  *#*
00046  *#* Revision 1.6  2006/05/27 17:17:34  bernie
00047  *#* Optimize away divisions in RAST_ADDR/MASK macros.
00048  *#*
00049  *#* Revision 1.5  2006/05/25 23:35:40  bernie
00050  *#* Cleanup.
00051  *#*
00052  *#* Revision 1.4  2006/03/22 09:50:37  bernie
00053  *#* Use the same format for fonts and rasters.
00054  *#*
00055  *#* Revision 1.3  2006/02/15 09:10:15  bernie
00056  *#* Implement prop fonts; Fix algo styles.
00057  *#*
00058  *#* Revision 1.2  2006/02/10 12:28:33  bernie
00059  *#* Add font support in bitmaps; Make bitmap formats public.
00060  *#*
00061  *#* Revision 1.1  2006/01/26 00:32:49  bernie
00062  *#* Graphics private header.
00063  *#*
00064  *#*/
00065 
00066 #ifndef GFX_GFX_P_H
00067 #define GFX_GFX_P_H
00068 
00069 #include <gfx/gfx.h>
00070 
00071 #if CONFIG_BITMAP_FMT == BITMAP_FMT_PLANAR_H_MSB
00072 
00073     /* We use ucoord_t to let the compiler optimize away the division/modulo. */
00074     #define RAST_ADDR(raster, x, y, stride) \
00075             ((raster) + (ucoord_t)(y) * (ucoord_t)(stride) + (ucoord_t)(x) / 8)
00076     #define RAST_MASK(raster, x, y) \
00077             (1 << (7 - (ucoord_t)(x) % 8))
00078 
00079 #elif CONFIG_BITMAP_FMT == BITMAP_FMT_PLANAR_V_LSB
00080 
00081     /* We use ucoord_t to let the compiler optimize away the division/modulo. */
00082     #define RAST_ADDR(raster, x, y, stride) \
00083             ((raster) + ((ucoord_t)(y) / 8) * (ucoord_t)(stride) + (ucoord_t)(x))
00084     #define RAST_MASK(raster, x, y) \
00085             (1 << ((ucoord_t)(y) % 8))
00086 
00087 #else
00088     #error Unknown value of CONFIG_BITMAP_FMT
00089 #endif /* CONFIG_BITMAP_FMT */
00090 
00091 #define BM_ADDR(bm, x, y)  RAST_ADDR((bm)->raster, (x), (y), (bm)->stride)
00092 #define BM_MASK(bm, x, y)  RAST_MASK((bm)->raster, (x), (y))
00093 
00100 #define BM_PLOT(bm, x, y) \
00101     ( *BM_ADDR(bm, x, y) |= BM_MASK(bm, x, y) )
00102 
00109 #define BM_CLEAR(bm, x, y) \
00110     ( *BM_ADDR(bm, x, y) &= ~BM_MASK(bm, x, y) )
00111 
00119 #define BM_DRAWPIXEL(bm, x, y, fg_pen) \
00120     do { \
00121         uint8_t *p = BM_ADDR(bm, x, y); \
00122         uint8_t mask = BM_MASK(bm, x, y); \
00123         *p = (*p & ~mask) | ((fg_pen) ? mask : 0); \
00124     } while (0)
00125 
00134 #define BM_READPIXEL(bm, x, y) \
00135     ( *BM_ADDR(bm, x, y) & BM_MASK(bm, x, y) ? 1 : 0 )
00136 
00137 #define RAST_READPIXEL(raster, x, y, stride) \
00138         ( *RAST_ADDR(raster, x, y, stride) & RAST_MASK(raster, x, y) ? 1 : 0 )
00139 
00140 #endif /* GFX_GFX_P_H */