[cairo] [PATCH 23/39] [OpenVG] implemented cairo_mask
tardyp at gmail.com
tardyp at gmail.com
Fri Jul 10 10:02:25 PDT 2009
From: Øyvind Kolås <pippin at gimp.org>
---
src/cairo-openvg-surface.c | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/src/cairo-openvg-surface.c b/src/cairo-openvg-surface.c
index f33d834..d2d0502 100644
--- a/src/cairo-openvg-surface.c
+++ b/src/cairo-openvg-surface.c
@@ -758,7 +758,39 @@ _cairo_openvg_surface_mask (void *asurface,
cairo_pattern_t *mask)
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
- printf ("mask\n");
+#ifdef ENABLE_MASK
+ cairo_openvg_surface_t *vgsurface = asurface;
+ cairo_surface_t *image;
+ cairo_t *cr;
+
+ image = cairo_image_surface_create (CAIRO_FORMAT_A8, vgsurface->width,
+ vgsurface->height);
+ cr = cairo_create (image);
+
+ cairo_save (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_translate (cr, 0.0, vgsurface->height);
+ cairo_scale (cr, 1.0, -1.0);
+
+ cairo_set_source (cr, mask);
+ cairo_paint (cr);
+ cairo_restore (cr);
+ cairo_restore (cr);
+
+ {
+ VGImage vgimage;
+ unsigned char *data = cairo_image_surface_get_data (image);
+ vgSeti (VG_MASKING, VG_TRUE);
+ vgimage = vgCreateImage (VG_A_8, vgsurface->width, vgsurface->height, VG_IMAGE_QUALITY_FASTER);
+ vgImageSubData (vgimage, data, vgsurface->width, VG_A_8, 0, 0, vgsurface->width, vgsurface->height);
+ vgMask (vgimage, VG_INTERSECT_MASK, 0, 0, vgsurface->width, vgsurface->height);
+ vgDestroyImage (vgimage);
+ }
+
+ cairo_destroy (cr);
+
+ cairo_surface_destroy (image);
+#endif
/* upload source as image */
status = _cairo_openvg_surface_paint (asurface, op, source);
--
1.6.0.4
More information about the cairo
mailing list