/[zanavi_public1]/navit/navit/graphics.h
ZANavi

Diff of /navit/navit/graphics.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2 Revision 28
19 19
20#ifndef NAVIT_GRAPHICS_H 20#ifndef NAVIT_GRAPHICS_H
21#define NAVIT_GRAPHICS_H 21#define NAVIT_GRAPHICS_H
22 22
23#ifdef __cplusplus 23#ifdef __cplusplus
24extern "C" { 24extern "C"
25{
25#endif 26#endif
26struct attr; 27struct attr;
27struct point; 28struct point;
28struct container; 29struct container;
29struct color; 30struct color;
33struct graphics_image; 34struct graphics_image;
34struct transformation; 35struct transformation;
35struct display_list; 36struct display_list;
36struct mapset; 37struct mapset;
37 38
38enum draw_mode_num { 39enum draw_mode_num
39 draw_mode_begin, draw_mode_begin_clear, draw_mode_end, draw_mode_cursor, draw_mode_end_lazy 40{
41 draw_mode_begin,
42 draw_mode_begin_clear,
43 draw_mode_end,
44 draw_mode_cursor,
45 draw_mode_end_lazy
46};
47
48#include "item.h"
49
50struct display_context
51{
52 struct graphics *gra;
53 struct element *e;
54 struct graphics_gc *gc;
55 struct graphics_gc *gc_background;
56 struct graphics_image *img;
57 enum projection pro;
58 int mindist;
59 struct transformation *trans;
60 enum item_type type;
61 int maxlen;
62};
63
64//#define HASH_SIZE_GRAPHICS_ 1024
65#define HASH_SIZE_GRAPHICS_ 2048 // inc. hash size for layer items
66
67struct hash_entry
68{
69 enum item_type type;
70 struct displayitem *di;
71};
72
73struct displaylist
74{
75 int busy;
76 int workload;
77 struct callback *cb;
78 struct layout *layout, *layout_hashed;
79 struct display_context dc;
80 int order, order_hashed, max_offset;
81 struct mapset *ms;
82 struct mapset_handle *msh;
83 struct map *m;
84 int conv;
85 struct map_selection *sel;
86 struct map_rect *mr;
87 struct callback *idle_cb;
88 struct event_idle *idle_ev;
89 unsigned int seq;
90 struct hash_entry hash_entries[HASH_SIZE_GRAPHICS_];
40}; 91};
41 92
42struct graphics_priv; 93struct graphics_priv;
43struct graphics_font_priv; 94struct graphics_font_priv;
44struct graphics_image_priv; 95struct graphics_image_priv;
45struct graphics_gc_priv; 96struct graphics_gc_priv;
46struct graphics_font_methods; 97struct graphics_font_methods;
47struct graphics_gc_methods; 98struct graphics_gc_methods;
48struct graphics_image_methods; 99struct graphics_image_methods;
49 100
50struct graphics_methods { 101struct graphics_methods
102{
51 void (*graphics_destroy)(struct graphics_priv *gr); 103 void (*graphics_destroy)(struct graphics_priv *gr);
52 void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode); 104 void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode);
53 void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count); 105 void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
54 void (*draw_lines2)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int oneway); 106 struct point *p, int count);
55 void (*draw_lines_dashed)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int oneway); 107 void (*draw_lines2)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
108 struct point *p, int count, int order, int oneway);
109 void (*draw_lines3)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
110 struct point *p, int count, int order, int width);
111 void (*draw_lines4)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
112 struct point *p, int count, int order, int width, int type);
113 void (*draw_lines_dashed)(struct graphics_priv *gr,
114 struct graphics_gc_priv *gc, struct point *p, int count, int order,
115 int oneway);
56 void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count); 116 void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
57 void (*draw_polygon2)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int oneway); 117 struct point *p, int count);
58 void (*draw_rectangle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h); 118 void (*draw_polygon2)(struct graphics_priv *gr,
119 struct graphics_gc_priv *gc, struct point *p, int count, int order,
120 int oneway);
121 void (*draw_rectangle)(struct graphics_priv *gr,
122 struct graphics_gc_priv *gc, struct point *p, int w, int h);
59 void (*draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r); 123 void (*draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
60 void (*draw_text)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy); 124 struct point *p, int r);
61 void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img); 125 void (*draw_text)(struct graphics_priv *gr, struct graphics_gc_priv *fg,
62 void (*draw_bigmap)(struct graphics_priv *gr, struct graphics_gc_priv *fg, int yaw, int order, float clat, float clng, int x, int y, int scx, int scy, int px, int py, int valid); 126 struct graphics_gc_priv *bg, struct graphics_font_priv *font,
63 void (*send_osd_values)(struct graphics_priv *gr, struct graphics_gc_priv *fg, char *id, char *text1, char *text2, char *text3, int i1, int i2, int i3, int i4, float f1, float f2, float f3); 127 char *text, struct point *p, int dx, int dy);
64 void (*draw_image_warp)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data); 128 void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg,
129 struct point *p, struct graphics_image_priv *img);
130 void (*draw_bigmap)(struct graphics_priv *gr, struct graphics_gc_priv *fg,
131 int yaw, int order, float clat, float clng, int x, int y, int scx,
132 int scy, int px, int py, int valid);
133 void (*send_osd_values)(struct graphics_priv *gr,
134 struct graphics_gc_priv *fg, char *id, char *text1, char *text2,
135 char *text3, int i1, int i2, int i3, int i4, float f1, float f2,
136 float f3);
137 void
138 (*draw_image_warp)(struct graphics_priv *gr,
139 struct graphics_gc_priv *fg, struct point *p, int count,
140 char *data);
65 void (*draw_restore)(struct graphics_priv *gr, struct point *p, int w, int h); 141 void (*draw_restore)(struct graphics_priv *gr, struct point *p, int w,
142 int h);
66 void (*draw_drag)(struct graphics_priv *gr, struct point *p); 143 void (*draw_drag)(struct graphics_priv *gr, struct point *p);
67 struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags); 144 struct graphics_font_priv
145 *(*font_new)(struct graphics_priv *gr,
146 struct graphics_font_methods *meth, char *font, int size,
147 int flags);
68 struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth); 148 struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr,
69 void (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc); 149 struct graphics_gc_methods *meth);
70 struct graphics_priv *(*overlay_new)(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int alpha, int wraparound); 150 void
71 struct graphics_image_priv *(*image_new)(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation); 151 (*background_gc)(struct graphics_priv *gr,
152 struct graphics_gc_priv *gc);
153 struct graphics_priv *(*overlay_new)(struct graphics_priv *gr,
154 struct graphics_methods *meth, struct point *p, int w, int h,
155 int alpha, int wraparound);
156 struct graphics_image_priv *(*image_new)(struct graphics_priv *gr,
157 struct graphics_image_methods *meth, char *path, int *w, int *h,
158 struct point *hot, int rotation);
72 void *(*get_data)(struct graphics_priv *gr, const char *type); 159 void *(*get_data)(struct graphics_priv *gr, const char *type);
73 void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv); 160 void (*image_free)(struct graphics_priv *gr,
74 void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate); 161 struct graphics_image_priv *priv);
162 void (*get_text_bbox)(struct graphics_priv *gr,
163 struct graphics_font_priv *font, char *text, int dx, int dy,
164 struct point *ret, int estimate);
75 void (*overlay_disable)(struct graphics_priv *gr, int disable); 165 void (*overlay_disable)(struct graphics_priv *gr, int disable);
76 void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w, int h, int alpha, int wraparound); 166 void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w,
167 int h, int alpha, int wraparound);
77 int (*set_attr)(struct graphics_priv *gr, struct attr *attr); 168 int (*set_attr)(struct graphics_priv *gr, struct attr *attr);
78}; 169};
79 170
80
81struct graphics_font_methods { 171struct graphics_font_methods
172{
82 void (*font_destroy)(struct graphics_font_priv *font); 173 void (*font_destroy)(struct graphics_font_priv *font);
83}; 174};
84 175
85struct graphics_font { 176struct graphics_font
177{
86 struct graphics_font_priv *priv; 178 struct graphics_font_priv *priv;
87 struct graphics_font_methods meth; 179 struct graphics_font_methods meth;
88}; 180};
89 181
90struct graphics_gc_methods { 182struct graphics_gc_methods
183{
91 void (*gc_destroy)(struct graphics_gc_priv *gc); 184 void (*gc_destroy)(struct graphics_gc_priv *gc);
92 void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width); 185 void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width);
93 void (*gc_set_dashes)(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n); 186 void (*gc_set_dashes)(struct graphics *gra, struct graphics_gc_priv *gc, int width, int offset,
187 int dash_list[], int order);
94 void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c); 188 void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c);
95 void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c); 189 void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c);
96 void (*gc_set_stipple)(struct graphics_gc_priv *gc, struct graphics_image_priv *img); 190 void (*gc_set_stipple)(struct graphics_gc_priv *gc,
191 struct graphics_image_priv *img);
97}; 192};
98 193
99struct graphics_gc { 194struct graphics_gc
195{
100 struct graphics_gc_priv *priv; 196 struct graphics_gc_priv *priv;
101 struct graphics_gc_methods meth; 197 struct graphics_gc_methods meth;
102 struct graphics *gra; 198 struct graphics *gra;
103}; 199};
104 200
105struct graphics_image_methods { 201struct graphics_image_methods
202{
106 void (*image_destroy)(struct graphics_image_priv *img); 203 void (*image_destroy)(struct graphics_image_priv *img);
107}; 204};
108 205
109struct graphics_image { 206struct graphics_image
207{
110 struct graphics_image_priv *priv; 208 struct graphics_image_priv *priv;
111 struct graphics_image_methods meth; 209 struct graphics_image_methods meth;
112 int width; 210 int width;
113 int height; 211 int height;
114 struct point hot; 212 struct point hot;
115}; 213};
116 214
117struct graphics_data_image { 215struct graphics_data_image
216{
118 void *data; 217 void *data;
119 int size; 218 int size;
120}; 219};
121 220
122/* prototypes */ 221/* prototypes */
142struct point_rect; 241struct point_rect;
143struct transformation; 242struct transformation;
144int graphics_set_attr(struct graphics *gra, struct attr *attr); 243int graphics_set_attr(struct graphics *gra, struct attr *attr);
145void graphics_set_rect(struct graphics *gra, struct point_rect *pr); 244void graphics_set_rect(struct graphics *gra, struct point_rect *pr);
146struct graphics *graphics_new(struct attr *parent, struct attr **attrs); 245struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
147int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter); 246int graphics_get_attr(struct graphics *this_, enum attr_type type,
247 struct attr *attr, struct attr_iter *iter);
148struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h, int alpha, int wraparound); 248struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p,
249 int w, int h, int alpha, int wraparound);
149void graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int alpha, int wraparound); 250void graphics_overlay_resize(struct graphics *this_, struct point *p, int w,
251 int h, int alpha, int wraparound);
150void graphics_init(struct graphics *this_); 252void graphics_init(struct graphics *this_);
151void *graphics_get_data(struct graphics *this_, const char *type); 253void *graphics_get_data(struct graphics *this_, const char *type);
152void graphics_add_callback(struct graphics *this_, struct callback *cb); 254void graphics_add_callback(struct graphics *this_, struct callback *cb);
153void graphics_remove_callback(struct graphics *this_, struct callback *cb); 255void graphics_remove_callback(struct graphics *this_, struct callback *cb);
154struct graphics_font *graphics_font_new(struct graphics *gra, int size, int flags); 256struct graphics_font *graphics_font_new(struct graphics *gra, int size,
257 int flags);
155struct graphics_font *graphics_named_font_new(struct graphics *gra, char *font, int size, int flags); 258struct graphics_font *graphics_named_font_new(struct graphics *gra, char *font,
259 int size, int flags);
156void graphics_free(struct graphics *gra); 260void graphics_free(struct graphics *gra);
157void graphics_font_destroy_all(struct graphics *gra); 261void graphics_font_destroy_all(struct graphics *gra);
158struct graphics_gc *graphics_gc_new(struct graphics *gra); 262struct graphics_gc *graphics_gc_new(struct graphics *gra);
159void graphics_gc_destroy(struct graphics_gc *gc); 263void graphics_gc_destroy(struct graphics_gc *gc);
160void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c); 264void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
161void graphics_gc_set_background(struct graphics_gc *gc, struct color *c); 265void graphics_gc_set_background(struct graphics_gc *gc, struct color *c);
162void graphics_gc_set_stipple(struct graphics_gc *gc, struct graphics_image *img); 266void
267 graphics_gc_set_stipple(struct graphics_gc *gc,
268 struct graphics_image *img);
163void graphics_gc_set_linewidth(struct graphics_gc *gc, int width); 269void graphics_gc_set_linewidth(struct graphics_gc *gc, int width);
164void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n); 270void graphics_gc_set_dashes(struct graphics *gra, struct graphics_gc *gc, int width, int offset,
271 int dash_list[], int n, int order);
165struct graphics_image *graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h); 272struct graphics_image *graphics_image_new_scaled(struct graphics *gra,
273 char *path, int w, int h);
166struct graphics_image *graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate); 274struct graphics_image *graphics_image_new_scaled_rotated(struct graphics *gra,
275 char *path, int w, int h, int rotate);
167struct graphics_image *graphics_image_new(struct graphics *gra, char *path); 276struct graphics_image *graphics_image_new(struct graphics *gra, char *path);
168void graphics_image_free(struct graphics *gra, struct graphics_image *img); 277void graphics_image_free(struct graphics *gra, struct graphics_image *img);
169void graphics_draw_restore(struct graphics *this_, struct point *p, int w, int h); 278void graphics_draw_restore(struct graphics *this_, struct point *p, int w,
279 int h);
170void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode); 280void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode);
171void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count); 281void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc,
282 struct point *p, int count);
172void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r); 283void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc,
284 struct point *p, int r);
173void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h); 285void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc,
174void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill); 286 struct point *p, int w, int h);
175void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2, struct graphics_font *font, char *text, struct point *p, int dx, int dy); 287void graphics_draw_rectangle_rounded(struct graphics *this_,
176void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate); 288 struct graphics_gc *gc, struct point *plu, int w, int h, int r,
289 int fill);
290void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1,
291 struct graphics_gc *gc2, struct graphics_font *font, char *text,
292 struct point *p, int dx, int dy);
293void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font,
294 char *text, int dx, int dy, struct point *ret, int estimate);
177void graphics_overlay_disable(struct graphics *this_, int disable); 295void graphics_overlay_disable(struct graphics *this_, int disable);
178void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img); 296void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc,
297 struct point *p, struct graphics_image *img);
179int graphics_draw_drag(struct graphics *this_, struct point *p); 298int graphics_draw_drag(struct graphics *this_, struct point *p);
180void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc); 299void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
181void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p); 300void graphics_draw_text_std(struct graphics *this_, int text_size, char *text,
301 struct point *p);
182char *graphics_icon_path(char *icon); 302char *graphics_icon_path(char *icon);
183void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label); 303void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm,
184void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags); 304 struct transformation *t, char *label);
185void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags); 305void graphics_displaylist_draw(struct graphics *gra,
306 struct displaylist *displaylist, struct transformation *trans,
307 struct layout *l, int flags);
308void graphics_draw(struct graphics *gra, struct displaylist *displaylist,
309 struct mapset *mapset, struct transformation *trans, struct layout *l,
310 int async, struct callback *cb, int flags);
186int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist); 311int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist);
187struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist); 312struct displaylist_handle *graphics_displaylist_open(
313 struct displaylist *displaylist);
188struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh); 314struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
189void graphics_displaylist_close(struct displaylist_handle *dlh); 315void graphics_displaylist_close(struct displaylist_handle *dlh);
190struct displaylist *graphics_displaylist_new(void); 316struct displaylist *graphics_displaylist_new(void);
191struct item *graphics_displayitem_get_item(struct displayitem *di); 317struct item *graphics_displayitem_get_item(struct displayitem *di);
192int graphics_displayitem_get_coord_count(struct displayitem *di); 318int graphics_displayitem_get_coord_count(struct displayitem *di);
193char *graphics_displayitem_get_label(struct displayitem *di); 319char *graphics_displayitem_get_label(struct displayitem *di);
194int graphics_displayitem_get_displayed(struct displayitem *di); 320int graphics_displayitem_get_displayed(struct displayitem *di);
195int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist); 321int graphics_displayitem_within_dist(struct displaylist *displaylist,
196void graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl); 322 struct displayitem *di, struct point *p, int dist);
323void graphics_add_selection(struct graphics *gra, struct item *item,
324 enum item_type type, struct displaylist *dl);
197void graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl); 325void graphics_remove_selection(struct graphics *gra, struct item *item,
326 enum item_type type, struct displaylist *dl);
198void graphics_clear_selection(struct graphics *gra, struct displaylist *dl); 327void graphics_clear_selection(struct graphics *gra, struct displaylist *dl);
199/* end of prototypes */ 328/* end of prototypes */
200#ifdef __cplusplus 329#ifdef __cplusplus
201} 330}
202#endif 331#endif

Legend:
Removed from v.2  
changed lines
  Added in v.28

   
Visit the ZANavi Wiki