changeset 588:e9923024f65e openvg

Implement mbe_scissoring() for OpenVG
author Thinker K.F. Li <thinker@branda.to>
date Wed, 30 Jun 2010 17:45:30 +0800
parents 1302b336add6
children d733e198bb25
files include/mb_graph_engine_openvg.h src/graph_engine_openvg.c
diffstat 2 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/include/mb_graph_engine_openvg.h	Wed Jun 30 17:27:46 2010 +0800
+++ b/include/mb_graph_engine_openvg.h	Wed Jun 30 17:45:30 2010 +0800
@@ -68,7 +68,6 @@
 #define mbe_paint(canvas)
 #define mbe_save(canvas)
 #define mbe_fill(canvas)
-#define mbe_scissoring(canvas, n_areas, areas)
 #define mbe_arc(canvas, x, y, radius, angle_start, angle_stop)
 
 typedef struct _mbe_text_extents_t mbe_text_extents_t;
@@ -118,6 +117,9 @@
 extern EGLNativeDisplayType _ge_openvg_disp_id;
 extern mbe_t *_ge_openvg_current_canvas;
 
+extern void mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas);
+
+
 #define _VG_DISPLAY() eglGetDisplay(_ge_openvg_disp_id)
 
 /* \brief Make the context of a canvas to be current context.
--- a/src/graph_engine_openvg.c	Wed Jun 30 17:27:46 2010 +0800
+++ b/src/graph_engine_openvg.c	Wed Jun 30 17:45:30 2010 +0800
@@ -2,3 +2,32 @@
 
 EGLNativeDisplayType _ge_openvg_disp_id = EGL_DEFAULT_DISPLAY;
 mbe_t *_ge_openvg_current_canvas = NULL;
+
+void
+mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) {
+    static VGint *coords = NULL;
+    static int coords_sz = 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);
+    }
+    
+    coord = coords;
+    for(i = 0; i < n_areas; i++) {
+	area = areas[i];
+	*coord++ = area->x;
+	*coord++ = area->y;
+	*coord++ = area->w;
+	*coord++ = area->h;
+    }
+
+    vgSetiv(VG_SCISSOR_RECTS, n_areas * 4, coords);
+}