Make more portable.
[bertos.git] / mware / gfx.h
1 /*!
2  * \file
3  * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
4  * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
5  * This file is part of DevLib - See devlib/README for information.
6  *
7  * \version $Id$
8  *
9  * \author Bernardo Innocenti <bernie@develer.com>
10  * \author Stefano Fedrigo <aleph@develer.com>
11  *
12  * \brief General pourpose graphics routines
13  */
14
15 /*#*
16  *#* $Log$
17  *#* Revision 1.8  2004/11/01 15:14:07  bernie
18  *#* Update to current coding conventions.
19  *#*
20  *#* Revision 1.7  2004/09/20 03:29:06  bernie
21  *#* Conditionalize AVR-specific code.
22  *#*
23  *#* Revision 1.6  2004/09/14 21:01:08  bernie
24  *#* Rename rectangle drawing functions; Unify filled/cleared implementations.
25  *#*
26  *#* Revision 1.4  2004/08/10 07:00:16  bernie
27  *#* Add missing header.
28  *#*
29  *#* Revision 1.3  2004/08/04 03:16:59  bernie
30  *#* Switch to new DevLib CONFIG_ convention.
31  *#*
32  *#* Revision 1.2  2004/06/03 11:27:09  bernie
33  *#* Add dual-license information.
34  *#*
35  *#* Revision 1.1  2004/05/23 15:43:16  bernie
36  *#* Import mware modules.
37  *#*/
38
39 #ifndef MWARE_GFX_H
40 #define MWARE_GFX_H
41
42 #include <compiler.h>
43 #include <config.h>
44
45
46 /*! Common type for coordinates expressed in pixel units */
47 typedef int coord_t;
48
49 #if CONFIG_GFX_VCOORDS
50 /*! Common type for coordinates expressed in logical units */
51 typedef float vcoord_t;
52 #endif /* CONFIG_GFX_VCOORDS */
53
54
55 typedef struct Rect { coord_t xmin, ymin, xmax, ymax; } Rect;
56
57
58 /*!
59  * Control structure to draw in a bitmap
60  */
61 typedef struct Bitmap
62 {
63         uint8_t *raster;        /*!< Pointer to byte array to hold the data */
64         coord_t width, height;  /*!< Width/Height in pixels */
65         coord_t penX, penY;     /*!< Current pen position MoveTo()/LineTo() */
66
67         Rect cr;                /*!< Clip drawing inside this rectangle */
68
69 #if CONFIG_GFX_VCOORDS
70         /*!
71          * \name Logical coordinate system
72          * \{
73          */
74         vcoord_t orgX, orgY;
75         vcoord_t scaleX, scaleY;
76         /*\}*/
77 #endif /* CONFIG_GFX_VCOORDS */
78
79 } Bitmap;
80
81
82 /* Function prototypes */
83 extern void gfx_bitmapInit (Bitmap *bm, uint8_t *raster, coord_t w, coord_t h);
84 extern void gfx_bitmapClear(Bitmap *bm);
85 extern void gfx_line       (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
86 extern void gfx_rectDraw   (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
87 extern void gfx_rectFillC  (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t color);
88 extern void gfx_rectFill   (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
89 extern void gfx_rectClear  (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
90 extern void gfx_moveTo     (Bitmap *bm, coord_t x,  coord_t y);
91 extern void gfx_lineTo     (Bitmap *bm, coord_t x,  coord_t y);
92 extern void gfx_setClipRect(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax);
93
94 #if CPU_AVR
95         #include <avr/pgmspace.h>
96         extern void gfx_blit_P(Bitmap *bm, const prog_uchar *raster);
97 #endif /* CPU_AVR */
98
99
100 #if CONFIG_GFX_VCOORDS
101 extern void gfx_setViewRect(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
102 extern coord_t gfx_transformX(Bitmap *bm, vcoord_t x);
103 extern coord_t gfx_transformY(Bitmap *bm, vcoord_t y);
104 extern void gfx_vline(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
105 #endif /* CONFIG_GFX_VCOORDS */
106
107 #endif /* MWARE_GFX_H */