diff include/mb_graph_engine_openvg.h @ 584:543a2a8523fb openvg

Make surce current VG context
author Thinker K.F. Li <thinker@branda.to>
date Wed, 30 Jun 2010 09:44:17 +0800
parents ca57132020e4
children 6af1aa74e57c
line wrap: on
line diff
--- a/include/mb_graph_engine_openvg.h	Wed Jun 30 09:29:28 2010 +0800
+++ b/include/mb_graph_engine_openvg.h	Wed Jun 30 09:44:17 2010 +0800
@@ -116,9 +116,19 @@
     } while(0)
 
 extern EGLNativeDisplayType _ge_openvg_disp_id;
+extern mbe_t *_ge_openvg_current_canvas;
 
-#define _MK_CURRENT_CTX(canvas)	/* TODO: Make the context of a canvas
-				 * as current context */
+#define _VG_DISPLAY() eglGetDisplay(_ge_openvg_disp_id)
+
+/* \brief Make the context of a canvas to be current context.
+ */
+#define _MK_CURRENT_CTX(canvas) do {				\
+	if(_ge_openvg_current_canvas != (canvas)) {		\
+	    _ge_openvg_current_canvas = canvas;			\
+	    eglMakeCurrent(_VG_DISPLAY(), (canvas)->tgt,	\
+			   (canvas)->tgt, (canvas)->ctx);	\
+	}							\
+    } while(0)
 
 static void
 mbe_transform(mbe_t *canvas, co_aix *mtx) {
@@ -129,8 +139,6 @@
     vgLoadMatrix(vg_mtx);
 }
 
-#define _VG_DISPLAY() eglGetDisplay(_ge_openvg_disp_id)
-
 static int
 _openvg_find_confg(mb_img_fmt_t fmt, int w, int h,
 		   EGLConfig *config) {