Mercurial > MadButterfly
comparison include/mb_graph_engine.h @ 450:a417fd980228
Replace cairo_format_t with mb_img_fmt_t.
- Replace all CAIRO_FORAMT_* with MB_IFMT_*
- wrap functions return or are argumented with image format.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 05 Aug 2009 15:54:44 +0800 |
parents | c525edac917e |
children | 5c9e2a8a4bd8 |
comparison
equal
deleted
inserted
replaced
449:c525edac917e | 450:a417fd980228 |
---|---|
1 #ifndef __MBE_H_ | 1 #ifndef __MBE_H_ |
2 #define __MBE_H_ | 2 #define __MBE_H_ |
3 | 3 |
4 #include <stdio.h> | |
4 #include <cairo.h> | 5 #include <cairo.h> |
6 #include "mb_img_ldr.h" | |
7 | |
8 /*! \defgroup mb_graph_engine MadButterfly Graphic Engine | |
9 * @{ | |
10 */ | |
11 #define MBE_OPERATOR_CLEAR CAIRO_OPERATOR_CLEAR | |
12 #define MBE_OPERATOR_SOURCE CAIRO_OPERATOR_SOURCE | |
13 #define MBE_STATUS_SUCCESS CAIRO_STATUS_SUCCESS | |
5 | 14 |
6 #define mbe_ft_font_face_create_for_pattern cairo_ft_font_face_create_for_pattern | 15 #define mbe_ft_font_face_create_for_pattern cairo_ft_font_face_create_for_pattern |
7 #define mbe_image_surface_create_from_png cairo_image_surface_create_from_png | 16 #define mbe_image_surface_create_from_png cairo_image_surface_create_from_png |
8 #define mbe_image_surface_create_for_data cairo_image_surface_create_for_data | |
9 #define mbe_pattern_add_color_stop_rgba cairo_pattern_add_color_stop_rgba | 17 #define mbe_pattern_add_color_stop_rgba cairo_pattern_add_color_stop_rgba |
10 #define mbe_pattern_create_for_surface cairo_pattern_create_for_surface | 18 #define mbe_pattern_create_for_surface cairo_pattern_create_for_surface |
11 #define mbe_scaled_font_text_extents cairo_scaled_font_text_extents | 19 #define mbe_scaled_font_text_extents cairo_scaled_font_text_extents |
12 #define mbe_image_surface_get_stride cairo_image_surface_get_stride | 20 #define mbe_image_surface_get_stride cairo_image_surface_get_stride |
13 #define mbe_image_surface_get_height cairo_image_surface_get_height | 21 #define mbe_image_surface_get_height cairo_image_surface_get_height |
14 #define mbe_image_surface_get_format cairo_image_surface_get_format | |
15 #define mbe_image_surface_get_width cairo_image_surface_get_width | 22 #define mbe_image_surface_get_width cairo_image_surface_get_width |
16 #define mbe_image_surface_get_data cairo_image_surface_get_data | 23 #define mbe_image_surface_get_data cairo_image_surface_get_data |
17 #define mbe_scaled_font_reference cairo_scaled_font_reference | 24 #define mbe_scaled_font_reference cairo_scaled_font_reference |
18 #define mbe_pattern_create_radial cairo_pattern_create_radial | 25 #define mbe_pattern_create_radial cairo_pattern_create_radial |
19 #define mbe_pattern_create_linear cairo_pattern_create_linear | 26 #define mbe_pattern_create_linear cairo_pattern_create_linear |
20 #define mbe_image_surface_create cairo_image_surface_create | |
21 #define mbe_xlib_surface_create cairo_xlib_surface_create | 27 #define mbe_xlib_surface_create cairo_xlib_surface_create |
22 #define mbe_scaled_font_destroy cairo_scaled_font_destroy | 28 #define mbe_scaled_font_destroy cairo_scaled_font_destroy |
23 #define mbe_font_options_create cairo_font_options_create | 29 #define mbe_font_options_create cairo_font_options_create |
24 #define mbe_font_face_reference cairo_font_face_reference | 30 #define mbe_font_face_reference cairo_font_face_reference |
25 #define mbe_set_source_surface cairo_set_source_surface | 31 #define mbe_set_source_surface cairo_set_source_surface |
32 #define mbe_surface_destroy cairo_surface_destroy | 38 #define mbe_surface_destroy cairo_surface_destroy |
33 #define mbe_set_source_rgba cairo_set_source_rgba | 39 #define mbe_set_source_rgba cairo_set_source_rgba |
34 #define mbe_set_scaled_font cairo_set_scaled_font | 40 #define mbe_set_scaled_font cairo_set_scaled_font |
35 #define mbe_pattern_destroy cairo_pattern_destroy | 41 #define mbe_pattern_destroy cairo_pattern_destroy |
36 #define mbe_get_scaled_font cairo_get_scaled_font | 42 #define mbe_get_scaled_font cairo_get_scaled_font |
37 #define mbe_text_extents_t cairo_text_extents_t | |
38 #define mbe_set_source_rgb cairo_set_source_rgb | 43 #define mbe_set_source_rgb cairo_set_source_rgb |
39 #define mbe_set_line_width cairo_set_line_width | 44 #define mbe_set_line_width cairo_set_line_width |
40 #define mbe_font_options_t cairo_font_options_t | |
41 #define mbe_scaled_font_t cairo_scaled_font_t | |
42 #define mbe_get_font_face cairo_get_font_face | 45 #define mbe_get_font_face cairo_get_font_face |
43 #define mbe_fill_preserve cairo_fill_preserve | 46 #define mbe_fill_preserve cairo_fill_preserve |
44 #define mbe_set_operator cairo_set_operator | 47 #define mbe_set_operator cairo_set_operator |
45 #define mbe_get_operator cairo_get_operator | 48 #define mbe_get_operator cairo_get_operator |
46 #define mbe_arc_negative cairo_arc_negative | 49 #define mbe_arc_negative cairo_arc_negative |
47 #define mbe_font_face_t cairo_font_face_t | |
48 #define mbe_set_source cairo_set_source | 50 #define mbe_set_source cairo_set_source |
49 #define mbe_reset_clip cairo_reset_clip | 51 #define mbe_reset_clip cairo_reset_clip |
50 #define mbe_operator_t cairo_operator_t | |
51 #define mbe_get_target cairo_get_target | 52 #define mbe_get_target cairo_get_target |
52 #define mbe_close_path cairo_close_path | 53 #define mbe_close_path cairo_close_path |
53 #define mbe_translate cairo_translate | 54 #define mbe_translate cairo_translate |
54 #define mbe_text_path cairo_text_path | 55 #define mbe_text_path cairo_text_path |
55 #define mbe_surface_t cairo_surface_t | |
56 #define mbe_show_text cairo_show_text | 56 #define mbe_show_text cairo_show_text |
57 #define mbe_rectangle cairo_rectangle | 57 #define mbe_rectangle cairo_rectangle |
58 #define mbe_pattern_t cairo_pattern_t | |
59 #define mbe_in_stroke cairo_in_stroke | 58 #define mbe_in_stroke cairo_in_stroke |
60 #define mbe_status_t cairo_status_t | |
61 #define mbe_new_path cairo_new_path | 59 #define mbe_new_path cairo_new_path |
62 #define mbe_matrix_t cairo_matrix_t | |
63 #define mbe_format_t cairo_format_t | |
64 #define mbe_curve_to cairo_curve_to | 60 #define mbe_curve_to cairo_curve_to |
65 #define mbe_restore cairo_restore | 61 #define mbe_restore cairo_restore |
66 #define mbe_move_to cairo_move_to | 62 #define mbe_move_to cairo_move_to |
67 #define mbe_line_to cairo_line_to | 63 #define mbe_line_to cairo_line_to |
68 #define mbe_in_fill cairo_in_fill | 64 #define mbe_in_fill cairo_in_fill |
69 #define mbe_destroy cairo_destroy | 65 #define mbe_destroy cairo_destroy |
70 #define mbe_stroke cairo_stroke | 66 #define mbe_stroke cairo_stroke |
71 #define mbe_rotate cairo_rotate | 67 #define mbe_rotate cairo_rotate |
72 #define mbe_line_t cairo_line_t | |
73 #define mbe_create cairo_create | 68 #define mbe_create cairo_create |
74 #define mbe_scale cairo_scale | 69 #define mbe_scale cairo_scale |
75 #define mbe_paint cairo_paint | 70 #define mbe_paint cairo_paint |
76 #define mbe_save cairo_save | 71 #define mbe_save cairo_save |
77 #define mbe_fill cairo_fill | 72 #define mbe_fill cairo_fill |
78 #define mbe_clip cairo_clip | 73 #define mbe_clip cairo_clip |
79 #define mbe_arc cairo_arc | 74 #define mbe_arc cairo_arc |
80 #define mbe_t cairo_t | 75 |
76 typedef cairo_text_extents_t mbe_text_extents_t; | |
77 typedef cairo_font_options_t mbe_font_options_t; | |
78 typedef cairo_scaled_font_t mbe_scaled_font_t; | |
79 typedef cairo_font_face_t mbe_font_face_t; | |
80 typedef cairo_operator_t mbe_operator_t; | |
81 typedef cairo_surface_t mbe_surface_t; | |
82 typedef cairo_pattern_t mbe_pattern_t; | |
83 typedef cairo_status_t mbe_status_t; | |
84 typedef cairo_matrix_t mbe_matrix_t; | |
85 typedef cairo_t mbe_t; | |
86 | |
87 static mbe_surface_t * | |
88 mbe_image_surface_create_for_data(unsigned char *data, | |
89 mb_img_fmt_t fmt, | |
90 int width, int height, | |
91 int stride) { | |
92 cairo_format_t _fmt; | |
93 | |
94 switch(fmt) { | |
95 case MB_IFMT_ARGB32: | |
96 _fmt = CAIRO_FORMAT_ARGB32; | |
97 break; | |
98 case MB_IFMT_RGB24: | |
99 _fmt = CAIRO_FORMAT_RGB24; | |
100 break; | |
101 case MB_IFMT_A8: | |
102 _fmt = CAIRO_FORMAT_A8; | |
103 break; | |
104 case MB_IFMT_A1: | |
105 _fmt = CAIRO_FORMAT_A1; | |
106 break; | |
107 default: | |
108 return NULL; | |
109 } | |
110 return cairo_image_surface_create_for_data(data, _fmt, | |
111 width, height, stride); | |
112 } | |
113 | |
114 static mb_img_fmt_t | |
115 mbe_image_surface_get_format(mbe_surface_t *surface) { | |
116 cairo_format_t _fmt; | |
117 mb_img_fmt_t fmt; | |
118 | |
119 _fmt = cairo_image_surface_get_format(surface); | |
120 switch(_fmt) { | |
121 case CAIRO_FORMAT_ARGB32: | |
122 fmt = MB_IFMT_ARGB32; | |
123 break; | |
124 case CAIRO_FORMAT_RGB24: | |
125 fmt = MB_IFMT_RGB24; | |
126 break; | |
127 case CAIRO_FORMAT_A8: | |
128 fmt = MB_IFMT_A8; | |
129 break; | |
130 case CAIRO_FORMAT_A1: | |
131 fmt = MB_IFMT_A1; | |
132 break; | |
133 default: | |
134 fmt = MB_IFMT_DUMMY; | |
135 break; | |
136 } | |
137 | |
138 return fmt; | |
139 } | |
140 | |
141 static mbe_surface_t * | |
142 mbe_image_surface_create(mb_img_fmt_t fmt, int width, int height) { | |
143 cairo_format_t _fmt; | |
144 | |
145 switch(fmt) { | |
146 case MB_IFMT_ARGB32: | |
147 _fmt = CAIRO_FORMAT_ARGB32; | |
148 break; | |
149 case MB_IFMT_RGB24: | |
150 _fmt = CAIRO_FORMAT_RGB24; | |
151 break; | |
152 case MB_IFMT_A8: | |
153 _fmt = CAIRO_FORMAT_A8; | |
154 break; | |
155 case MB_IFMT_A1: | |
156 _fmt = CAIRO_FORMAT_A1; | |
157 break; | |
158 default: | |
159 return NULL; | |
160 } | |
161 | |
162 return cairo_image_surface_create(_fmt, width, height); | |
163 } | |
164 | |
165 /* @} */ | |
81 | 166 |
82 #endif /* __MBE_H_ */ | 167 #endif /* __MBE_H_ */ |