Mercurial > MadButterfly
changeset 1080:394d7d4c0673 openvg
Fix issue that tank does not update window with OpenVG.
It was caused by
- invalid attribute list,
- invalid config for the context, and
- forget to call eglSwapBuffers().
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 02 Dec 2010 12:22:55 +0800 |
parents | c5255cc77143 |
children | 14c2bdcbbcca |
files | include/mb_graph_engine_openvg.h src/graph_engine_openvg.c |
diffstat | 2 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/include/mb_graph_engine_openvg.h Wed Dec 01 23:08:13 2010 +0800 +++ b/include/mb_graph_engine_openvg.h Thu Dec 02 12:22:55 2010 +0800 @@ -112,6 +112,7 @@ * surface and mbe */ _ge_openvg_img_t *asso_img; int w, h; + mb_img_fmt_t fmt; }; struct _ge_openvg_pattern {
--- a/src/graph_engine_openvg.c Wed Dec 01 23:08:13 2010 +0800 +++ b/src/graph_engine_openvg.c Thu Dec 02 12:22:55 2010 +0800 @@ -36,6 +36,8 @@ (mtx)[8] = 1; \ } while(0) +#define VG_MBE_SURFACE(mbe) ((mbe)->tgt->surface) + /*! \brief Convert mb_img_fmt_t to VGImageFormat */ static VGImageFormat _mb_ifmt_2_vgifmt(mb_img_fmt_t fmt) { @@ -582,6 +584,7 @@ surface->surface = egl_surface; surface->asso_img = NULL; + surface->fmt = fmt; return surface; } @@ -593,7 +596,7 @@ EGLSurface surface; EGLDisplay display; EGLConfig config; - EGLint attrib_list[5]; + EGLint attrib_list[1] = {EGL_NONE}; _ge_openvg_img_t *ge_img; mbe_surface_t *mbe_surface; int r; @@ -608,13 +611,10 @@ return NULL; display = _VG_DISPLAY(); - attrib_list[0] = EGL_WIDTH; - attrib_list[1] = w; - attrib_list[2] = EGL_HEIGHT; - attrib_list[3] = h; - attrib_list[4] = EGL_NONE; /* Some implementation does not support pbuffer. * We need use some other surface to replace this one. + * + * EGL does not support any attributes for pbuffer used by OpenVG. */ surface = eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, (EGLClientBuffer)ge_img->img, @@ -635,6 +635,7 @@ mbe_surface->asso_img = ge_img; mbe_surface->w = w; mbe_surface->h = h; + mbe_surface->fmt = fmt; return mbe_surface; } @@ -667,6 +668,7 @@ void mbe_copy_source(mbe_t *src_canvas, mbe_t *dst_canvas) { VGImage vg_img; + EGLDisplay display; ASSERT(src_canvas->tgt->asso_img != NULL); @@ -677,6 +679,9 @@ vg_img = src_canvas->tgt->asso_img; vgDrawImage(vg_img); + + display = _VG_DISPLAY(); + eglSwapBuffers(display, VG_MBE_SURFACE(dst_canvas)); } mbe_t * @@ -688,8 +693,15 @@ EGLint attrib_list[2] = {EGL_NONE}; static VGfloat clear_color[4] = {0, 0, 0, 1}; mbe_t *canvas; + int r; display = _VG_DISPLAY(); + + r = _openvg_find_config(surface->fmt, surface->w, surface->h, &config); + if(r != 0) + return NULL; + + shared = EGL_NO_CONTEXT; ctx = eglCreateContext(display, config, shared, attrib_list); if(ctx == EGL_NO_CONTEXT) return NULL;