Move graphics stuff from mware/ to gfx/.
[bertos.git] / gfx / 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 README.devlib 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.1  2005/11/04 18:11:35  bernie
18  *#* Move graphics stuff from mware/ to gfx/.
19  *#*
20  *#* Revision 1.12  2005/11/04 16:20:02  bernie
21  *#* Fix reference to README.devlib in header.
22  *#*
23  *#* Revision 1.11  2005/04/11 19:10:28  bernie
24  *#* Include top-level headers from cfg/ subdir.
25  *#*
26  *#* Revision 1.10  2005/03/01 23:26:45  bernie
27  *#* Use new CPU-neutral program-memory API.
28  *#*
29  *#* Revision 1.9  2005/01/20 18:46:31  aleph
30  *#* Fix progmem includes.
31  *#*
32  *#* Revision 1.8  2004/11/01 15:14:07  bernie
33  *#* Update to current coding conventions.
34  *#*
35  *#* Revision 1.7  2004/09/20 03:29:06  bernie
36  *#* Conditionalize AVR-specific code.
37  *#*
38  *#* Revision 1.6  2004/09/14 21:01:08  bernie
39  *#* Rename rectangle drawing functions; Unify filled/cleared implementations.
40  *#*
41  *#* Revision 1.4  2004/08/10 07:00:16  bernie
42  *#* Add missing header.
43  *#*
44  *#* Revision 1.3  2004/08/04 03:16:59  bernie
45  *#* Switch to new DevLib CONFIG_ convention.
46  *#*
47  *#* Revision 1.2  2004/06/03 11:27:09  bernie
48  *#* Add dual-license information.
49  *#*
50  *#* Revision 1.1  2004/05/23 15:43:16  bernie
51  *#* Import mware modules.
52  *#*/
53
54 #ifndef MWARE_GFX_H
55 #define MWARE_GFX_H
56
57 #include <cfg/config.h>
58 #include <cfg/compiler.h>
59 #include <cfg/cpu.h>
60
61
62 /*! Common type for coordinates expressed in pixel units */
63 typedef int coord_t;
64
65 #if CONFIG_GFX_VCOORDS
66 /*! Common type for coordinates expressed in logical units */
67 typedef float vcoord_t;
68 #endif /* CONFIG_GFX_VCOORDS */
69
70
71 typedef struct Rect { coord_t xmin, ymin, xmax, ymax; } Rect;
72
73
74 /*!
75  * Control structure to draw in a bitmap
76  */
77 typedef struct Bitmap
78 {
79         uint8_t *raster;        /*!< Pointer to byte array to hold the data */
80         coord_t width, height;  /*!< Width/Height in pixels */
81         coord_t penX, penY;     /*!< Current pen position MoveTo()/LineTo() */
82
83         Rect cr;                /*!< Clip drawing inside this rectangle */
84
85 #if CONFIG_GFX_VCOORDS
86         /*!
87          * \name Logical coordinate system
88          * \{
89          */
90         vcoord_t orgX, orgY;
91         vcoord_t scaleX, scaleY;
92         /*\}*/
93 #endif /* CONFIG_GFX_VCOORDS */
94
95 } Bitmap;
96
97
98 /* Function prototypes */
99 extern void gfx_bitmapInit (Bitmap *bm, uint8_t *raster, coord_t w, coord_t h);
100 extern void gfx_bitmapClear(Bitmap *bm);
101 extern void gfx_line       (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
102 extern void gfx_rectDraw   (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
103 extern void gfx_rectFillC  (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t color);
104 extern void gfx_rectFill   (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
105 extern void gfx_rectClear  (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
106 extern void gfx_moveTo     (Bitmap *bm, coord_t x,  coord_t y);
107 extern void gfx_lineTo     (Bitmap *bm, coord_t x,  coord_t y);
108 extern void gfx_setClipRect(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax);
109
110 #if CPU_HARVARD
111         #include <mware/pgm.h>
112         extern void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster);
113 #endif
114
115
116 #if CONFIG_GFX_VCOORDS
117 extern void gfx_setViewRect(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
118 extern coord_t gfx_transformX(Bitmap *bm, vcoord_t x);
119 extern coord_t gfx_transformY(Bitmap *bm, vcoord_t y);
120 extern void gfx_vline(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
121 #endif /* CONFIG_GFX_VCOORDS */
122
123 #endif /* MWARE_GFX_H */