[cairo-commit] cairo/src Makefile.am, 1.40, 1.41 cairo-pdf.h, 1.3, 1.4 cairo.c, 1.57, 1.58 cairo.h, 1.81, 1.82 cairo_font.c, 1.35, 1.36 cairo_glitz_surface.c, 1.25, 1.26 cairo_image_surface.c, 1.28, 1.29 cairo_pdf_surface.c, 1.18, 1.19 cairo_png_surface.c, 1.18, 1.19 cairo_ps_surface.c, 1.25, 1.26 cairo_surface.c, 1.46, 1.47 cairo_win32_surface.c, 1.9, 1.10 cairo_xcb_surface.c, 1.17, 1.18 cairo_xlib_surface.c, 1.48, 1.49 cairoint.h, 1.105, 1.106

Kristian Hogsberg commit at pdx.freedesktop.org
Wed Mar 16 12:08:43 PST 2005


Committed by: krh

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv32617/src

Modified Files:
	Makefile.am cairo-pdf.h cairo.c cairo.h cairo_font.c 
	cairo_glitz_surface.c cairo_image_surface.c 
	cairo_pdf_surface.c cairo_png_surface.c cairo_ps_surface.c 
	cairo_surface.c cairo_win32_surface.c cairo_xcb_surface.c 
	cairo_xlib_surface.c cairoint.h 
Log Message:
2005-03-16  Kristian Høgsberg  <krh at redhat.com>

        * src/Makefile.am: Add cairo_output_stream.c

        * src/cairo.h: Add new errors, CAIRO_STATUS_WRITE_ERROR and
        CAIRO_STATUS_SURFACE_FINISHED, add cairo_surface_finish()
        prototype, add cairo_write_func_t.

        * src/cairo.c: Add strings for new errors, documentation fix.

        * src/cairo_win32_surface.c:
        * src/cairo_xcb_surface.c:
        * src/cairo_xlib_surface.c:
        * src/cairo_glitz_surface.c:
        * src/cairo_image_surface.c:
        * src/cairo_png_surface.c:
        * src/cairo_ps_surface.c: Rename surface destroy functions to
        finish and change them to not free the surface.

        * src/cairo-pdf.h:
        * src/cairo_pdf_surface.c: Change PDF surface constructors to take
        a write function in the general case and add stdio convenience
        constructors.  Change destroy function to finish for
        cairo_pdf_surface.  Change implementation to use
        cairo_output_stream_t functions for output.

        * src/cairo_font.c: (_cairo_font_show_glyphs): Use
        _cairo_surface_show_glyphs instead of calling function pointer
        directly.

        * src/cairoint.h: Add prototypes for cairo output stream
        functions, rename destroy to finish in cairo_surface_backend_t and
        add finished flag to cairo_surface_t.

        * src/cairo_surface.c: Add cairo_surface_finish() and call it from
        cairo_surface_destroy().  Check the finished flag in
        cairo_surface_t in functions that change the surface.



Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/src/Makefile.am,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- Makefile.am	11 Mar 2005 22:29:15 -0000	1.40
+++ Makefile.am	16 Mar 2005 20:08:41 -0000	1.41
@@ -103,6 +103,7 @@
 	cairo_traps.c		\
 	cairo_pattern.c		\
 	cairo_unicode.c		\
+	cairo_output_stream.c	\
 	cairo_wideint.c		\
 	cairo-wideint.h		\
 	$(libcairo_atsui_sources)\

Index: cairo-pdf.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pdf.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo-pdf.h	22 Feb 2005 19:35:03 -0000	1.3
+++ cairo-pdf.h	16 Mar 2005 20:08:41 -0000	1.4
@@ -46,20 +46,38 @@
 CAIRO_BEGIN_DECLS
 
 void
-cairo_set_target_pdf (cairo_t	*cr,
-		      FILE	*file,
-		      double	width_inches,
-		      double	height_inches,
-		      double	x_pixels_per_inch,
-		      double	y_pixels_per_inch);
+cairo_set_target_pdf (cairo_t			*cr,
+		      cairo_write_func_t	write_func,
+		      cairo_destroy_func_t	destroy_closure_func,
+		      void			*closure,
+		      double			width_inches,
+		      double			height_inches,
+		      double			x_pixels_per_inch,
+		      double			y_pixels_per_inch);
+
+void
+cairo_set_target_pdf_as_file (cairo_t	*cr,
+			      FILE	*fp,
+			      double	width_inches,
+			      double	height_inches,
+			      double	x_pixels_per_inch,
+			      double	y_pixels_per_inch);
 
+cairo_surface_t *
+cairo_pdf_surface_create (cairo_write_func_t	write_func,
+			  cairo_destroy_func_t	destroy_closure_func,
+			  void			*closure,
+			  double		width_inches,
+			  double		height_inches,
+			  double		x_pixels_per_inch,
+			  double		y_pixels_per_inch);
 
 cairo_surface_t *
-cairo_pdf_surface_create (FILE		*file,
-			  double	width_inches,
-			  double	height_inches,
-			  double	x_pixels_per_inch,
-			  double	y_pixels_per_inch);
+cairo_pdf_surface_create_for_file (FILE		*fp,
+				   double	width_inches,
+				   double	height_inches,
+				   double	x_pixels_per_inch,
+				   double	y_pixels_per_inch);
 
 CAIRO_END_DECLS
 

Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- cairo.c	16 Mar 2005 00:25:30 -0000	1.57
+++ cairo.c	16 Mar 2005 20:08:41 -0000	1.58
@@ -127,7 +127,7 @@
  * 
  * Decreases the reference count on @cr by one. If the result
  * is zero, then @cr and all associated resources are freed.
- * See cairo_destroy().
+ * See cairo_reference().
  **/
 void
 cairo_destroy (cairo_t *cr)
@@ -1821,6 +1821,10 @@
 	return "input string not valid UTF-8";
     case CAIRO_STATUS_INVALID_PATH_DATA:
 	return "input path data not valid";
+    case CAIRO_STATUS_WRITE_ERROR:
+	return "error while writing to output stream";
+    case CAIRO_STATUS_SURFACE_FINISHED:
+	return "the target surface has been finished";
     }
 
     return "<unknown error status>";

Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- cairo.h	16 Mar 2005 00:25:30 -0000	1.81
+++ cairo.h	16 Mar 2005 20:08:41 -0000	1.82
@@ -107,7 +107,9 @@
     CAIRO_STATUS_NO_TARGET_SURFACE,
     CAIRO_STATUS_NULL_POINTER,
     CAIRO_STATUS_INVALID_STRING,
-    CAIRO_STATUS_INVALID_PATH_DATA
+    CAIRO_STATUS_INVALID_PATH_DATA,
+    CAIRO_STATUS_WRITE_ERROR,
+    CAIRO_STATUS_SURFACE_FINISHED
 } cairo_status_t;
 
 /* Functions for manipulating state objects */
@@ -824,6 +826,9 @@
 void
 cairo_surface_destroy (cairo_surface_t *surface);
 
+cairo_status_t
+cairo_surface_finish (cairo_surface_t *surface);
+
 /* XXX: Note: The current Render/Ic implementations don't do the right
    thing with repeat when the surface has a non-identity matrix. */
 /* XXX: Rework this as a cairo function with an enum: cairo_set_pattern_extend */
@@ -989,6 +994,21 @@
 cairo_status_t
 cairo_matrix_transform_point (cairo_matrix_t *matrix, double *x, double *y);
 
+/**
+ * cairo_write_func_t
+ *
+ * #cairo_write_func_t is the type of function which is called when a
+ * backend needs to write data to an output stream.  It is passed the
+ * closure which was specified by the user at the time the write
+ * function was registered, the data to write and the length of the
+ * data in bytes.  The write function should return
+ * CAIRO_STATUS_SUCCESS if all the data was successfully written,
+ * CAIRO_STATUS_WRITE_ERROR otherwise.
+ */
+typedef cairo_status_t (*cairo_write_func_t) (void *closure,
+					      const char *data,
+					      unsigned int length);
+
 #define CAIRO_API_SHAKEUP_FLAG_DAY 0
 
 #ifndef _CAIROINT_H_

Index: cairo_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_font.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- cairo_font.c	22 Feb 2005 19:35:03 -0000	1.35
+++ cairo_font.c	16 Mar 2005 20:08:41 -0000	1.36
@@ -114,16 +114,15 @@
 			 int                    num_glyphs)
 {
     cairo_status_t status;
-    if (surface->backend->show_glyphs != NULL) {
-	status = surface->backend->show_glyphs (font, operator, pattern, 
-						surface,
-						source_x, source_y,
-						dest_x, dest_y,
-						width, height,
-						glyphs, num_glyphs);
-	if (status == CAIRO_STATUS_SUCCESS)
-	    return status;
-    }
+
+    status = _cairo_surface_show_glyphs (font, operator, pattern, 
+					 surface,
+					 source_x, source_y,
+					 dest_x, dest_y,
+					 width, height,
+					 glyphs, num_glyphs);
+    if (status != CAIRO_INT_STATUS_UNSUPPORTED)
+	return status;
 
     /* Surface display routine either does not exist or failed. */
     return font->backend->show_glyphs (font, operator, pattern, 

Index: cairo_glitz_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_glitz_surface.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- cairo_glitz_surface.c	6 Mar 2005 13:16:19 -0000	1.25
+++ cairo_glitz_surface.c	16 Mar 2005 20:08:41 -0000	1.26
@@ -54,8 +54,8 @@
     pixman_region16_t *clip;
 } cairo_glitz_surface_t;
 
-static void
-_cairo_glitz_surface_destroy (void *abstract_surface)
+static cairo_status_t
+_cairo_glitz_surface_finish (void *abstract_surface)
 {
     cairo_glitz_surface_t *surface = abstract_surface;
 
@@ -66,7 +66,8 @@
     }
     
     glitz_surface_destroy (surface->surface);
-    free (surface);
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static glitz_format_name_t
@@ -733,7 +734,7 @@
 	_cairo_pattern_release_surface (&dst->base, &surface->base,
 					&attr->base);
     else
-	_cairo_glitz_surface_destroy (surface);
+	cairo_surface_destroy (&surface->base);
 }
 
 static cairo_int_status_t
@@ -1277,7 +1278,7 @@
 
 static const cairo_surface_backend_t cairo_glitz_surface_backend = {
     _cairo_glitz_surface_create_similar,
-    _cairo_glitz_surface_destroy,
+    _cairo_glitz_surface_finish,
     _cairo_glitz_surface_pixels_per_inch,
     _cairo_glitz_surface_acquire_source_image,
     _cairo_glitz_surface_release_source_image,

Index: cairo_image_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_image_surface.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- cairo_image_surface.c	4 Mar 2005 02:39:06 -0000	1.28
+++ cairo_image_surface.c	16 Mar 2005 20:08:41 -0000	1.29
@@ -234,8 +234,8 @@
     return cairo_image_surface_create (format, width, height);
 }
 
-static void
-_cairo_image_abstract_surface_destroy (void *abstract_surface)
+static cairo_status_t
+_cairo_image_abstract_surface_finish (void *abstract_surface)
 {
     cairo_image_surface_t *surface = abstract_surface;
 
@@ -247,7 +247,7 @@
 	surface->data = NULL;
     }
 
-    free (surface);
+    return CAIRO_STATUS_SUCCESS;
 }
 
 void
@@ -658,7 +658,7 @@
 
 static const cairo_surface_backend_t cairo_image_surface_backend = {
     _cairo_image_surface_create_similar,
-    _cairo_image_abstract_surface_destroy,
+    _cairo_image_abstract_surface_finish,
     _cairo_image_surface_pixels_per_inch,
     _cairo_image_surface_acquire_source_image,
     _cairo_image_surface_release_source_image,

Index: cairo_pdf_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_pdf_surface.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- cairo_pdf_surface.c	8 Mar 2005 05:22:42 -0000	1.18
+++ cairo_pdf_surface.c	16 Mar 2005 20:08:41 -0000	1.19
@@ -153,8 +153,10 @@
 };
 
 struct cairo_pdf_document {
-    FILE *file;
+    cairo_output_stream_t *output_stream;
     unsigned long refcount;
+    cairo_surface_t *owner;
+    cairo_bool_t finished;
 
     double width_inches;
     double height_inches;
[...1295 lines suppressed...]
+			      FILE	*fp,
+			      double	width_inches,
+			      double	height_inches,
+			      double	x_pixels_per_inch,
+			      double	y_pixels_per_inch)
+{
+    cairo_output_stream_t *stream;
+
+    stream = _cairo_output_stream_create_for_file (fp);
+    if (stream == NULL) {
+	cr->status = CAIRO_STATUS_NO_MEMORY;
+	return;
+    }
+
+    return _cairo_set_target_pdf_as_stream (cr, stream,
+					    width_inches,
+					    height_inches,
+					    x_pixels_per_inch,
+					    y_pixels_per_inch);
+}

Index: cairo_png_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_png_surface.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- cairo_png_surface.c	4 Mar 2005 02:39:06 -0000	1.18
+++ cairo_png_surface.c	16 Mar 2005 20:08:41 -0000	1.19
@@ -150,8 +150,8 @@
     }
 }
 
-static void
-_cairo_png_surface_destroy (void *abstract_surface)
+static cairo_status_t
+_cairo_png_surface_finish (void *abstract_surface)
 {
     cairo_png_surface_t *surface = abstract_surface;
 
@@ -160,7 +160,7 @@
 
     cairo_surface_destroy (&surface->image->base);
 
-    free (surface);
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static void
@@ -408,7 +408,7 @@
 
 static const cairo_surface_backend_t cairo_png_surface_backend = {
     _cairo_png_surface_create_similar,
-    _cairo_png_surface_destroy,
+    _cairo_png_surface_finish,
     _cairo_png_surface_pixels_per_inch,
     _cairo_png_surface_acquire_source_image,
     _cairo_png_surface_release_source_image,

Index: cairo_ps_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_ps_surface.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- cairo_ps_surface.c	4 Mar 2005 02:39:06 -0000	1.25
+++ cairo_ps_surface.c	16 Mar 2005 20:08:41 -0000	1.26
@@ -170,8 +170,8 @@
     return NULL;
 }
 
-static void
-_cairo_ps_surface_destroy (void *abstract_surface)
+static cairo_status_t
+_cairo_ps_surface_finish (void *abstract_surface)
 {
     cairo_ps_surface_t *surface = abstract_surface;
 
@@ -180,7 +180,7 @@
 
     cairo_surface_destroy (&surface->image->base);
 
-    free (surface);
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static void
@@ -426,7 +426,7 @@
 
 static const cairo_surface_backend_t cairo_ps_surface_backend = {
     _cairo_ps_surface_create_similar,
-    _cairo_ps_surface_destroy,
+    _cairo_ps_surface_finish,
     _cairo_ps_surface_pixels_per_inch,
     _cairo_ps_surface_acquire_source_image,
     _cairo_ps_surface_release_source_image,

Index: cairo_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_surface.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- cairo_surface.c	10 Mar 2005 17:28:50 -0000	1.46
+++ cairo_surface.c	16 Mar 2005 20:08:41 -0000	1.47
@@ -51,6 +51,8 @@
     surface->backend = backend;
 
     surface->ref_count = 1;
+    surface->finished = FALSE;
+
     _cairo_array_init (&surface->user_data_slots,
 		       sizeof (cairo_user_data_slot_t));
 
@@ -164,14 +166,49 @@
     if (surface->ref_count)
 	return;
 
-    if (surface->backend->destroy)
-	surface->backend->destroy (surface);
+    cairo_surface_finish (surface);
 
     _destroy_user_data (surface);
+
+    free (surface);
 }
 slim_hidden_def(cairo_surface_destroy);
 
 /**
+ * cairo_surface_finish:
+ * @surface: the #cairo_surface_t to finish
+ * 
+ * This function finishes the surface and drops all references to
+ * external resources.  For example, for the Xlib backend it means
+ * that cairo will no longer access the drawable, which can be freed.
+ * After calling cairo_surface_finish() the only valid operations on a
+ * surface are getting and setting user data and referencing and
+ * destroying it.  Further drawing the the surface will not affect the
+ * surface but set the surface status to
+ * CAIRO_STATUS_SURFACE_FINISHED.
+ *
+ * When the last call to cairo_surface_destroy() decreases the
+ * reference count to zero, cairo will call cairo_surface_finish() if
+ * it hasn't been called already, before freeing the resources
+ * associated with the surface.
+ * 
+ * Return value: CAIRO_STATUS_SUCCESS if the surface was finished
+ * successfully, otherwise CAIRO_STATUS_NO_MEMORY or
+ * CAIRO_STATUS_WRITE_ERROR.
+ **/
+cairo_status_t
+cairo_surface_finish (cairo_surface_t *surface)
+{
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
+    if (surface->backend->finish)
+	return surface->backend->finish (surface);
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+/**
  * cairo_surface_get_user_data:
  * @surface: a #cairo_surface_t
  * @key: the address of the #cairo_user_data_key_t the user data was
@@ -281,6 +318,8 @@
 				     cairo_image_surface_t  **image_out,
 				     void                   **image_extra)
 {
+    assert (!surface->finished);
+
     return surface->backend->acquire_source_image (surface,  image_out, image_extra);
 }
 
@@ -296,6 +335,8 @@
 				     cairo_image_surface_t  *image,
 				     void                   *image_extra)
 {
+    assert (!surface->finished);
+
     surface->backend->release_source_image (surface, image, image_extra);
 }
 
@@ -334,6 +375,8 @@
 				   cairo_rectangle_t       *image_rect,
 				   void                   **image_extra)
 {
+    assert (!surface->finished);
+
     return surface->backend->acquire_dest_image (surface, interest_rect,
 						 image_out, image_rect, image_extra);
 }
@@ -357,6 +400,8 @@
 				   cairo_rectangle_t      *image_rect,
 				   void                   *image_extra)
 {
+    assert (!surface->finished);
+
     surface->backend->release_dest_image (surface, interest_rect,
 					  image, image_rect, image_extra);
 }
@@ -386,6 +431,9 @@
     cairo_image_surface_t *image;
     void *image_extra;
     
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     status = surface->backend->clone_similar (surface, src, clone_out);
     if (status != CAIRO_INT_STATUS_UNSUPPORTED)
 	return status;
@@ -409,6 +457,9 @@
 cairo_status_t
 cairo_surface_set_matrix (cairo_surface_t *surface, cairo_matrix_t *matrix)
 {
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     if (surface == NULL)
 	return CAIRO_STATUS_NULL_POINTER;
 
@@ -419,6 +470,9 @@
 cairo_status_t
 cairo_surface_get_matrix (cairo_surface_t *surface, cairo_matrix_t *matrix)
 {
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     if (surface == NULL)
 	return CAIRO_STATUS_NULL_POINTER;
 
@@ -429,6 +483,9 @@
 cairo_status_t
 cairo_surface_set_filter (cairo_surface_t *surface, cairo_filter_t filter)
 {
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     if (surface == NULL)
 	return CAIRO_STATUS_NULL_POINTER;
 
@@ -460,6 +517,9 @@
 cairo_status_t
 cairo_surface_set_repeat (cairo_surface_t *surface, int repeat)
 {
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     if (surface == NULL)
 	return CAIRO_STATUS_NULL_POINTER;
 
@@ -552,6 +612,9 @@
 {
     cairo_int_status_t status;
 
+    if (dst->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     status = dst->backend->composite (operator,
 				      src, mask, dst,
 				      src_x, src_y,
@@ -580,6 +643,9 @@
 {
     cairo_rectangle_t rect;
 
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     rect.x = x;
     rect.y = y;
     rect.width = width;
@@ -668,6 +734,9 @@
 {
     cairo_int_status_t status;
 
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     if (num_rects == 0)
 	return CAIRO_STATUS_SUCCESS;
 
@@ -763,6 +832,9 @@
 {
     cairo_int_status_t status;
 
+    if (dst->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     status = dst->backend->composite_trapezoids (operator,
 						 pattern, dst,
 						 src_x, src_y,
@@ -784,6 +856,9 @@
 {
     cairo_int_status_t status;
 
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     status = surface->backend->copy_page (surface);
     /* It's fine if some backends just don't support this. */
     if (status == CAIRO_INT_STATUS_UNSUPPORTED)
@@ -799,6 +874,9 @@
 {
     cairo_int_status_t status;
 
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     status = surface->backend->show_page (surface);
     /* It's fine if some backends just don't support this. */
     if (status == CAIRO_INT_STATUS_UNSUPPORTED)
@@ -812,5 +890,39 @@
 cairo_status_t
 _cairo_surface_set_clip_region (cairo_surface_t *surface, pixman_region16_t *region)
 {
+    if (surface->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
     return surface->backend->set_clip_region (surface, region);
 }
+
+cairo_status_t
+_cairo_surface_show_glyphs (cairo_font_t	        *font,
+			    cairo_operator_t		operator,
+			    cairo_pattern_t		*pattern,
+			    cairo_surface_t		*dst,
+			    int				source_x,
+			    int				source_y,
+			    int				dest_x,
+			    int				dest_y,
+			    unsigned int		width,
+			    unsigned int		height,
+			    const cairo_glyph_t		*glyphs,
+			    int				num_glyphs)
+{
+    cairo_status_t status;
+
+    if (dst->finished)
+	return CAIRO_STATUS_SURFACE_FINISHED;
+
+    if (dst->backend->show_glyphs != NULL)
+	status = dst->backend->show_glyphs (font, operator, pattern, dst,
+					    source_x, source_y,
+					    dest_x, dest_y,
+					    width, height,
+					    glyphs, num_glyphs);
+    else
+	status = CAIRO_INT_STATUS_UNSUPPORTED;
+
+    return status;
+}

Index: cairo_win32_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_win32_surface.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cairo_win32_surface.c	4 Mar 2005 18:43:24 -0000	1.9
+++ cairo_win32_surface.c	16 Mar 2005 20:08:41 -0000	1.10
@@ -346,7 +346,7 @@
 }
 
 static void
-_cairo_win32_surface_destroy (void *abstract_surface)
+_cairo_win32_surface_finish (void *abstract_surface)
 {
     cairo_win32_surface_t *surface = abstract_surface;
 
@@ -362,8 +362,6 @@
   	DeleteObject (surface->bitmap);
         DeleteDC (surface->dc);
     }
-  
-    free (surface);
 }
 
 static double
@@ -914,7 +912,7 @@
 
 static const cairo_surface_backend_t cairo_win32_surface_backend = {
     _cairo_win32_surface_create_similar,
-    _cairo_win32_surface_destroy,
+    _cairo_win32_surface_finish,
     _cairo_win32_surface_pixels_per_inch,
     _cairo_win32_surface_acquire_source_image,
     _cairo_win32_surface_release_source_image,

Index: cairo_xcb_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_xcb_surface.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- cairo_xcb_surface.c	4 Mar 2005 04:16:23 -0000	1.17
+++ cairo_xcb_surface.c	16 Mar 2005 20:08:41 -0000	1.18
@@ -278,7 +278,7 @@
 }
 
 static void
-_cairo_xcb_surface_destroy (void *abstract_surface)
+_cairo_xcb_surface_finish (void *abstract_surface)
 {
     cairo_xcb_surface_t *surface = abstract_surface;
     if (surface->picture.xid)
@@ -291,8 +291,6 @@
 	XCBFreeGC (surface->dpy, surface->gc);
 
     surface->dpy = 0;
-
-    free (surface);
 }
 
 static double
@@ -901,7 +899,7 @@
 
 static const cairo_surface_backend_t cairo_xcb_surface_backend = {
     _cairo_xcb_surface_create_similar,
-    _cairo_xcb_surface_destroy,
+    _cairo_xcb_surface_finish,
     _cairo_xcb_surface_pixels_per_inch,
     _cairo_xcb_surface_acquire_source_image,
     _cairo_xcb_surface_release_source_image,

Index: cairo_xlib_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_xlib_surface.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- cairo_xlib_surface.c	16 Mar 2005 00:25:30 -0000	1.48
+++ cairo_xlib_surface.c	16 Mar 2005 20:08:41 -0000	1.49
@@ -185,8 +185,8 @@
     return &surface->base;
 }
 
-static void
-_cairo_xlib_surface_destroy (void *abstract_surface)
+static cairo_status_t
+_cairo_xlib_surface_finish (void *abstract_surface)
 {
     cairo_xlib_surface_t *surface = abstract_surface;
     if (surface->picture)
@@ -200,7 +200,7 @@
 
     surface->dpy = NULL;
 
-    free (surface);
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static double
@@ -959,7 +959,7 @@
 
 static const cairo_surface_backend_t cairo_xlib_surface_backend = {
     _cairo_xlib_surface_create_similar,
-    _cairo_xlib_surface_destroy,
+    _cairo_xlib_surface_finish,
     _cairo_xlib_surface_pixels_per_inch,
     _cairo_xlib_surface_acquire_source_image,
     _cairo_xlib_surface_release_source_image,

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- cairoint.h	10 Mar 2005 16:59:11 -0000	1.105
+++ cairoint.h	16 Mar 2005 20:08:41 -0000	1.106
@@ -55,6 +55,7 @@
 #include <math.h>
 #include <limits.h>
 #include <stdint.h>
+#include <stdio.h>
 
 #include "cairo.h"
 
@@ -550,8 +551,8 @@
 				 int			width,
 				 int			height);
 
-    void
-    (*destroy)			(void			*surface);
+    cairo_status_t
+    (*finish)			(void			*surface);
 
     double
     (*pixels_per_inch)		(void			*surface);
@@ -666,6 +667,7 @@
     const cairo_surface_backend_t *backend;
 
     unsigned int ref_count;
+    cairo_bool_t finished;
     cairo_array_t user_data_slots;
 
     cairo_matrix_t matrix;
@@ -1501,6 +1503,20 @@
 cairo_private cairo_status_t
 _cairo_surface_set_clip_region (cairo_surface_t *surface, pixman_region16_t *region);
 
+cairo_private cairo_status_t
+_cairo_surface_show_glyphs (cairo_font_t	        *font,
+			    cairo_operator_t		operator,
+			    cairo_pattern_t		*pattern,
+			    cairo_surface_t		*surface,
+			    int				source_x,
+			    int				source_y,
+			    int				dest_x,
+			    int				dest_y,
+			    unsigned int		width,
+			    unsigned int		height,
+			    const cairo_glyph_t		*glyphs,
+			    int				num_glyphs);
+
 /* cairo_image_surface.c */
 
 cairo_private cairo_image_surface_t *
@@ -1764,6 +1780,35 @@
 		      uint16_t   **result,
 		      int         *items_written);
 
+/* cairo_output_stream.c */
+
+typedef struct _cairo_output_stream cairo_output_stream_t;
+
+cairo_private cairo_output_stream_t *
+_cairo_output_stream_create (cairo_write_func_t		write_func,
+			     cairo_destroy_func_t	destroy_closure_func,
+			     void			*closure);
+
+cairo_private void
+_cairo_output_stream_destroy (cairo_output_stream_t *stream);
+
+cairo_private cairo_status_t
+_cairo_output_stream_write (cairo_output_stream_t *stream,
+			    const void *data, size_t length);
+
+cairo_private cairo_status_t
+_cairo_output_stream_printf (cairo_output_stream_t *stream,
+			     const char *fmt, ...);
+
+cairo_private long
+_cairo_output_stream_get_position (cairo_output_stream_t *status);
+
+cairo_private cairo_status_t
+_cairo_output_stream_get_status (cairo_output_stream_t *stream);
+
+cairo_output_stream_t *
+_cairo_output_stream_create_for_file (FILE *fp);
+
 /* Avoid unnecessary PLT entries.  */
 
 slim_hidden_proto(cairo_close_path)




More information about the cairo-commit mailing list