[cairo] [PATCH 08/39] [OpenVG] Preliminary stubs for surface source.

tardyp at gmail.com tardyp at gmail.com
Fri Jul 10 10:02:10 PDT 2009


From: Øyvind Kolås <pippin at gimp.org>

---
 src/cairo-openvg-surface.c |   44 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/src/cairo-openvg-surface.c b/src/cairo-openvg-surface.c
index f35d13f..1068028 100644
--- a/src/cairo-openvg-surface.c
+++ b/src/cairo-openvg-surface.c
@@ -43,6 +43,8 @@ typedef struct cairo_openvg_surface {
     cairo_content_t content;
     int             width;
     int             height;
+
+    VGImage         source_image;
 } cairo_openvg_surface_t;
 
 static cairo_surface_t *
@@ -79,10 +81,8 @@ _cairo_openvg_surface_intersect_clip_path (void *asurface,
 
 static cairo_int_status_t
 _cairo_openvg_surface_get_extents (void *asurface,
-                                cairo_rectangle_int_t *extents)
+                                   cairo_rectangle_int_t *extents)
 {
-    cairo_openvg_surface_t *s = asurface;
-
     extents->x = 0;
     extents->y = 0;
     extents->width = 0;
@@ -110,7 +110,7 @@ _cairo_openvg_surface_paint (void *asurface,
       }
     else
       {
-        printf ("not supporting source of type %i for paint yet", source->type);
+        printf ("not supporting source of type %i for paint yet\n", source->type);
       }
 
 
@@ -415,6 +415,29 @@ _cairo_openvg_setup_radial_source (VGPaint paint,
                                       (cairo_gradient_pattern_t *) rpat);
 }
 
+static void
+_cairo_openvg_setup_solid_source (VGPaint paint,
+                                  cairo_solid_pattern_t *spat)
+{
+  VGfloat color[] = {spat->color.red,
+                     spat->color.green,
+                     spat->color.blue,
+                     spat->color.alpha};
+  vgSetParameterfv (paint, VG_PAINT_COLOR, 4, color);
+}
+
+static void
+_cairo_openvg_setup_surface_source (VGPaint paint,
+                                    cairo_surface_pattern_t *spat)
+{
+  VGfloat color[] = {0.7, 0.5, 0.3, 0.5};
+  vgSetParameterfv (paint, VG_PAINT_COLOR, 4, color);
+  printf ("not handling source of type surface\n");
+}
+
+
+
+
 static void setup_source (VGPaint paint,
                           cairo_pattern_t *source)
 {
@@ -422,11 +445,8 @@ static void setup_source (VGPaint paint,
   if (source->type == CAIRO_PATTERN_TYPE_SOLID)
     {
       cairo_solid_pattern_t *solid = (cairo_solid_pattern_t *) source;
-      VGfloat color[] = {solid->color.red,
-                         solid->color.green,
-                         solid->color.blue,
-                         solid->color.alpha};
-      vgSetParameterfv (paint, VG_PAINT_COLOR, 4, color);
+      _cairo_openvg_setup_solid_source (paint, solid);
+      return;
     }
   else if (source->type == CAIRO_PATTERN_TYPE_LINEAR)
     {
@@ -440,6 +460,12 @@ static void setup_source (VGPaint paint,
       _cairo_openvg_setup_radial_source (paint, rpat);
       return;
     }
+  else if (source->type == CAIRO_PATTERN_TYPE_SURFACE)
+    {
+      cairo_surface_pattern_t *spat = (cairo_surface_pattern_t *)source;
+      _cairo_openvg_setup_surface_source (paint, spat);
+      return;
+    }
   else
     {
       printf ("not handling source of type: %i\n", source->type);
-- 
1.6.0.4



More information about the cairo mailing list