[cairo-commit] 2 commits - src/cairo.h src/cairo-image-info.c src/cairo-image-info-private.h src/cairo-output-stream.c src/cairo-output-stream-private.h src/cairo-pdf-surface.c src/cairo-png.c src/cairo-ps-surface.c src/cairo-script-surface.c src/cairo-surface.c src/cairo-surface-subsurface.c src/cairo-surface-subsurface-private.h src/cairo-svg-surface.c src/cairo-types-private.h src/cairo-win32-printing-surface.c util/cairo-trace

Chris Wilson ickle at kemper.freedesktop.org
Sat Jul 10 03:16:45 PDT 2010


 src/cairo-image-info-private.h         |    6 +++---
 src/cairo-image-info.c                 |    4 ++--
 src/cairo-output-stream-private.h      |    2 +-
 src/cairo-output-stream.c              |    2 +-
 src/cairo-pdf-surface.c                |   18 +++++++++---------
 src/cairo-png.c                        |    2 +-
 src/cairo-ps-surface.c                 |    2 +-
 src/cairo-script-surface.c             |    6 +++---
 src/cairo-surface-subsurface-private.h |    1 -
 src/cairo-surface-subsurface.c         |   17 ++++++++---------
 src/cairo-surface.c                    |    4 ++--
 src/cairo-svg-surface.c                |    6 +++---
 src/cairo-types-private.h              |    2 +-
 src/cairo-win32-printing-surface.c     |   10 +++++-----
 src/cairo.h                            |    4 ++--
 util/cairo-trace/trace.c               |    6 +++---
 16 files changed, 45 insertions(+), 47 deletions(-)

New commits:
commit 9b9952ab4f64a476bbadfd3e6cf1e66c1137ccd7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jul 10 11:13:07 2010 +0100

    Convert mime data length to use unsigned long
    
    What we want to use is size_t, but we don't want the implied POSIX
    dependency. However, POSIX does say that size_t is an unsigned integer
    that is no longer than a long, so it would appear safe to use an
    unsigned long as a replacement. Safer at least than unsigned int.

diff --git a/src/cairo-image-info-private.h b/src/cairo-image-info-private.h
index 88f47c4..0d9ef84 100644
--- a/src/cairo-image-info-private.h
+++ b/src/cairo-image-info-private.h
@@ -53,11 +53,11 @@ _cairo_image_info_get_jpeg_info (cairo_image_info_t	*info,
 cairo_private cairo_int_status_t
 _cairo_image_info_get_jpx_info (cairo_image_info_t	*info,
 				const unsigned char	*data,
-				long			 length);
+				unsigned long		 length);
 
 cairo_private cairo_int_status_t
-_cairo_image_info_get_png_info (cairo_image_info_t     	*info,
+_cairo_image_info_get_png_info (cairo_image_info_t	*info,
 				const unsigned char     *data,
-				long                     length);
+				unsigned long            length);
 
 #endif /* CAIRO_IMAGE_INFO_PRIVATE_H */
diff --git a/src/cairo-image-info.c b/src/cairo-image-info.c
index dc74d0e..63201e6 100644
--- a/src/cairo-image-info.c
+++ b/src/cairo-image-info.c
@@ -214,7 +214,7 @@ _jpx_extract_info (const unsigned char *p, cairo_image_info_t *info)
 cairo_int_status_t
 _cairo_image_info_get_jpx_info (cairo_image_info_t	*info,
 				const unsigned char	*data,
-				long			 length)
+				unsigned long		 length)
 {
     const unsigned char *p = data;
     const unsigned char *end = data + length;
@@ -262,7 +262,7 @@ static const unsigned char _png_magic[8] = { 137, 80, 78, 71, 13, 10, 26, 10 };
 cairo_int_status_t
 _cairo_image_info_get_png_info (cairo_image_info_t     *info,
                                const unsigned char     *data,
-                               long                     length)
+                               unsigned long            length)
 {
     const unsigned char *p = data;
     const unsigned char *end = data + length;
diff --git a/src/cairo-output-stream-private.h b/src/cairo-output-stream-private.h
index 7845eb0..edaabbe 100644
--- a/src/cairo-output-stream-private.h
+++ b/src/cairo-output-stream-private.h
@@ -175,7 +175,7 @@ _cairo_memory_stream_length (cairo_output_stream_t *stream);
 cairo_private cairo_status_t
 _cairo_memory_stream_destroy (cairo_output_stream_t *abstract_stream,
 			      unsigned char **data_out,
-			      unsigned int *length_out);
+			      unsigned long *length_out);
 
 cairo_private cairo_output_stream_t *
 _cairo_null_stream_create (void);
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index 8ee46fe..0adda36 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -690,7 +690,7 @@ _cairo_memory_stream_create (void)
 cairo_status_t
 _cairo_memory_stream_destroy (cairo_output_stream_t *abstract_stream,
 			      unsigned char **data_out,
-			      unsigned int *length_out)
+			      unsigned long *length_out)
 {
     memory_stream_t *stream;
     cairo_status_t status;
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 301ddce..2da49d9 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1041,10 +1041,10 @@ _cairo_pdf_source_surface_init_key (cairo_pdf_source_surface_entry_t *key)
 }
 
 static cairo_int_status_t
-_get_jpx_image_info (cairo_surface_t	 	 *source,
-		     cairo_image_info_t 	 *info,
-		     const unsigned char 	**mime_data,
-		     unsigned int 		 *mime_data_length)
+_get_jpx_image_info (cairo_surface_t		 *source,
+		     cairo_image_info_t		*info,
+		     const unsigned char	**mime_data,
+		     unsigned long		 *mime_data_length)
 {
     cairo_surface_get_mime_data (source, CAIRO_MIME_TYPE_JP2,
 				 mime_data, mime_data_length);
@@ -1055,10 +1055,10 @@ _get_jpx_image_info (cairo_surface_t	 	 *source,
 }
 
 static cairo_int_status_t
-_get_jpeg_image_info (cairo_surface_t	 *source,
+_get_jpeg_image_info (cairo_surface_t		 *source,
 		      cairo_image_info_t	 *info,
 		      const unsigned char	**mime_data,
-		      unsigned int		 *mime_data_length)
+		      unsigned long		 *mime_data_length)
 {
     cairo_surface_get_mime_data (source, CAIRO_MIME_TYPE_JPEG,
 				 mime_data, mime_data_length);
@@ -1077,7 +1077,7 @@ _get_source_surface_size (cairo_surface_t         *source,
     cairo_rectangle_int_t extents;
     cairo_image_info_t info;
     const unsigned char *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
 
     if (source->type == CAIRO_SURFACE_TYPE_RECORDING) {
 	if (source->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SUBSURFACE) {
@@ -2004,7 +2004,7 @@ _cairo_pdf_surface_emit_jpx_image (cairo_pdf_surface_t   *surface,
 {
     cairo_status_t status;
     const unsigned char *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
     cairo_image_info_t info;
 
     if (surface->pdf_version < CAIRO_PDF_VERSION_1_5)
@@ -2045,7 +2045,7 @@ _cairo_pdf_surface_emit_jpeg_image (cairo_pdf_surface_t   *surface,
 {
     cairo_status_t status;
     const unsigned char *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
     cairo_image_info_t info;
 
     cairo_surface_get_mime_data (source, CAIRO_MIME_TYPE_JPEG,
diff --git a/src/cairo-png.c b/src/cairo-png.c
index 8b2ff77..41a33d7 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -529,7 +529,7 @@ read_png (struct png_read_closure_t *png_closure)
     cairo_format_t format;
     cairo_status_t status;
     unsigned char *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
 
     png_closure->png_data = _cairo_memory_stream_create ();
 
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index fda4a30..bedc143 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -2327,7 +2327,7 @@ _cairo_ps_surface_emit_jpeg_image (cairo_ps_surface_t    *surface,
 {
     cairo_status_t status;
     const unsigned char *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
     cairo_image_info_t info;
 
     cairo_surface_get_mime_data (source, CAIRO_MIME_TYPE_JPEG,
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index 407b716..f0db3b0 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -1155,7 +1155,7 @@ _emit_png_surface (cairo_script_surface_t *surface,
     cairo_output_stream_t *base85_stream;
     cairo_status_t status;
     const uint8_t *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
 
     cairo_surface_get_mime_data (&image->base, CAIRO_MIME_TYPE_PNG,
 				 &mime_data, &mime_data_length);
@@ -1208,7 +1208,7 @@ _emit_image_surface (cairo_script_surface_t *surface,
     cairo_output_stream_t *zlib_stream;
     cairo_status_t status, status2;
     const uint8_t *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
     struct def *tag;
 
     if (_cairo_user_data_array_get_data (&image->base.user_data,
@@ -1310,7 +1310,7 @@ _emit_image_surface (cairo_script_surface_t *surface,
     cairo_list_add (&tag->link, &ctx->defines);
     status = _cairo_user_data_array_set_data (&image->base.user_data,
 					      (cairo_user_data_key_t *) ctx,
-					tag, _undef);
+					      tag, _undef);
     if (unlikely (status)) {
 	free (tag);
 	return status;
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 7e2fb9f..a0c1941 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -783,7 +783,7 @@ void
 cairo_surface_get_mime_data (cairo_surface_t		*surface,
                              const char			*mime_type,
                              const unsigned char       **data,
-                             unsigned int		*length)
+                             unsigned long		*length)
 {
     cairo_user_data_slot_t *slots;
     int i, num_slots;
@@ -896,7 +896,7 @@ cairo_status_t
 cairo_surface_set_mime_data (cairo_surface_t		*surface,
                              const char			*mime_type,
                              const unsigned char	*data,
-                             unsigned int		 length,
+                             unsigned long		 length,
 			     cairo_destroy_func_t	 destroy,
 			     void			*closure)
 {
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index 5b348f3..fb612fa 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -1086,7 +1086,7 @@ _cairo_surface_base64_encode_jpeg (cairo_surface_t       *surface,
 				   cairo_output_stream_t *output)
 {
     const unsigned char *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
     cairo_image_info_t image_info;
     base64_write_closure_t info;
     cairo_status_t status;
@@ -1125,7 +1125,7 @@ _cairo_surface_base64_encode_png (cairo_surface_t       *surface,
 				  cairo_output_stream_t *output)
 {
     const unsigned char *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
     base64_write_closure_t info;
     cairo_status_t status;
 
@@ -1266,7 +1266,7 @@ _cairo_svg_surface_emit_surface (cairo_svg_document_t *document,
     cairo_bool_t is_bounded;
     cairo_status_t status;
     const unsigned char *uri;
-    unsigned int uri_len;
+    unsigned long uri_len;
 
     if (_cairo_user_data_array_get_data (&surface->user_data,
 					 (cairo_user_data_key_t *) document))
diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h
index af46f40..d042736 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -374,7 +374,7 @@ typedef enum _cairo_image_transparency {
 struct _cairo_mime_data {
     cairo_reference_count_t ref_count;
     unsigned char *data;
-    unsigned int length;
+    unsigned long length;
     cairo_destroy_func_t destroy;
     void *closure;
 };
diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index 9f9f568..497be25 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -521,11 +521,11 @@ static cairo_int_status_t
 _cairo_win32_printing_surface_check_jpeg (cairo_win32_surface_t   *surface,
 					  cairo_surface_t         *source,
 					  const unsigned char    **data,
-					  unsigned int            *length,
+					  unsigned long           *length,
 					  cairo_image_info_t      *info)
 {
     const unsigned char *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
     cairo_int_status_t status;
     DWORD result;
 
@@ -559,11 +559,11 @@ static cairo_int_status_t
 _cairo_win32_printing_surface_check_png (cairo_win32_surface_t   *surface,
 					 cairo_surface_t         *source,
 					 const unsigned char    **data,
-					 unsigned int            *length,
+					 unsigned long           *length,
 					 cairo_image_info_t      *info)
 {
     const unsigned char *mime_data;
-    unsigned int mime_data_length;
+    unsigned long mime_data_length;
 
     cairo_int_status_t status;
     DWORD result;
@@ -611,7 +611,7 @@ _cairo_win32_printing_surface_paint_image_pattern (cairo_win32_surface_t   *surf
     RECT clip;
     const cairo_color_t *background_color;
     const unsigned char *mime_data;
-    unsigned int mime_size;
+    unsigned long mime_size;
     cairo_image_info_t mime_info;
     cairo_bool_t use_mime;
     DWORD mime_type;
diff --git a/src/cairo.h b/src/cairo.h
index 44ce561..9251bf6 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2188,13 +2188,13 @@ cairo_public void
 cairo_surface_get_mime_data (cairo_surface_t		*surface,
                              const char			*mime_type,
                              const unsigned char       **data,
-                             unsigned int		*length);
+                             unsigned long		*length);
 
 cairo_public cairo_status_t
 cairo_surface_set_mime_data (cairo_surface_t		*surface,
                              const char			*mime_type,
                              const unsigned char	*data,
-                             unsigned int		 length,
+                             unsigned long		 length,
 			     cairo_destroy_func_t	 destroy,
 			     void			*closure);
 
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index 6dd58db..971fa43 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -1320,7 +1320,7 @@ _expand_four_tuple_to_five (unsigned char four_tuple[4],
 static void
 _write_base85_data (struct _data_stream *stream,
 		    const unsigned char	  *data,
-		    unsigned int	   length)
+		    unsigned long	   length)
 {
     unsigned char five_tuple[5];
     int ret;
@@ -1555,7 +1555,7 @@ _emit_image (cairo_surface_t *image,
 
 	for (mime_type = mime_types; *mime_type; mime_type++) {
 	    const unsigned char *mime_data;
-	    unsigned int mime_length;
+	    unsigned long mime_length;
 
 	    DLCALL (cairo_surface_get_mime_data,
 		    image, *mime_type, &mime_data, &mime_length);
@@ -3652,7 +3652,7 @@ cairo_status_t
 cairo_surface_set_mime_data (cairo_surface_t		*surface,
                              const char			*mime_type,
                              const unsigned char	*data,
-                             unsigned int		 length,
+                             unsigned long		 length,
 			     cairo_destroy_func_t	 destroy,
 			     void			*closure)
 {
commit eb85ab998b606144daf025285968a5d6031b9aa6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jul 10 10:43:40 2010 +0100

    subsurface: Don't assume we ever own the target.
    
    Andrea pointed out that snapshots can be shared, and so the subsurface
    should not be calling finish even on a snapshot.

diff --git a/src/cairo-surface-subsurface-private.h b/src/cairo-surface-subsurface-private.h
index 6410abd..435e1eb 100644
--- a/src/cairo-surface-subsurface-private.h
+++ b/src/cairo-surface-subsurface-private.h
@@ -44,7 +44,6 @@ struct _cairo_surface_subsurface {
     cairo_rectangle_int_t extents;
 
     cairo_surface_t *target;
-    cairo_bool_t owns_target;
 };
 
 #endif /* CAIRO_SURFACE_SUBSURFACE_PRIVATE_H */
diff --git a/src/cairo-surface-subsurface.c b/src/cairo-surface-subsurface.c
index 01ea7e2..3cbb516 100644
--- a/src/cairo-surface-subsurface.c
+++ b/src/cairo-surface-subsurface.c
@@ -46,16 +46,10 @@ static cairo_status_t
 _cairo_surface_subsurface_finish (void *abstract_surface)
 {
     cairo_surface_subsurface_t *surface = abstract_surface;
-    cairo_status_t status = CAIRO_STATUS_SUCCESS;
-
-    if (surface->owns_target) {
-	cairo_surface_finish (surface->target);
-	status = surface->target->status;
-    }
 
     cairo_surface_destroy (surface->target);
 
-    return status;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_surface_t *
@@ -419,7 +413,13 @@ _cairo_surface_subsurface_snapshot (void *abstract_surface)
 			 NULL, /* device */
 			 surface->target->content);
     snapshot->target = _cairo_surface_snapshot (surface->target);
-    snapshot->owns_target = TRUE;
+    if (unlikely (snapshot->target->status)) {
+	cairo_status_t status;
+
+	status = snapshot->target->status;
+	free (snapshot);
+	return _cairo_surface_create_in_error (status);
+    }
 
     snapshot->base.type = snapshot->target->type;
     snapshot->extents = surface->extents;
@@ -532,7 +532,6 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
     }
 
     surface->target = cairo_surface_reference (target);
-    surface->owns_target = FALSE;
 
     return &surface->base;
 }


More information about the cairo-commit mailing list