[cairo] [PATCH 10/39] [OpenVG] Added preliminary code to support image pattern source.
tardyp at gmail.com
tardyp at gmail.com
Fri Jul 10 10:02:12 PDT 2009
From: Øyvind Kolås <pippin at gimp.org>
---
src/cairo-openvg-surface.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/src/cairo-openvg-surface.c b/src/cairo-openvg-surface.c
index 54ad794..364e855 100644
--- a/src/cairo-openvg-surface.c
+++ b/src/cairo-openvg-surface.c
@@ -45,6 +45,7 @@ typedef struct cairo_openvg_surface {
int height;
VGPaint source_paint;
+ VGImage source_image;
} cairo_openvg_surface_t;
static cairo_surface_t *
@@ -111,6 +112,7 @@ _cairo_openvg_surface_paint (void *asurface,
else
{
printf ("not supporting source of type %i for paint yet\n", source->type);
+ return CAIRO_INT_STATUS_UNSUPPORTED;
}
@@ -439,6 +441,26 @@ _cairo_openvg_setup_surface_source (cairo_openvg_surface_t *vgsurface,
VGfloat color[] = {0.7, 0.5, 0.3, 0.5};
vgSetParameterfv (vgsurface->source_paint, VG_PAINT_COLOR, 4, color);
printf ("not handling source of type surface\n");
+
+ vgsurface->source_image = vgCreateImage (VG_sRGBA_8888, 128, 128, VG_IMAGE_QUALITY_BETTER);
+
+ {
+ unsigned char *data = malloc (128*128*4);
+ int i;
+ for (i=0;i<128*128*4;i++)
+ {
+ data[i] = rand() % 255;
+ if (0 && i%4 == 3)
+ data[i] = 255;
+ }
+
+ vgImageSubData (vgsurface->source_image, data, 128*4, VG_sRGBA_8888, 0,
+ 0, 128, 128);
+
+ free (data);
+ }
+
+
return CAIRO_STATUS_SUCCESS;
return CAIRO_INT_STATUS_UNSUPPORTED;
}
@@ -489,6 +511,12 @@ teardown_source (cairo_openvg_surface_t *vgsurface,
vgDestroyPaint (vgsurface->source_paint);
vgsurface->source_paint = 0;
}
+ if (vgsurface->source_image)
+ {
+ vgDestroyImage (vgsurface->source_paint);
+ vgsurface->source_image = 0;
+ }
+ return CAIRO_STATUS_SUCCESS;
}
static cairo_int_status_t
@@ -577,7 +605,21 @@ _cairo_openvg_surface_fill (void *asurface,
goto BAIL;
vgSetPaint(vgsurface->source_paint, VG_FILL_PATH);
+
+
+
+ if (vgsurface->source_image)
+ {
+ printf ("WARNING: attempting to paint with image pattern\n");
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
+ vgSetParameteri(vgsurface->source_image, VG_PAINT_PATTERN_TILING_MODE,
+ VG_TILE_REPEAT);
+ /*vgPaintPattern(vgsurface->source_paint, vgsurface->source_image);*/
+
+ }
+
vgDrawPath (vg_path.path, VG_FILL_PATH);
+
vgDestroyPath (vg_path.path);
teardown_source (vgsurface, source);
--
1.6.0.4
More information about the cairo
mailing list