core: add support for the autoverbose feature
[fbsplash.git] / core / src / render.h
blob9e5633f29ad3432d22ffa71bf61a9324485fdf2b
1 #ifndef __RENDER_H
2 #define __RENDER_H
4 /* ************************************************************************
5 * Lists
6 * ************************************************************************ */
7 typedef struct item {
8 void *p;
9 struct item *next;
10 } item;
12 typedef struct {
13 item *head, *tail;
14 } list;
16 #define list_init(list) { list.head = list.tail = NULL; }
18 /* ************************************************************************
19 * Enums
20 * ************************************************************************ */
22 enum ESVC { e_display, e_svc_inact_start, e_svc_inact_stop, e_svc_start,
23 e_svc_started, e_svc_stop, e_svc_stopped, e_svc_stop_failed,
24 e_svc_start_failed };
28 /* ************************************************************************
29 * Structures
30 * ************************************************************************ */
31 enum otype { o_box, o_icon, o_text, o_anim };
32 typedef struct {
33 char *filename;
34 unsigned int w, h;
35 u8 *picbuf;
36 } icon_img;
38 typedef struct {
39 int x1, x2, y1, y2;
40 } rect;
42 typedef struct {
43 int x, y;
44 icon_img *img;
45 char *svc;
46 enum ESVC type;
47 u8 status;
48 bool crop;
49 rect crop_from, crop_to, crop_curr;
50 } icon;
52 typedef struct {
53 int id; /* monotonically increased ID */
54 enum otype type; /* object type */
55 void *p; /* pointer to the type-specific data */
56 rect bnd; /* bounding rectangle */
57 u8 *bgcache; /* bgnd cache, directly from the bg picture if NULL */
58 u8 modes;
59 bool invalid; /* indicates whether this object has to be repainted */
60 bool visible; /* is this object to be rendered? */
61 u8 opacity; /* global object opacity */
62 u16 op_tstep; /* opacity time step in ms */
63 short op_step; /* opacity step */
64 short wait_msecs; /* time to wait till the next step */
65 u16 blendin; /* blend-in time in ms, 0 if disabled */
66 u16 blendout; /* blend-out time in ms, 0 if disabled */
67 } obj;
69 typedef struct {
70 rect re;
71 obj *o;
72 } orect;
74 typedef struct color {
75 u8 r, g, b, a;
76 } __attribute__ ((packed)) color;
78 struct colorf {
79 float r, g, b, a;
82 #if WANT_TTF
83 #define F_TXT_EXEC 1
84 #define F_TXT_EVAL 2
85 #define F_TXT_MSGLOG 4
87 #define F_HS_HORIZ_MASK 7
88 #define F_HS_VERT_MASK 56
90 #define F_HS_TOP 8
91 #define F_HS_VMIDDLE 16
92 #define F_HS_BOTTOM 32
94 #define F_HS_LEFT 1
95 #define F_HS_HMIDDLE 2
96 #define F_HS_RIGHT 4
98 #include "ttf.h"
99 typedef struct {
100 char *file;
101 int size;
102 TTF_Font *font;
103 } font_e;
105 typedef struct text {
106 int x, y, last_width;
107 u8 hotspot;
108 color col;
109 u8 flags;
110 u8 style;
111 char *val;
112 u16 *cache;
113 font_e *font;
114 int curr_progress; /* if this string uses the $progress variable,
115 * curr_progress holds its currently used value
116 * (i.e. the value for which the text has been
117 * rendered), otherwise = -1 */
118 int log_last;
119 } text;
121 #endif /* TTF */
123 typedef struct fbspl_theme {
124 u8 bg_color;
125 u16 tx;
126 u16 ty;
127 u16 tw;
128 u16 th;
130 u8 modes; /* bitmask of supported splash modes */
132 char *silentpic; /* background pictures */
133 char *pic;
134 char *silentpic256; /* pictures for 8bpp modes */
135 char *pic256;
137 /* Loaded background images */
138 struct fb_image verbose_img;
139 struct fb_image silent_img;
141 u8 *bgbuf; /* background buffer */
143 /* A list of all objects used in the theme config file. */
144 list objs;
146 /* A list of objects forming a textbox. Objects from this list
147 * are also memebers of the objs list. */
148 list textbox;
150 /* A list of objects with currently active special effects. */
151 list fxobjs;
153 /* A list of anims used in the theme config file. Anims from this
154 * list are also members of the objs list. */
155 list anims;
157 /* A list of icon_img's. */
158 list icons;
160 /* A list of fonts used in the theme. */
161 list fonts;
163 /* A list of rectangles. Rectangles are not on the objs list as they
164 * only describe a special area on the screen and are not renderable. */
165 list rects;
167 int xres; /* Resolution for which this theme has been designed. */
168 int yres;
169 int xmarg; /* Margins. Non-zero only if using a config file
170 * designed for a different resolution than the one
171 * currently in use. */
172 int ymarg;
174 int log_cnt;
175 int log_lines, log_cols;
176 list msglog;
178 list blit; /* List of rectangular regions (rect's) that need to be re-blit to the
179 screen. */
180 list render; /* List of rectangular regions (orect's) that need to be re-rendered
181 to update the screen image. */
182 } stheme_t;
184 #if defined(CONFIG_MNG) && !defined(TARGET_KERNEL)
185 #include "mng_splash.h"
187 #define F_ANIM_METHOD_MASK 12
188 #define F_ANIM_ONCE 0
189 #define F_ANIM_LOOP 4
190 #define F_ANIM_PROPORTIONAL 8
192 #define F_ANIM_STATUS_DONE 1
194 typedef struct anim {
195 int x, y, w, h;
196 mng_handle mng;
197 char *svc;
198 char *filename;
199 enum ESVC type;
200 int curr_progress;
201 u8 status;
202 u8 flags;
203 } anim;
204 #endif /* CONFIG_MNG */
206 typedef struct box {
207 rect re;
208 struct color c_ul, c_ur, c_ll, c_lr; /* upper left, upper right,
209 lower left, lower right */
210 u8 attr;
211 struct box *curr; /* current interpolated box */
212 struct box *inter;
213 } box;
215 typedef struct {
216 u8 r, g, b, a;
217 } __attribute__ ((packed)) rgbacolor;
219 typedef struct {
220 u8 r, g, b;
221 } __attribute__ ((packed)) rgbcolor;
223 #define BOX_NOOVER 0x01
224 #define BOX_INTER 0x02
226 /* internal attributes */
227 #define BOX_SOLID 0x80
228 #define BOX_VGRAD 0x40
229 #define BOX_HGRAD 0x20
231 struct fb_data {
232 struct fb_var_screeninfo var;
233 struct fb_fix_screeninfo fix;
234 int bytespp; /* bytes per pixel */
235 bool opt; /* can we use optimized 24/32bpp routines? */
236 u8 ro, go, bo; /* red, green, blue offset */
237 u8 rlen, glen, blen; /* red, green, blue length */
240 /* ************************************************************************
241 * Functions
242 * ************************************************************************ */
244 /* common.c */
245 int fb_get_settings(int);
246 int do_getpic(unsigned char, unsigned char, char);
247 int cfg_check_sanity(stheme_t *theme, u8 mode);
249 int dev_create(char *fn, char *sys);
250 int fb_open(int fb, bool create);
251 void fb_unmap(u8 *fb);
252 void* fb_mmap(int fb);
254 int tty_open(int tty);
256 /* parse.c */
257 #define obj_alloc(__type, __mode) ({ \
258 u8* __mptr = calloc(1, sizeof(obj) + sizeof(__type)); \
259 (__mptr) ? ({ \
260 ((obj*)__mptr)->p = __mptr + sizeof(obj); \
261 ((obj*)__mptr)->modes = __mode; \
262 ((obj*)__mptr)->visible = true; \
263 ((obj*)__mptr)->opacity = 0xff; \
264 ((obj*)__mptr)->invalid = true; \
265 ((obj*)__mptr)->type = o_##__type; \
266 (__type*)(__mptr + sizeof(obj)); \
267 }) : NULL; })
269 #define container_of(x) (obj*)((u8*)(x) - sizeof(obj))
271 #define obj_setmode(__obj, __mode) { ((obj*)__obj)->modes = __mode; }
273 int parse_svc_state(char *t, enum ESVC *state);
274 int parse_cfg(char *cfgfile, stheme_t *st);
276 /* render.c */
277 void rgba2fb(rgbacolor* data, u8 *bg, u8* out, int len, int y, u8 alpha, u8 opacity);
278 void put_pixel(u8 a, u8 r, u8 g, u8 b, u8 *src, u8 *dst, u8 add);
279 void invalidate_all(stheme_t *theme);
280 void invalidate_service(stheme_t *theme, char *svc, enum ESVC state);
281 void invalidate_progress(stheme_t *theme);
282 void invalidate_textbox(stheme_t *theme, bool active);
283 void rect_interpolate(rect *a, rect *b, rect *c);
284 bool rect_intersect(rect *a, rect *b);
285 void rect_sanitize(stheme_t *theme, rect *re);
286 void box_interpolate(box *a, box *b, box *c);
287 void render_objs(stheme_t *theme, u8 *target, u8 mode, bool force);
288 void bnd_init(stheme_t *theme);
289 void blit_add(stheme_t *theme, rect *a);
290 void render_add(stheme_t *theme, obj *o, rect *a);
292 /* image.c */
293 int load_images(stheme_t *theme, char mode);
295 /* fbcon_decor.c */
296 int fbcon_decor_open(bool create);
297 int fbcon_decor_setstate(unsigned char origin, int vc, unsigned int state);
298 int fbcon_decor_getstate(unsigned char origin, int vc);
299 int fbcon_decor_setpic(unsigned char origin, int vc, stheme_t *theme);
300 int fbcon_decor_setcfg(unsigned char origin, int vc, stheme_t *theme);
301 int fbcon_decor_getcfg(int vc);
303 /* daemon.c */
304 void daemon_start();
306 /* list.c */
307 void list_add(list *l, void *obj);
308 void list_free(list l, bool free_item);
309 void list_del(list *l, item *prev, item *curr);
311 /* effects.c */
312 void paint_rect(stheme_t *theme, u8 *dst, u8 *src, int x1, int y1, int x2, int y2);
313 void put_img(stheme_t *theme, u8 *dst, u8 *src);
314 void paint_img(stheme_t *theme, u8 *dst, u8 *src);
315 void fade(stheme_t *theme, u8 *dst, u8 *image, struct fb_cmap cmap, u8 bgnd, int fd, char type);
316 void set_directcolor_cmap(int fd);
318 /* common.c */
320 extern char *arg_pidfile;
322 extern int fd_fb;
323 extern int fd_tty0;
324 extern int fd_fbcondecor;
325 extern sendian_t endianess;
326 extern fbspl_cfg_t config;
328 /* libsplashrender */
329 extern int fd_tty[MAX_NR_CONSOLES];
330 extern struct fb_data fbd;
334 #endif /* __RENDER_H */