# HG changeset patch # User Thinker K.F. Li # Date 1277891130 -28800 # Node ID e9923024f65eab2d37d8d6c63bb20b9c7791e184 # Parent 1302b336add66eeeede7d3c10d4f356cbb1af08c Implement mbe_scissoring() for OpenVG diff -r 1302b336add6 -r e9923024f65e include/mb_graph_engine_openvg.h --- 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. diff -r 1302b336add6 -r e9923024f65e src/graph_engine_openvg.c --- 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); +}