# HG changeset patch # User Thinker K.F. Li # Date 1278311366 -28800 # Node ID e78bff7d23d3892500978ada40fefaa44a7adb89 # Parent 287db640078d609d8a5937233f498e5b89212a18 create pattern from surface for OpenVG diff -r 287db640078d -r e78bff7d23d3 include/mb_graph_engine_dummy.h --- a/include/mb_graph_engine_dummy.h Mon Jul 05 13:15:17 2010 +0800 +++ b/include/mb_graph_engine_dummy.h Mon Jul 05 14:29:26 2010 +0800 @@ -11,7 +11,7 @@ /*! \defgroup mb_ge_cairo MadButterfly Graphic Engine with Cairo * @{ */ -#define mbe_pattern_create_for_surface(canvas) ((mbe_pattern_t *)NULL) +#define mbe_pattern_create_for_surface(surface) ((mbe_pattern_t *)NULL) #define mbe_scaled_font_text_extents(scaled, utf8, extents) #define mbe_image_surface_get_stride(surface) (20) #define mbe_image_surface_get_format(surface) ((mb_img_fmt_t)0) diff -r 287db640078d -r e78bff7d23d3 include/mb_graph_engine_openvg.h --- a/include/mb_graph_engine_openvg.h Mon Jul 05 13:15:17 2010 +0800 +++ b/include/mb_graph_engine_openvg.h Mon Jul 05 14:29:26 2010 +0800 @@ -11,7 +11,6 @@ /*! \defgroup mb_ge_cairo MadButterfly Graphic Engine with Cairo * @{ */ -#define mbe_pattern_create_for_surface(canvas) ((mbe_pattern_t *)NULL) #define mbe_scaled_font_text_extents(scaled, utf8, extents) #define mbe_image_surface_get_stride(surface) (20) #define mbe_image_surface_get_format(surface) ((mb_img_fmt_t)0) @@ -131,6 +130,7 @@ extern EGLNativeDisplayType _ge_openvg_disp_id; extern mbe_t *_ge_openvg_current_canvas; +extern mbe_pattern_t *mbe_pattern_create_for_surface(mbe_surface_t *surface); extern mbe_pattern_t *mbe_pattern_create_radial(co_aix cx0, co_aix cy0, co_aix radius0, co_aix cx1, co_aix cy1, diff -r 287db640078d -r e78bff7d23d3 src/graph_engine_openvg.c --- a/src/graph_engine_openvg.c Mon Jul 05 13:15:17 2010 +0800 +++ b/src/graph_engine_openvg.c Mon Jul 05 14:29:26 2010 +0800 @@ -13,6 +13,31 @@ (((int)(0xf * b) & 0xf) << 16) | \ ((int)(0xf * a) & 0xf)) +/* + * This implementation supports only from image surface. + */ +mbe_pattern_t * +mbe_pattern_create_for_surface(mbe_surface_t *surface) { + mbe_pattern_t *pattern; + _ge_openvg_img_t *ge_img; + VGPaint paint; + + /* Support only from image surface */ + if(surface->asso_img == NULL) + return NULL; + + paint = vgCreatePaint(); + if(paint == VG_INVALID_HANDLE) + return NULL; + + ge_img = surface->asso_img; + pattern = O_ALLOC(mbe_pattern_t); + pattern->asso_img = ge_img; + pattern->paint = paint; + + return pattern; +} + static mbe_pattern_t * _mbe_pattern_create_gradient(VGfloat *gradient, int grad_len, int grad_type,