[cairo-commit] src/cairo-pdf-surface.c src/cairo-pdf-surface-private.h

Adrian Johnson ajohnson at kemper.freedesktop.org
Sat Jun 2 02:32:11 PDT 2012


 src/cairo-pdf-surface-private.h |    2 --
 src/cairo-pdf-surface.c         |   16 ++++++++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 0210499578898ba5bab8dbd323455c6735419a5a
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Jun 2 10:48:34 2012 +0930

    pdf: fix the offset of padded images
    
    Bug 50598

diff --git a/src/cairo-pdf-surface-private.h b/src/cairo-pdf-surface-private.h
index a58fbbf..d9f65d8 100644
--- a/src/cairo-pdf-surface-private.h
+++ b/src/cairo-pdf-surface-private.h
@@ -75,8 +75,6 @@ typedef struct _cairo_pdf_source_surface_entry {
     cairo_pdf_resource_t surface_res;
     int width;
     int height;
-    double x_offset;
-    double y_offset;
     cairo_rectangle_int_t extents;
 } cairo_pdf_source_surface_entry_t;
 
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 9765179..eaa27f1 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1412,8 +1412,6 @@ release_source:
     surface_entry->unique_id = unique_id;
     surface_entry->width = *width;
     surface_entry->height = *height;
-    surface_entry->x_offset = *x_offset;
-    surface_entry->y_offset = *y_offset;
     surface_entry->extents = *source_extents;
     _cairo_pdf_source_surface_init_key (surface_entry);
 
@@ -2151,8 +2149,6 @@ _cairo_pdf_surface_add_padded_image_surface (cairo_pdf_surface_t          *surfa
         _cairo_pattern_fini (&pad_pattern.base);
         if (unlikely (status))
             goto BAIL;
-
-	cairo_surface_set_device_offset (pad_image, rect.x, rect.y);
     }
 
     status = _cairo_pdf_surface_add_source_surface (surface,
@@ -2170,6 +2166,18 @@ _cairo_pdf_surface_add_padded_image_surface (cairo_pdf_surface_t          *surfa
     if (unlikely (status))
         goto BAIL;
 
+    if (pad_image != &image->base) {
+	/* If using a padded image, replace _add_source_surface
+	 * x/y_offset with padded image offset. Note:
+	 * _add_source_surface only sets a non zero x/y_offset for
+	 * RASTER_SOURCE patterns. _add_source_surface will always set
+	 * x/y_offset to 0 for surfaces so we can ignore the returned
+	 * offset and replace it with the offset required for the
+	 * padded image */
+	*x_offset = rect.x;
+	*y_offset = rect.y;
+    }
+
 BAIL:
     if (pad_image != &image->base)
         cairo_surface_destroy (pad_image);


More information about the cairo-commit mailing list