changeset 595:aaaaa03af04d openvg

Set VGPaint for canvas
author Thinker K.F. Li <thinker@branda.to>
date Thu, 01 Jul 2010 14:24:02 +0800
parents d416e1fff71a
children aaab76730beb
files include/mb_graph_engine_openvg.h src/graph_engine_openvg.c
diffstat 2 files changed, 26 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/include/mb_graph_engine_openvg.h	Wed Jun 30 23:15:42 2010 +0800
+++ b/include/mb_graph_engine_openvg.h	Thu Jul 01 14:24:02 2010 +0800
@@ -63,7 +63,6 @@
 #define mbe_line_to(canvas, x, y)
 #define mbe_in_fill(canvas, x, y) (0)
 #define mbe_clear(canvas)
-#define mbe_paint(canvas)
 #define mbe_save(canvas)
 #define mbe_arc(canvas, x, y, radius, angle_start, angle_stop)
 
@@ -85,6 +84,9 @@
 
 struct _ge_openvg_mbe {
     mbe_pattern_t *src;
+    VGPaint paint;		/*!< \brief The paint associated with
+				 * the src pattern */
+    int paint_installed;
     mbe_surface_t *tgt;
     EGLContext ctx;
     VGPath path;
@@ -100,6 +102,7 @@
 struct _ge_openvg_pattern {
     void *pattern;
     void *asso_img;
+    VGPaint paint;
 };
 
 #define MB_MATRIX_2_OPENVG(vgmtx, mtx) do {	\
@@ -131,6 +134,9 @@
 			   (canvas)->tgt, (canvas)->ctx);	\
 	}							\
     } while(0)
+#define _MK_CURRENT_PAINT(canvas)					\
+    if((canvas)->paint_installed)					\
+	vgSetPaint((canvas)->paint, VG_FILL_PATH|VG_STROKE_PATH)
 
 static void
 mbe_transform(mbe_t *canvas, co_aix *mtx) {
@@ -170,9 +176,12 @@
 
 extern mbe_t *mbe_create(mbe_surface_t *surface);
 extern void mbe_destroy(mbe_t *canvas);
+extern void mbe_paint(mbe_t *canvas);
+
 static void
 mbe_stroke(mbe_t *canvas) {
     _MK_CURRENT_CTX(canvas);
+    _MK_CURRENT_PAINT(canvas);
 
     vgDrawPath(canvas->path, VG_STROKE_PATH);
     vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL);
@@ -181,6 +190,7 @@
 static void
 mbe_fill(mbe_t *canvas) {
     _MK_CURRENT_CTX(canvas);
+    _MK_CURRENT_PAINT(canvas);
 
     vgDrawPath(canvas->path, VG_FILL_PATH);
     vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL);
--- a/src/graph_engine_openvg.c	Wed Jun 30 23:15:42 2010 +0800
+++ b/src/graph_engine_openvg.c	Thu Jul 01 14:24:02 2010 +0800
@@ -9,22 +9,22 @@
 
 void
 mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) {
-    static VGint *coords = NULL;
-    static int coords_sz = 0;
+    static VGint *scissors = NULL;
+    static int n_scissors = 0;
     VGint *coord;
     area_t *area;
     int i;
 
     _MK_CURRENT_CTX(canvas);
 
-    if(n_areas > coords_sz) {
-	if(coords) free(coords);
-	coords_sz = (n_areas + 0xf) & 0xf;
-	coords = (VGint *)malloc(sizeof(VGint) * coords_sz * 4);
-	ASSERT(coords != NULL);
+    if(n_areas > n_scissors) {
+	if(scissors) free(scissors);
+	n_scissors = (n_areas + 0xf) & 0xf;
+	scissors = (VGint *)malloc(sizeof(VGint) * n_scissors * 4);
+	ASSERT(scissors != NULL);
     }
     
-    coord = coords;
+    coord = scissors;
     for(i = 0; i < n_areas; i++) {
 	area = areas[i];
 	*coord++ = area->x;
@@ -33,7 +33,7 @@
 	*coord++ = area->h;
     }
 
-    vgSetiv(VG_SCISSOR_RECTS, n_areas * 4, coords);
+    vgSetiv(VG_SCISSOR_RECTS, n_areas * 4, scissors);
 }
 
 static int
@@ -266,6 +266,7 @@
     }
     
     canvas->src = NULL;
+    canvas->paint = VG_INVALID_HANDLE;
     canvas->tgt = surface;
     canvas->ctx = ctx;
     canvas->path = path;
@@ -285,3 +286,8 @@
     free(canvas);
 }
 
+void
+mbe_paint(mbe_t *canvas) {
+    
+}
+