# HG changeset patch # User Thinker K.F. Li # Date 1277897432 -28800 # Node ID b714f0c9992eed19e019b28f0f69507d724f9b54 # Parent d733e198bb25a2a2670857966e43f82470378101 include a VGPath in VG canvas diff -r d733e198bb25 -r b714f0c9992e include/mb_graph_engine_openvg.h --- a/include/mb_graph_engine_openvg.h Wed Jun 30 18:06:36 2010 +0800 +++ b/include/mb_graph_engine_openvg.h Wed Jun 30 19:30:32 2010 +0800 @@ -62,7 +62,6 @@ #define mbe_move_to(canvas, x, y) #define mbe_line_to(canvas, x, y) #define mbe_in_fill(canvas, x, y) (0) -#define mbe_destroy(canvas) #define mbe_stroke(canvas) #define mbe_clear(canvas) #define mbe_paint(canvas) @@ -90,11 +89,13 @@ mbe_pattern_t *src; mbe_surface_t *tgt; EGLContext ctx; + VGPath path; }; struct _ge_openvg_surface { void *surface; - mbe_t *asso_mbe; + mbe_t *asso_mbe; /* There is a association between + * surface and mbe */ }; struct _ge_openvg_pattern { @@ -169,6 +170,7 @@ } extern mbe_t *mbe_create(mbe_surface_t *surface); +extern void mbe_destroy(mbe_t *canvas); /* @} */ diff -r d733e198bb25 -r b714f0c9992e src/graph_engine_openvg.c --- a/src/graph_engine_openvg.c Wed Jun 30 18:06:36 2010 +0800 +++ b/src/graph_engine_openvg.c Wed Jun 30 19:30:32 2010 +0800 @@ -220,8 +220,10 @@ return NULL; mbe_surface = (mbe_surface_t *)malloc(sizeof(mbe_surface_t)); - if(mbe_surface == NULL) + if(mbe_surface == NULL) { + eglDestroySurface(surface); return NULL; + } mbe_surface->surface = surface; mbe_surface->asso_mbe = NULL; @@ -233,6 +235,7 @@ EGLDisplay display; EGLConfig config; EGLContext ctx, shared; + VGPath path; EGLint attrib_list[2] = {EGL_NONE}; mbe_t *canvas; @@ -241,13 +244,36 @@ if(ctx == EGL_NO_CONTEXT) return NULL; + path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, + 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL); + if(path == VG_INVALID_HANDLE) { + eglDestroyContext(display, ctx); + return NULL; + } + canvas = (mbe_t *)malloc(sizeof(mbe_t)); - if(canvas == NULL) + if(canvas == NULL) { + eglDestroyContext(display, ctx); + vgDestroyPath(path); return NULL; + } canvas->src = NULL; canvas->tgt = surface; canvas->ctx = ctx; + canvas->path = path; return canvas; } + +void +mbe_destroy(mbe_t *canvas) { + EGLDisplay display; + + display = _VG_DISPLAY(); + + vgDestroyPath(canvas->path); + eglDestroyContext(display, canvas->ctx); + canvas->tgt->asso_mbe = NULL; + free(ctx); +}