comparison include/mb_redraw_man.h @ 1067:7b4e80ab671a openvg

merge from default branch
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 01 Dec 2010 12:25:56 +0800
parents a8d20bc8ce40
children 36cbe73813a8
comparison
equal deleted inserted replaced
630:bd18951b51d5 1067:7b4e80ab671a
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
2 // vim: sw=4:ts=8:sts=4
1 #ifndef __REDRAW_MAN_H_ 3 #ifndef __REDRAW_MAN_H_
2 #define __REDRAW_MAN_H_ 4 #define __REDRAW_MAN_H_
3 5
4 #include "mb_graph_engine.h" 6 #include "mb_graph_engine.h"
5 #include "mb_tools.h" 7 #include "mb_tools.h"
6 #include "mb_types.h" 8 #include "mb_types.h"
7 #include "mb_observer.h" 9 #include "mb_observer.h"
8 #include "mb_img_ldr.h" 10 #include "mb_img_ldr.h"
9 #include "mb_timer.h" 11
10 12 /*! \defgroup rdman Redraw Manager
13 * @{
14 */
11 typedef struct _redraw_man redraw_man_t; 15 typedef struct _redraw_man redraw_man_t;
12 16
17 /*! \defgroup rdman_private Private Types of Redraw Manager
18 * @{
19 */
13 typedef void (*free_func_t)(redraw_man_t *rdman, void *obj); 20 typedef void (*free_func_t)(redraw_man_t *rdman, void *obj);
14 struct _free_obj { 21 struct _free_obj {
15 void *obj; 22 void *obj;
16 free_func_t free_func; 23 free_func_t free_func;
17 }; 24 };
22 }; 29 };
23 typedef struct _free_objs free_objs_t; 30 typedef struct _free_objs free_objs_t;
24 31
25 DARRAY(coords, coord_t *); 32 DARRAY(coords, coord_t *);
26 DARRAY(geos, geo_t *); 33 DARRAY(geos, geo_t *);
34 /* @} */
27 35
28 /*! \brief Manage redrawing of shapes (graphic elements). 36 /*! \brief Manage redrawing of shapes (graphic elements).
29 * 37 *
30 * Every coord_t and geo_t object is assigned with a unique 38 * Every coord_t and geo_t object is assigned with a unique
31 * incremental order. The order is a unsigned integer. 39 * incremental order. The order is a unsigned integer.
46 coord_t *root_coord; 54 coord_t *root_coord;
47 55
48 elmpool_t *geo_pool; 56 elmpool_t *geo_pool;
49 elmpool_t *coord_pool; 57 elmpool_t *coord_pool;
50 elmpool_t *shnode_pool; 58 elmpool_t *shnode_pool;
59 elmpool_t *sh_path_pool;
60 elmpool_t *sh_rect_pool;
51 elmpool_t *observer_pool; 61 elmpool_t *observer_pool;
52 elmpool_t *subject_pool; 62 elmpool_t *subject_pool;
53 elmpool_t *paint_color_pool; 63 elmpool_t *paint_color_pool;
64 elmpool_t *paint_linear_pool;
65 elmpool_t *paint_radial_pool;
66 elmpool_t *paint_image_pool;
54 elmpool_t *pent_pool; 67 elmpool_t *pent_pool;
55 elmpool_t *coord_canvas_pool; 68 elmpool_t *coord_canvas_pool;
56 69
57 coords_t dirty_coords; 70 coords_t dirty_coords;
58 coords_t dirty_pcache_area_coords;
59 geos_t dirty_geos; 71 geos_t dirty_geos;
60 int n_dirty_areas; /*!< \brief Number of all dirty areas. */ 72 int n_dirty_areas; /*!< \brief Number of all dirty areas. */
61 73
62 geos_t gen_geos; 74 geos_t gen_geos;
63 coords_t zeroing_coords; 75 coords_t zeroing_coords;
68 free_objs_t free_objs; 80 free_objs_t free_objs;
69 81
70 mbe_t *cr; 82 mbe_t *cr;
71 mbe_t *backend; 83 mbe_t *backend;
72 84
73 ob_factory_t ob_factory; 85 observer_factory_t observer_factory;
74 86
75 subject_t *redraw; /*!< \brief Notified after redrawing. */ 87 subject_t *redraw; /*!< \brief Notified after redrawing. */
76 subject_t *addrm_monitor; /*!< \brief Monitor adding/removing observers 88 subject_t *addrm_monitor; /*!< \brief Monitor adding/removing observers
77 * to/from mouse event subjects. 89 * to/from mouse event subjects.
78 * \see addrm_monitor_hdlr() 90 * \see addrm_monitor_hdlr()
79 */ 91 */
80 mb_obj_t *last_mouse_over; 92 mb_obj_t *last_mouse_over;
81 void *rt; /*!< \brief This is a pointer to the current 93 void *rt; /*!< \brief This is a pointer to the current
82 * graphic backend. 94 * graphic backend.
83 * \see rdman_attach_backend() 95 * \see rdman_attach_backend()
84 */ 96 */
85 mb_prop_store_t props; 97 mb_prop_store_t props;
86 mb_img_ldr_t *img_ldr; /*!< \brief Image Loader. 98 mb_img_ldr_t *img_ldr; /*!< \brief Image Loader.
87 * This is initialized by backend. 99 * This is initialized by backend.
98 geo_t *geo, 110 geo_t *geo,
99 geo_t ***overlays); 111 geo_t ***overlays);
100 extern int rdman_add_shape(redraw_man_t *rdman, 112 extern int rdman_add_shape(redraw_man_t *rdman,
101 shape_t *shape, coord_t *coord); 113 shape_t *shape, coord_t *coord);
102 /*! \brief Make a shape been managed by a redraw manager. */ 114 /*! \brief Make a shape been managed by a redraw manager. */
103 #define rdman_shape_man(rdman, shape) \ 115 #define rdman_man_shape(rdman, shape) \
104 do { \ 116 do { \
105 mb_prop_store_init(&((mb_obj_t *)(shape))->props, \ 117 mb_prop_store_init(&((mb_obj_t *)(shape))->props, \
106 (rdman)->pent_pool); \ 118 (rdman)->pent_pool); \
107 STAILQ_INS_TAIL(rdman->shapes, shape_t, sh_next, shape); \ 119 STAILQ_INS_TAIL(rdman->shapes, shape_t, sh_next, shape); \
108 if(rdman->last_mouse_over == (mb_obj_t *)(shape)) \ 120 if(rdman->last_mouse_over == (mb_obj_t *)(shape)) \
109 rdman->last_mouse_over = NULL; \ 121 rdman->last_mouse_over = NULL; \
122 mb_prop_store_init(&((mb_obj_t *)(shape))->props, \
123 (rdman)->pent_pool); \
110 } while(0) 124 } while(0)
111 extern int rdman_shape_free(redraw_man_t *rdman, shape_t *shape); 125 extern int rdman_shape_free(redraw_man_t *rdman, shape_t *shape);
112 126
113 extern int rdman_paint_free(redraw_man_t *rdman, paint_t *paint); 127 extern int rdman_paint_free(redraw_man_t *rdman, paint_t *paint);
114 128
138 shnode_free(rdman, __last); \ 152 shnode_free(rdman, __last); \
139 __last = __node; \ 153 __last = __node; \
140 } \ 154 } \
141 shnode_free(rdman, __last); \ 155 shnode_free(rdman, __last); \
142 } while(0) 156 } while(0)
157
158 /*! \defgroup rdman_paints Paints Supporting of Redraw Manger
159 * @{
160 */
143 #define _rdman_paint_child(rdman, paint, shape) \ 161 #define _rdman_paint_child(rdman, paint, shape) \
144 do { \ 162 do { \
145 shnode_t *__node; \ 163 shnode_t *__node; \
146 if((shape)->fill != (paint) && \ 164 if((shape)->fill != (paint) && \
147 (shape)->stroke != (paint)) { \ 165 (shape)->stroke != (paint)) { \
181 if(paint) \ 199 if(paint) \
182 _rdman_paint_child(rdman, paint, shape); \ 200 _rdman_paint_child(rdman, paint, shape); \
183 (shape)->stroke = paint; \ 201 (shape)->stroke = paint; \
184 } while(0) 202 } while(0)
185 extern int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint); 203 extern int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint);
186 204 /* @} */
205
206 /*! \defgroup rdman_pos Position/Overlay Detection for Managed Objects
207 * @{
208 */
187 extern shape_t *find_shape_at_pos(redraw_man_t *rdman, 209 extern shape_t *find_shape_at_pos(redraw_man_t *rdman,
188 co_aix x, co_aix y, int *in_stroke); 210 co_aix x, co_aix y, int *in_stroke);
189 extern int mb_obj_pos_is_in(redraw_man_t *rdman, mb_obj_t *obj, 211 extern int mb_obj_pos_is_in(redraw_man_t *rdman, mb_obj_t *obj,
190 co_aix x, co_aix y, int *in_stroke); 212 co_aix x, co_aix y, int *in_stroke);
191 extern int mb_objs_are_overlay(redraw_man_t *rdman, 213 extern int mb_objs_are_overlay(redraw_man_t *rdman,
192 mb_obj_t *obj1, mb_obj_t *obj2); 214 mb_obj_t *obj1, mb_obj_t *obj2);
193 #define rdman_get_ob_factory(rdman) (&(rdman)->ob_factory) 215 /* @} */
216
217 /*! \defgroup rdman_accessors Accessors of Redraw Manager
218 * @{
219 */
220 #define rdman_get_observer_factory(rdman) (&(rdman)->observer_factory)
194 #define rdman_get_redraw_subject(rdman) ((rdman)->redraw) 221 #define rdman_get_redraw_subject(rdman) ((rdman)->redraw)
195 #define rdman_get_root(rdman) ((rdman)->root_coord) 222 #define rdman_get_root(rdman) ((rdman)->root_coord)
196 #define rdman_get_cr(rdman) ((rdman)->cr) 223 #define rdman_get_cr(rdman) ((rdman)->cr)
197 #define rdman_get_gen_geos(rdman) (&(rdman)->gen_geos) 224 #define rdman_get_gen_geos(rdman) (&(rdman)->gen_geos)
198 extern int rdman_add_gen_geos(redraw_man_t *rdman, geo_t *geo); 225 extern int rdman_add_gen_geos(redraw_man_t *rdman, geo_t *geo);
202 rdman_add_gen_geos(rdman, sh_get_geo(shape)) 229 rdman_add_gen_geos(rdman, sh_get_geo(shape))
203 #define rdman_shape_gl_len(rdman) \ 230 #define rdman_shape_gl_len(rdman) \
204 rdman_get_gen_geos(rdman)->num 231 rdman_get_gen_geos(rdman)->num
205 #define rdman_clear_shape_gl(rdman) \ 232 #define rdman_clear_shape_gl(rdman) \
206 DARRAY_CLEAN(rdman_get_gen_geos(rdman)) 233 DARRAY_CLEAN(rdman_get_gen_geos(rdman))
234 #define _coord_get_canvas(coord) ((coord)->canvas_info->canvas)
235 #define _coord_set_canvas(coord, _canvas) \
236 do { \
237 (coord)->canvas_info->canvas = _canvas; \
238 } while(0)
207 #define rdman_prop_store(rdman) ((rdman)->props) 239 #define rdman_prop_store(rdman) ((rdman)->props)
208 #define rdman_img_ldr(rdman) ((rdman)->img_ldr) 240 #define rdman_img_ldr(rdman) ((rdman)->img_ldr)
209 #define rdman_set_img_ldr(rdman, ldr) \ 241 #define rdman_set_img_ldr(rdman, ldr) \
210 do { (rdman)->img_ldr = ldr; } while(0) 242 do { (rdman)->img_ldr = ldr; } while(0)
243 /* @} */
211 244
212 /*! \brief Attach backend to the redraw manager so that we can hide the backend from the users. 245 /*! \brief Attach backend to the redraw manager so that we can hide the backend from the users.
213 * 246 *
214 */ 247 */
215 #define rdman_attach_backend(rdman,backend) (((rdman)->rt)=(backend)) 248 #define rdman_attach_backend(rdman,backend) (((rdman)->rt)=(backend))
216 /*! \brief Load sprite dymanicly from the shared object module.
217 *
218 * The search path can be changed by sprite_set_search_path. The name
219 * can have a relative path in the front of it.
220 * This function will search the object in the current working directory
221 * and then search the system search path.
222 */
223 extern mb_sprite_t *sprite_load(const char *name, redraw_man_t *rdman,
224 coord_t *root);
225
226 /*! \brief Set the search path of dymanic object loading.
227 *
228 */
229 extern void sprite_set_search_path(char *path);
230 249
231 extern paint_t *rdman_img_ldr_load_paint(redraw_man_t *rdman, 250 extern paint_t *rdman_img_ldr_load_paint(redraw_man_t *rdman,
232 const char *img_id); 251 const char *img_id);
233 252 /* @} */
234 typedef void (*mb_eventcb_t )(int fd,void *arg);
235 #define MONITOR_READ 1
236 #define MONITOR_WRITE 2
237
238 /*! \brief The backend engine mb_backend_t is used to define the interface to realize the MB.
239 *
240 * A backend is used to receive events from the system. The MB does not define the backend by itself.
241 * Instead, it define an interface which allow the lower layer to implement the event system. Each
242 * backend need to provides the following events.
243 *
244 * - keyboard event
245 * - timer event
246 * - image loader(?)
247 * - render manager(?)
248 */
249 typedef struct {
250
251 void *(*init)(char *display,int w,int h);
252 void (*free)(void *be);
253 void (*add_event)(void *be,int type, int fd, mb_eventcb_t f,void *arg);
254 void (*remove_event)(void *be,int type, int fd);
255 void (*loop)(void *be);
256 subject_t *(*kbevents)(void *be);
257 redraw_man_t *(*rdman)(void *be);
258 mb_tman_t *(*tman)(void *be);
259 ob_factory_t *(*factory)(void *be);
260 mb_img_ldr_t *(*loader)(void *be);
261 } mb_backend_t;
262
263 extern mb_backend_t backend;
264 253
265 #endif /* __REDRAW_MAN_H_ */ 254 #endif /* __REDRAW_MAN_H_ */