comparison include/mb_graph_engine_openvg.h @ 619:7020ed3c3e37 openvg

Actiavte a VGImage before using a pattern paint or image surface. - A VGImage can only activated for a pattern or an image in any instance. - _ge_openvg_img trace the object activated for currently and its deactivation function. - everytime a pattern paint or image surface will be used, the current activated one will be deactivated, and activate a new one.
author Thinker K.F. Li <thinker@branda.to>
date Thu, 08 Jul 2010 18:44:26 +0800
parents 35a67a837a53
children 3f544e876939
comparison
equal deleted inserted replaced
618:35a67a837a53 619:7020ed3c3e37
108 * 108 *
109 * A VGImage can associated one of pattern or surface. This type is 109 * A VGImage can associated one of pattern or surface. This type is
110 * used to make sure previous associated pattern or surface being 110 * used to make sure previous associated pattern or surface being
111 * released before new association. 111 * released before new association.
112 * 112 *
113 * Functions must release assocation specified by 113 * A _ge_openvg_img can be associated by mutltiple patterns and
114 * _ge_openvg_img::asso_pattern or _ge_openvg_img::asso_surface before 114 * surfaces. But, at most one of associated patterns or surfaces, the
115 * new association, and record new association as one of thes two 115 * _ge_openvg_img can be activated for at any instant.
116 * vairables. 116 * _ge_openvg_img::activated_for trace the object it being activated
117 * for. When a context will be current, the _ge_openvg_img associated
118 * with its surface would be activated for the surface. When a paint
119 * wil be used, the _ge_openvg_img associated must be activated for
120 * the paint. Before activated, the old activation must be
121 * deactivated. _ge_openvg_img::deactivate_func is a pointer to
122 * deactivation function of activated pattern or surface.
117 * 123 *
118 * \sa _ge_openvg_img_t 124 * \sa _ge_openvg_img_t
119 * \note This is type is for internal using of OpenVG graphic engine. 125 * \note This is type is for internal using of OpenVG graphic engine.
120 */ 126 */
121 struct _ge_openvg_img { 127 struct _ge_openvg_img {
122 int ref; 128 int ref;
123 VGImage img; 129 VGImage img;
124 mbe_pattern_t *asso_pattern; 130 void *activated_for;
125 mbe_surface_t *asso_surface; 131 void (*deactivate_func)(void *obj);
126 }; 132 };
127 133
128 #define MB_MATRIX_2_OPENVG(vgmtx, mtx) do { \ 134 #define MB_MATRIX_2_OPENVG(vgmtx, mtx) do { \
129 (vgmtx)[0] = (mtx)[0]; \ 135 (vgmtx)[0] = (mtx)[0]; \
130 (vgmtx)[1] = (mtx)[1]; \ 136 (vgmtx)[1] = (mtx)[1]; \
138 } while(0) 144 } while(0)
139 145
140 extern EGLNativeDisplayType _ge_openvg_disp_id; 146 extern EGLNativeDisplayType _ge_openvg_disp_id;
141 extern mbe_t *_ge_openvg_current_canvas; 147 extern mbe_t *_ge_openvg_current_canvas;
142 extern void _mbe_load_pattern_mtx(VGfloat *mtx1, VGfloat *mtx2, int mode); 148 extern void _mbe_load_pattern_mtx(VGfloat *mtx1, VGfloat *mtx2, int mode);
149 extern void _ge_vg_img_activate_for_pattern(mbe_pattern_t *ptn);
150 extern void _ge_vg_img_activate_for_surface(mbe_surface_t *surf);
143 151
144 extern mbe_pattern_t *mbe_pattern_create_for_surface(mbe_surface_t *surface); 152 extern mbe_pattern_t *mbe_pattern_create_for_surface(mbe_surface_t *surface);
145 extern mbe_pattern_t *mbe_pattern_create_radial(co_aix cx0, co_aix cy0, 153 extern mbe_pattern_t *mbe_pattern_create_radial(co_aix cx0, co_aix cy0,
146 co_aix radius0, 154 co_aix radius0,
147 co_aix cx1, co_aix cy1, 155 co_aix cx1, co_aix cy1,
173 eglMakeCurrent(_VG_DISPLAY(), \ 181 eglMakeCurrent(_VG_DISPLAY(), \
174 (canvas)->tgt->surface, \ 182 (canvas)->tgt->surface, \
175 (canvas)->tgt->surface, \ 183 (canvas)->tgt->surface, \
176 (canvas)->ctx); \ 184 (canvas)->ctx); \
177 } \ 185 } \
186 /* \sa _ge_openvg_img_t */ \
187 _ge_vg_img_activate_for_surface((canvas)->tgt); \
178 } while(0) 188 } while(0)
179 /* TODO: switch VGImage between VGPaint and surface. */ 189 /* TODO: switch VGImage between VGPaint and surface. */
180 #define _MK_CURRENT_PAINT(canvas) \ 190 #define _MK_CURRENT_PAINT(canvas) \
181 if((canvas)->paint_installed) { \ 191 do { \
182 vgSetPaint((canvas)->paint, VG_FILL_PATH|VG_STROKE_PATH); \ 192 if((canvas)->paint_installed == 0) { \
183 } 193 vgSetPaint((canvas)->paint, VG_FILL_PATH|VG_STROKE_PATH); \
194 (canvas)->paint_installed = 1; \
195 } \
196 /* \sa _ge_openvg_img_t */ \
197 if((canvas)->src) \
198 _ge_vg_img_activate_for_pattern((canvas)->src); \
199 } while(0)
184 200
185 #define mbe_transform(canvas, _mtx) \ 201 #define mbe_transform(canvas, _mtx) \
186 do { \ 202 do { \
187 _MK_CURRENT_CTX(canvas); \ 203 _MK_CURRENT_CTX(canvas); \
188 MB_MATRIX_2_OPENVG((canvas)->mtx, _mtx); \ 204 MB_MATRIX_2_OPENVG((canvas)->mtx, _mtx); \