Mercurial > MadButterfly
changeset 590:b714f0c9992e openvg
include a VGPath in VG canvas
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 30 Jun 2010 19:30:32 +0800 |
parents | d733e198bb25 |
children | 71df2896877c |
files | include/mb_graph_engine_openvg.h src/graph_engine_openvg.c |
diffstat | 2 files changed, 32 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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); /* @} */
--- 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); +}