changeset 598:aba62eb9362d openvg

define color source for VG
author Thinker K.F. Li <thinker@branda.to>
date Thu, 01 Jul 2010 16:16:46 +0800
parents 3300992b29ff
children 28aa5e53abaa
files include/mb_graph_engine_openvg.h src/graph_engine_openvg.c
diffstat 2 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/include/mb_graph_engine_openvg.h	Thu Jul 01 15:52:29 2010 +0800
+++ b/include/mb_graph_engine_openvg.h	Thu Jul 01 16:16:46 2010 +0800
@@ -37,7 +37,6 @@
 #define mbe_pattern_set_matrix(ptn, mtx)
 #define mbe_font_face_destroy(face)
 #define mbe_paint_with_alpha(canvas, alpha)
-#define mbe_set_source_rgba(canvas, r, g, b, a)
 #define mbe_set_scaled_font(canvas, scaled)
 #define mbe_pattern_destroy(pattern)
 #define mbe_get_scaled_font(canvas) ((mbe_scaled_font_t *)NULL)
@@ -119,6 +118,8 @@
 extern EGLNativeDisplayType _ge_openvg_disp_id;
 extern mbe_t *_ge_openvg_current_canvas;
 
+extern void mbe_set_source_rgba(mbe_t *canvas, co_comp_t r, co_comp_t g,
+				co_comp_t b, co_comp_t a);
 extern void mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas);
 
 
--- a/src/graph_engine_openvg.c	Thu Jul 01 15:52:29 2010 +0800
+++ b/src/graph_engine_openvg.c	Thu Jul 01 16:16:46 2010 +0800
@@ -7,6 +7,30 @@
 #define ASSERT(x)
 #endif
 
+#define MB_2_VG_COLOR(r, g, b, a) ((((int)(0xf * r) & 0xf) << 24) |	\
+				   (((int)(0xf * g) & 0xf) << 16) |	\
+				   (((int)(0xf * b) & 0xf) << 16) |	\
+				   ((int)(0xf * a) & 0xf))
+
+void mbe_set_source_rgba(mbe_t *canvas, co_comp_t r, co_comp_t g,
+			 co_comp_t b, co_comp_t a) {
+    VGPaint paint;
+    VGuint color;
+
+    if(paint != VG_INVALID_HANDLE && canvas->src == NULL)
+	paint = canvas->paint;	/* previous one is also a color paint */
+    else {
+	paint = vgCreatePaint();
+	ASSERT(paint != VG_INVALID_HANDLE);
+	canvas->paint = paint;
+	canvas->src = NULL;
+    }
+    
+    color = MB_2_VG_COLOR(r, g, b, a);
+    vgSetColor(paint, color);
+    canvas->paint_installed = 0;
+}
+
 void
 mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) {
     static VGint *scissors = NULL;