Mercurial > MadButterfly
changeset 610:e78bff7d23d3 openvg
create pattern from surface for OpenVG
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 05 Jul 2010 14:29:26 +0800 |
parents | 287db640078d |
children | 38383f5f645d |
files | include/mb_graph_engine_dummy.h include/mb_graph_engine_openvg.h src/graph_engine_openvg.c |
diffstat | 3 files changed, 27 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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,
--- 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,