Mercurial > MadButterfly
diff 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 |
line wrap: on
line diff
--- a/include/mb_graph_engine_openvg.h Thu Jul 08 13:51:47 2010 +0800 +++ b/include/mb_graph_engine_openvg.h Thu Jul 08 18:44:26 2010 +0800 @@ -110,10 +110,16 @@ * used to make sure previous associated pattern or surface being * released before new association. * - * Functions must release assocation specified by - * _ge_openvg_img::asso_pattern or _ge_openvg_img::asso_surface before - * new association, and record new association as one of thes two - * vairables. + * A _ge_openvg_img can be associated by mutltiple patterns and + * surfaces. But, at most one of associated patterns or surfaces, the + * _ge_openvg_img can be activated for at any instant. + * _ge_openvg_img::activated_for trace the object it being activated + * for. When a context will be current, the _ge_openvg_img associated + * with its surface would be activated for the surface. When a paint + * wil be used, the _ge_openvg_img associated must be activated for + * the paint. Before activated, the old activation must be + * deactivated. _ge_openvg_img::deactivate_func is a pointer to + * deactivation function of activated pattern or surface. * * \sa _ge_openvg_img_t * \note This is type is for internal using of OpenVG graphic engine. @@ -121,8 +127,8 @@ struct _ge_openvg_img { int ref; VGImage img; - mbe_pattern_t *asso_pattern; - mbe_surface_t *asso_surface; + void *activated_for; + void (*deactivate_func)(void *obj); }; #define MB_MATRIX_2_OPENVG(vgmtx, mtx) do { \ @@ -140,6 +146,8 @@ extern EGLNativeDisplayType _ge_openvg_disp_id; extern mbe_t *_ge_openvg_current_canvas; extern void _mbe_load_pattern_mtx(VGfloat *mtx1, VGfloat *mtx2, int mode); +extern void _ge_vg_img_activate_for_pattern(mbe_pattern_t *ptn); +extern void _ge_vg_img_activate_for_surface(mbe_surface_t *surf); extern mbe_pattern_t *mbe_pattern_create_for_surface(mbe_surface_t *surface); extern mbe_pattern_t *mbe_pattern_create_radial(co_aix cx0, co_aix cy0, @@ -175,12 +183,20 @@ (canvas)->tgt->surface, \ (canvas)->ctx); \ } \ + /* \sa _ge_openvg_img_t */ \ + _ge_vg_img_activate_for_surface((canvas)->tgt); \ } while(0) /* TODO: switch VGImage between VGPaint and surface. */ #define _MK_CURRENT_PAINT(canvas) \ - if((canvas)->paint_installed) { \ - vgSetPaint((canvas)->paint, VG_FILL_PATH|VG_STROKE_PATH); \ - } + do { \ + if((canvas)->paint_installed == 0) { \ + vgSetPaint((canvas)->paint, VG_FILL_PATH|VG_STROKE_PATH); \ + (canvas)->paint_installed = 1; \ + } \ + /* \sa _ge_openvg_img_t */ \ + if((canvas)->src) \ + _ge_vg_img_activate_for_pattern((canvas)->src); \ + } while(0) #define mbe_transform(canvas, _mtx) \ do { \