Mercurial > MadButterfly
comparison src/graph_engine_openvg.c @ 1127:baf4c4d48cff
Fix issue of passing EGLSurface with mbe_surface_t for OpenVG
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 14 Dec 2010 11:04:56 +0800 |
parents | 20e15872f3df |
children |
comparison
equal
deleted
inserted
replaced
1126:20e15872f3df | 1127:baf4c4d48cff |
---|---|
29 (mtx)[6] = 0; \ | 29 (mtx)[6] = 0; \ |
30 (mtx)[7] = 0; \ | 30 (mtx)[7] = 0; \ |
31 (mtx)[8] = 1; \ | 31 (mtx)[8] = 1; \ |
32 } while(0) | 32 } while(0) |
33 | 33 |
34 #define VG_MBE_SURFACE(mbe) ((mbe)->tgt->surface) | 34 #define VG_MBE_EGLSURFACE(mbe) ((EGLSurface *)(mbe)->tgt->surface) |
35 | 35 |
36 /*! \brief Information associated with VGImage. | 36 /*! \brief Information associated with VGImage. |
37 * | 37 * |
38 * A VGImage can associated one of pattern or surface. This type is | 38 * A VGImage can associated one of pattern or surface. This type is |
39 * used to make sure previous associated pattern or surface being | 39 * used to make sure previous associated pattern or surface being |
561 egl_disp = eglGetDisplay((Display *)display); | 561 egl_disp = eglGetDisplay((Display *)display); |
562 if(egl_disp == EGL_NO_DISPLAY || egl_disp != _VG_DISPLAY()) | 562 if(egl_disp == EGL_NO_DISPLAY || egl_disp != _VG_DISPLAY()) |
563 return NULL; | 563 return NULL; |
564 | 564 |
565 egl_surface = eglCreateWindowSurface(egl_disp, config, | 565 egl_surface = eglCreateWindowSurface(egl_disp, config, |
566 (Drawable)drawable, | 566 (EGLNativeWindowType)drawable, |
567 attrib_list); | 567 attrib_list); |
568 | 568 |
569 surface = O_ALLOC(mbe_surface_t); | 569 surface = O_ALLOC(mbe_surface_t); |
570 if(surface == NULL) { | 570 if(surface == NULL) { |
571 eglDestroySurface(egl_disp, egl_surface); | 571 eglDestroySurface(egl_disp, egl_surface); |
670 | 670 |
671 vg_img = SURFACE_VG_IMG(src_canvas); | 671 vg_img = SURFACE_VG_IMG(src_canvas); |
672 vgDrawImage(vg_img); | 672 vgDrawImage(vg_img); |
673 | 673 |
674 display = _VG_DISPLAY(); | 674 display = _VG_DISPLAY(); |
675 eglSwapBuffers(display, VG_MBE_SURFACE(dst_canvas)); | 675 eglSwapBuffers(display, VG_MBE_EGLSURFACE(dst_canvas)); |
676 } | 676 } |
677 | 677 |
678 void | 678 void |
679 mbe_flush(mbe_t *canvas) { | 679 mbe_flush(mbe_t *canvas) { |
680 EGLDisplay display; | 680 EGLDisplay display; |
681 mbe_surface_t *surface; | 681 EGLSurface *egl_surface; |
682 | 682 |
683 _MK_CURRENT_CTX(canvas); | 683 _MK_CURRENT_CTX(canvas); |
684 display = _VG_DISPLAY(); | 684 display = _VG_DISPLAY(); |
685 surface = VG_MBE_SURFACE(canvas); | 685 egl_surface = VG_MBE_EGLSURFACE(canvas); |
686 eglSwapBuffers(display, surface); | 686 eglSwapBuffers(display, egl_surface); |
687 } | 687 } |
688 | 688 |
689 mbe_t * | 689 mbe_t * |
690 mbe_create(mbe_surface_t *surface) { | 690 mbe_create(mbe_surface_t *surface) { |
691 EGLDisplay display; | 691 EGLDisplay display; |
753 | 753 |
754 void | 754 void |
755 mbe_paint_with_alpha(mbe_t *canvas, co_comp_t alpha) { | 755 mbe_paint_with_alpha(mbe_t *canvas, co_comp_t alpha) { |
756 VGfloat color_trans[8] = {1, 1, 1, alpha, 0, 0, 0, 0}; | 756 VGfloat color_trans[8] = {1, 1, 1, alpha, 0, 0, 0, 0}; |
757 EGLDisplay display; | 757 EGLDisplay display; |
758 EGLSurface *egl_surface; | |
758 EGLint w, h; | 759 EGLint w, h; |
759 EGLBoolean r; | 760 EGLBoolean r; |
760 | 761 |
761 _MK_CURRENT_CTX(canvas); | 762 _MK_CURRENT_CTX(canvas); |
762 | 763 |
763 display = _VG_DISPLAY(); | 764 display = _VG_DISPLAY(); |
764 | 765 |
765 r = eglQuerySurface(display, canvas->tgt, EGL_WIDTH, &w); | 766 egl_surface = VG_MBE_EGLSURFACE(canvas); |
767 r = eglQuerySurface(display, egl_surface, EGL_WIDTH, &w); | |
766 ASSERT(r == EGL_TRUE); | 768 ASSERT(r == EGL_TRUE); |
767 r = eglQuerySurface(display, canvas->tgt, EGL_HEIGHT, &h); | 769 r = eglQuerySurface(display, egl_surface, EGL_HEIGHT, &h); |
768 ASSERT(r == EGL_TRUE); | 770 ASSERT(r == EGL_TRUE); |
769 | 771 |
770 /* Setup color transform for alpha */ | 772 /* Setup color transform for alpha */ |
771 #ifdef OPENVG_1_1 | 773 #ifdef OPENVG_1_1 |
772 vgSetfv(VG_COLOR_TRANSFORM_VALUES, 8, color_trans); | 774 vgSetfv(VG_COLOR_TRANSFORM_VALUES, 8, color_trans); |
781 } | 783 } |
782 | 784 |
783 void | 785 void |
784 mbe_paint(mbe_t *canvas) { | 786 mbe_paint(mbe_t *canvas) { |
785 EGLDisplay display; | 787 EGLDisplay display; |
788 EGLSurface *egl_surface; | |
786 EGLint w, h; | 789 EGLint w, h; |
787 EGLBoolean r; | 790 EGLBoolean r; |
788 VGPath path; | 791 VGPath path; |
789 | 792 |
790 _MK_CURRENT_CTX(canvas); | 793 _MK_CURRENT_CTX(canvas); |
793 _mbe_load_pattern_mtx(canvas->src->mtx, NULL, | 796 _mbe_load_pattern_mtx(canvas->src->mtx, NULL, |
794 VG_MATRIX_FILL_PAINT_TO_USER); | 797 VG_MATRIX_FILL_PAINT_TO_USER); |
795 | 798 |
796 display = _VG_DISPLAY(); | 799 display = _VG_DISPLAY(); |
797 | 800 |
798 r = eglQuerySurface(display, canvas->tgt, EGL_WIDTH, &w); | 801 egl_surface = VG_MBE_EGLSURFACE(canvas); |
802 r = eglQuerySurface(display, egl_surface, EGL_WIDTH, &w); | |
799 ASSERT(r == EGL_TRUE); | 803 ASSERT(r == EGL_TRUE); |
800 r = eglQuerySurface(display, canvas->tgt, EGL_HEIGHT, &h); | 804 r = eglQuerySurface(display, egl_surface, EGL_HEIGHT, &h); |
801 ASSERT(r == EGL_TRUE); | 805 ASSERT(r == EGL_TRUE); |
802 | 806 |
803 /* | 807 /* |
804 * Disable scissoring and identity transform matrix. | 808 * Disable scissoring and identity transform matrix. |
805 * | 809 * |
823 } | 827 } |
824 | 828 |
825 void | 829 void |
826 mbe_clear(mbe_t *canvas) { | 830 mbe_clear(mbe_t *canvas) { |
827 EGLDisplay display; | 831 EGLDisplay display; |
828 EGLSurface *tgt_surface; | 832 EGLSurface *egl_surface; |
829 EGLint w, h; | 833 EGLint w, h; |
830 EGLBoolean r; | 834 EGLBoolean r; |
831 | 835 |
832 _MK_CURRENT_CTX(canvas); | 836 _MK_CURRENT_CTX(canvas); |
833 | 837 |
834 display = _VG_DISPLAY(); | 838 display = _VG_DISPLAY(); |
835 | 839 |
836 tgt_surface = (EGLSurface *)canvas->tgt->surface; | 840 egl_surface = VG_MBE_EGLSURFACE(canvas); |
837 r = eglQuerySurface(display, tgt_surface, EGL_WIDTH, &w); | 841 r = eglQuerySurface(display, egl_surface, EGL_WIDTH, &w); |
838 ASSERT(r == EGL_TRUE); | 842 ASSERT(r == EGL_TRUE); |
839 r = eglQuerySurface(display, tgt_surface, EGL_HEIGHT, &h); | 843 r = eglQuerySurface(display, egl_surface, EGL_HEIGHT, &h); |
840 ASSERT(r == EGL_TRUE); | 844 ASSERT(r == EGL_TRUE); |
841 | 845 |
842 /* Clear regions to the color specified by mbe_create() */ | 846 /* Clear regions to the color specified by mbe_create() */ |
843 vgClear(0, 0, w, h); | 847 vgClear(0, 0, w, h); |
844 } | 848 } |