# HG changeset patch # User Thinker K.F. Li # Date 1277972206 -28800 # Node ID aba62eb9362d65a29d14c27bb32c74276adb3300 # Parent 3300992b29ff58b12ff8f587de2195f749eb9afb define color source for VG diff -r 3300992b29ff -r aba62eb9362d include/mb_graph_engine_openvg.h --- 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); diff -r 3300992b29ff -r aba62eb9362d src/graph_engine_openvg.c --- 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;