Mercurial > MadButterfly
comparison include/mb_graph_engine_openvg.h @ 612:b1d1b6c5af90 openvg
Implements setting pattern matrix for OpenVG
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 07 Jul 2010 18:44:17 +0800 |
parents | 38383f5f645d |
children | 9c5705da2495 |
comparison
equal
deleted
inserted
replaced
611:38383f5f645d | 612:b1d1b6c5af90 |
---|---|
19 #define mbe_image_surface_get_data(surface) ((unsigned char *)NULL) | 19 #define mbe_image_surface_get_data(surface) ((unsigned char *)NULL) |
20 #define mbe_scaled_font_reference(scaled) ((mbe_scaled_font_t *)NULL) | 20 #define mbe_scaled_font_reference(scaled) ((mbe_scaled_font_t *)NULL) |
21 #define mbe_scaled_font_destroy(scaled) | 21 #define mbe_scaled_font_destroy(scaled) |
22 #define mbe_font_face_reference(face) ((mbe_font_face_t *)NULL) | 22 #define mbe_font_face_reference(face) ((mbe_font_face_t *)NULL) |
23 #define mbe_scaled_font_create(face, fnt_mtx, ctm) ((mbe_scaled_font_t *)NULL) | 23 #define mbe_scaled_font_create(face, fnt_mtx, ctm) ((mbe_scaled_font_t *)NULL) |
24 #define mbe_pattern_set_matrix(ptn, mtx) | |
25 #define mbe_font_face_destroy(face) | 24 #define mbe_font_face_destroy(face) |
26 #define mbe_set_scaled_font(canvas, scaled) | 25 #define mbe_set_scaled_font(canvas, scaled) |
27 #define mbe_pattern_destroy(pattern) | 26 #define mbe_pattern_destroy(pattern) |
28 #define mbe_get_scaled_font(canvas) ((mbe_scaled_font_t *)NULL) | 27 #define mbe_get_scaled_font(canvas) ((mbe_scaled_font_t *)NULL) |
29 #define mbe_query_font_face(family, slant, weight) ((mbe_font_face_t *)NULL) | 28 #define mbe_query_font_face(family, slant, weight) ((mbe_font_face_t *)NULL) |
78 * the src pattern */ | 77 * the src pattern */ |
79 int paint_installed; | 78 int paint_installed; |
80 mbe_surface_t *tgt; | 79 mbe_surface_t *tgt; |
81 EGLContext ctx; | 80 EGLContext ctx; |
82 VGPath path; | 81 VGPath path; |
82 | |
83 VGfloat mtx[9]; | |
83 }; | 84 }; |
84 | 85 |
85 struct _ge_openvg_surface { | 86 struct _ge_openvg_surface { |
86 void *surface; | 87 void *surface; |
87 mbe_t *asso_mbe; /* There is a association between | 88 mbe_t *asso_mbe; /* There is a association between |
90 int w, h; | 91 int w, h; |
91 }; | 92 }; |
92 | 93 |
93 struct _ge_openvg_pattern { | 94 struct _ge_openvg_pattern { |
94 _ge_openvg_img_t *asso_img; | 95 _ge_openvg_img_t *asso_img; |
96 VGfloat mtx[9]; | |
95 VGPaint paint; | 97 VGPaint paint; |
96 }; | 98 }; |
97 | 99 |
98 /*! \brief Information associated with VGImage. | 100 /*! \brief Information associated with VGImage. |
99 * | 101 * |
127 (vgmtx)[8] = 1; \ | 129 (vgmtx)[8] = 1; \ |
128 } while(0) | 130 } while(0) |
129 | 131 |
130 extern EGLNativeDisplayType _ge_openvg_disp_id; | 132 extern EGLNativeDisplayType _ge_openvg_disp_id; |
131 extern mbe_t *_ge_openvg_current_canvas; | 133 extern mbe_t *_ge_openvg_current_canvas; |
134 extern void _mbe_load_pattern_mtx(VGfloat *mtx1, VGfloat *mtx2, int mode); | |
132 | 135 |
133 extern mbe_pattern_t *mbe_pattern_create_for_surface(mbe_surface_t *surface); | 136 extern mbe_pattern_t *mbe_pattern_create_for_surface(mbe_surface_t *surface); |
134 extern mbe_pattern_t *mbe_pattern_create_radial(co_aix cx0, co_aix cy0, | 137 extern mbe_pattern_t *mbe_pattern_create_radial(co_aix cx0, co_aix cy0, |
135 co_aix radius0, | 138 co_aix radius0, |
136 co_aix cx1, co_aix cy1, | 139 co_aix cx1, co_aix cy1, |
140 extern mbe_pattern_t *mbe_pattern_create_linear(co_aix x0, co_aix y0, | 143 extern mbe_pattern_t *mbe_pattern_create_linear(co_aix x0, co_aix y0, |
141 co_aix x1, co_aix y1, | 144 co_aix x1, co_aix y1, |
142 grad_stop_t *stops, | 145 grad_stop_t *stops, |
143 int stop_cnt); | 146 int stop_cnt); |
144 extern mbe_pattern_t *mbe_pattern_create_image(mb_img_data_t *img); | 147 extern mbe_pattern_t *mbe_pattern_create_image(mb_img_data_t *img); |
148 extern void mbe_pattern_set_matrix(mbe_pattern_t *ptn, co_aix *mtx); | |
145 extern void mbe_set_source_rgba(mbe_t *canvas, co_comp_t r, co_comp_t g, | 149 extern void mbe_set_source_rgba(mbe_t *canvas, co_comp_t r, co_comp_t g, |
146 co_comp_t b, co_comp_t a); | 150 co_comp_t b, co_comp_t a); |
147 /* TODO: rename n_areas to areas_cnt and make it after areas */ | 151 /* TODO: rename n_areas to areas_cnt and make it after areas */ |
148 extern void mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas); | 152 extern void mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas); |
149 | 153 |
163 (canvas)->ctx); \ | 167 (canvas)->ctx); \ |
164 } \ | 168 } \ |
165 } while(0) | 169 } while(0) |
166 /* TODO: switch VGImage between VGPaint and surface. */ | 170 /* TODO: switch VGImage between VGPaint and surface. */ |
167 #define _MK_CURRENT_PAINT(canvas) \ | 171 #define _MK_CURRENT_PAINT(canvas) \ |
168 if((canvas)->paint_installed) \ | 172 if((canvas)->paint_installed) { \ |
169 vgSetPaint((canvas)->paint, VG_FILL_PATH|VG_STROKE_PATH) | 173 vgSetPaint((canvas)->paint, VG_FILL_PATH|VG_STROKE_PATH); \ |
170 | 174 } |
171 static void | 175 |
172 mbe_transform(mbe_t *canvas, co_aix *mtx) { | 176 #define mbe_transform(canvas, _mtx) \ |
173 VGfloat vg_mtx[9]; | 177 do { \ |
174 | 178 MB_MATRIX_2_OPENVG((canvas)->mtx, _mtx); \ |
175 _MK_CURRENT_CTX(canvas); | 179 _mbe_load_pattern_mtx(_mtx, NULL, \ |
176 MB_MATRIX_2_OPENVG(vg_mtx, mtx); | 180 VG_MATRIX_PATH_USER_TO_SURFACE); \ |
177 vgLoadMatrix(vg_mtx); | 181 } while(0) |
178 } | 182 |
179 | 183 |
180 #define EGL_GLX 1 | 184 #define EGL_GLX 1 |
181 #ifdef EGL_GLX | 185 #ifdef EGL_GLX |
182 #include <X11/Xlib.h> | 186 #include <X11/Xlib.h> |
183 #include <X11/Xutil.h> | 187 #include <X11/Xutil.h> |
215 | 219 |
216 static void | 220 static void |
217 mbe_stroke(mbe_t *canvas) { | 221 mbe_stroke(mbe_t *canvas) { |
218 _MK_CURRENT_CTX(canvas); | 222 _MK_CURRENT_CTX(canvas); |
219 _MK_CURRENT_PAINT(canvas); | 223 _MK_CURRENT_PAINT(canvas); |
224 if(canvas->src) | |
225 _mbe_load_pattern_mtx(canvas->src->mtx, NULL, | |
226 VG_MATRIX_STROKE_PAINT_TO_USER); | |
220 | 227 |
221 vgDrawPath(canvas->path, VG_STROKE_PATH); | 228 vgDrawPath(canvas->path, VG_STROKE_PATH); |
222 vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL); | 229 vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL); |
223 } | 230 } |
224 | 231 |
225 static void | 232 static void |
226 mbe_fill(mbe_t *canvas) { | 233 mbe_fill(mbe_t *canvas) { |
227 _MK_CURRENT_CTX(canvas); | 234 _MK_CURRENT_CTX(canvas); |
228 _MK_CURRENT_PAINT(canvas); | 235 _MK_CURRENT_PAINT(canvas); |
236 if(canvas->src) | |
237 _mbe_load_pattern_mtx(canvas->src->mtx, NULL, | |
238 VG_MATRIX_FILL_PAINT_TO_USER); | |
229 | 239 |
230 vgDrawPath(canvas->path, VG_FILL_PATH); | 240 vgDrawPath(canvas->path, VG_FILL_PATH); |
231 vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL); | 241 vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL); |
232 } | 242 } |
233 | 243 |