Mercurial > MadButterfly
comparison src/graph_engine_openvg.c @ 1081:14c2bdcbbcca openvg
Make an association between mbe and surface for OpenVG
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 03 Dec 2010 01:11:14 +0800 |
parents | 394d7d4c0673 |
children | af74a96e6624 |
comparison
equal
deleted
inserted
replaced
1080:394d7d4c0673 | 1081:14c2bdcbbcca |
---|---|
35 (mtx)[7] = 0; \ | 35 (mtx)[7] = 0; \ |
36 (mtx)[8] = 1; \ | 36 (mtx)[8] = 1; \ |
37 } while(0) | 37 } while(0) |
38 | 38 |
39 #define VG_MBE_SURFACE(mbe) ((mbe)->tgt->surface) | 39 #define VG_MBE_SURFACE(mbe) ((mbe)->tgt->surface) |
40 | |
41 static EGLContext init_ctx; | |
40 | 42 |
41 /*! \brief Convert mb_img_fmt_t to VGImageFormat */ | 43 /*! \brief Convert mb_img_fmt_t to VGImageFormat */ |
42 static VGImageFormat | 44 static VGImageFormat |
43 _mb_ifmt_2_vgifmt(mb_img_fmt_t fmt) { | 45 _mb_ifmt_2_vgifmt(mb_img_fmt_t fmt) { |
44 VGImageFormat vgifmt; | 46 VGImageFormat vgifmt; |
581 eglDestroySurface(egl_disp, egl_surface); | 583 eglDestroySurface(egl_disp, egl_surface); |
582 return NULL; | 584 return NULL; |
583 } | 585 } |
584 | 586 |
585 surface->surface = egl_surface; | 587 surface->surface = egl_surface; |
588 surface->asso_mbe = NULL; | |
586 surface->asso_img = NULL; | 589 surface->asso_img = NULL; |
587 surface->fmt = fmt; | 590 surface->fmt = fmt; |
588 | 591 |
589 return surface; | 592 return surface; |
590 } | 593 } |
699 | 702 |
700 r = _openvg_find_config(surface->fmt, surface->w, surface->h, &config); | 703 r = _openvg_find_config(surface->fmt, surface->w, surface->h, &config); |
701 if(r != 0) | 704 if(r != 0) |
702 return NULL; | 705 return NULL; |
703 | 706 |
704 shared = EGL_NO_CONTEXT; | 707 /* shared = EGL_NO_CONTEXT; */ |
708 shared = init_ctx; | |
705 ctx = eglCreateContext(display, config, shared, attrib_list); | 709 ctx = eglCreateContext(display, config, shared, attrib_list); |
706 if(ctx == EGL_NO_CONTEXT) | 710 if(ctx == EGL_NO_CONTEXT) |
707 return NULL; | 711 return NULL; |
708 | 712 |
709 path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, | 713 path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, |
724 canvas->paint = VG_INVALID_HANDLE; | 728 canvas->paint = VG_INVALID_HANDLE; |
725 canvas->paint_installed = 0; | 729 canvas->paint_installed = 0; |
726 canvas->tgt = surface; | 730 canvas->tgt = surface; |
727 canvas->ctx = ctx; | 731 canvas->ctx = ctx; |
728 canvas->path = path; | 732 canvas->path = path; |
733 | |
734 surface->asso_mbe = canvas; | |
729 | 735 |
730 /* Set clear color for the context */ | 736 /* Set clear color for the context */ |
731 _MK_CURRENT_CTX(canvas); | 737 _MK_CURRENT_CTX(canvas); |
732 vgSetfv(VG_CLEAR_COLOR, 4, clear_color); | 738 vgSetfv(VG_CLEAR_COLOR, 4, clear_color); |
733 | 739 |
835 /* Clear regions to the color specified by mbe_create() */ | 841 /* Clear regions to the color specified by mbe_create() */ |
836 vgClear(0, 0, w, h); | 842 vgClear(0, 0, w, h); |
837 } | 843 } |
838 | 844 |
839 void mbe_init() { | 845 void mbe_init() { |
840 static EGLContext init_ctx; | |
841 static EGLSurface init_surf; | 846 static EGLSurface init_surf; |
842 EGLDisplay display; | 847 EGLDisplay display; |
843 EGLConfig config; | 848 EGLConfig config; |
844 EGLint nconfigs; | 849 EGLint nconfigs; |
845 EGLint attrib_list[] = { | 850 EGLint attrib_list[] = { |