[cairo-commit] cairo/src cairo-glitz.h, 1.3, 1.4 cairo-gstate.c, 1.120, 1.121 cairo-pdf.h, 1.5, 1.6 cairo-ps.h, 1.3, 1.4 cairo-quartz-surface.c, 1.8, 1.9 cairo-quartz.h, 1.4, 1.5 cairo-surface.c, 1.63, 1.64 cairo-win32.h, 1.8, 1.9 cairo-xcb.h, 1.4, 1.5 cairo-xlib.h, 1.11, 1.12 cairo.c, 1.87, 1.88 cairo.h, 1.110, 1.111 cairoint.h, 1.133, 1.134

Carl Worth commit at pdx.freedesktop.org
Fri May 6 13:23:44 PDT 2005


Committed by: cworth

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

Modified Files:
	cairo-glitz.h cairo-gstate.c cairo-pdf.h cairo-ps.h 
	cairo-quartz-surface.c cairo-quartz.h cairo-surface.c 
	cairo-win32.h cairo-xcb.h cairo-xlib.h cairo.c cairo.h 
	cairoint.h 
Log Message:

        * src/cairo.c: (cairo_create), (cairo_save), (cairo_get_target):
        * src/cairo.h:
        * src/cairoint.h:
        * src/cairo-gstate.c: (_cairo_gstate_create), (_cairo_gstate_init),
        (_cairo_gstate_get_target):
        * src/cairo-glitz.h:
        * src/cairo-pdf.h:
        * src/cairo-ps.h:
        * src/cairo-quartz-surface.c:
        * src/cairo-quartz.h:
        * src/cairo-surface.c: (_cairo_surface_begin):
        * src/cairo-win32.h:
        * src/cairo-xcb.h:
        * src/cairo-xlib.h: Remove cairo_set_target_surface and all other
        backend-specific cairo_set_target functions. Require a
        cairo_surface_t* to call cairo_create.

        * test/cairo-test.c: (create_image_surface), (cleanup_image),
        (create_glitz_surface), (cleanup_glitz), (create_quartz_surface),
        (cleanup_quartz), (create_win32_surface), (cleanup_win32),
        (create_xcb_surface), (cleanup_xcb), (create_xlib_surface),
        (cleanup_xlib), (cairo_test_for_target), (cairo_test_real):

        Port to use new cairo_create interface.

        * test/clip-nesting.c: (draw):
        * test/mask.c: (mask_polygon), (draw):
        * test/path-data.c: (main):
        * test/pdf-surface.c: (main):
        * test/pixman-rotate.c: (draw):
        * test/scale-source-surface-paint.c: (draw):
        * test/self-copy.c: (draw):
        * test/source-clip.c: (draw):
        * test/source-surface-scale-paint.c: (draw):
        * test/surface-pattern.c: (draw):

        Rewrite all tests that were using cairo_set_target_surface to
        instead create a temporary cairo_t, (eventually to be replaced
        with cairo_begin_group).


Index: cairo-glitz.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-glitz.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo-glitz.h	22 Feb 2005 19:35:03 -0000	1.3
+++ cairo-glitz.h	6 May 2005 20:23:41 -0000	1.4
@@ -45,10 +45,6 @@
 
 CAIRO_BEGIN_DECLS
 
-void
-cairo_set_target_glitz (cairo_t *cr,
-			glitz_surface_t *surface);
-
 cairo_surface_t *
 cairo_glitz_surface_create (glitz_surface_t *surface);
 

Index: cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- cairo-gstate.c	3 May 2005 21:28:50 -0000	1.120
+++ cairo-gstate.c	6 May 2005 20:23:41 -0000	1.121
@@ -42,6 +42,10 @@
 #include "cairo-gstate-private.h"
 
 static cairo_status_t
+_cairo_gstate_set_target_surface (cairo_gstate_t  *gstate,
+				  cairo_surface_t *surface);
+
+static cairo_status_t
 _cairo_gstate_clip_and_composite_trapezoids (cairo_gstate_t *gstate,
 					     cairo_pattern_t *src,
 					     cairo_operator_t operator,
@@ -58,7 +62,7 @@
 _cairo_gstate_unset_font (cairo_gstate_t *gstate);
 
 cairo_gstate_t *
-_cairo_gstate_create ()
+_cairo_gstate_create (cairo_surface_t *target)
 {
     cairo_status_t status;
     cairo_gstate_t *gstate;
@@ -67,7 +71,7 @@
 
     if (gstate)
     {
-	status = _cairo_gstate_init (gstate);
+	status = _cairo_gstate_init (gstate, target);
 	if (status) {
 	    free (gstate);
 	    return NULL;		
@@ -78,8 +82,11 @@
 }
 
 cairo_status_t
-_cairo_gstate_init (cairo_gstate_t *gstate)
+_cairo_gstate_init (cairo_gstate_t  *gstate,
+		    cairo_surface_t *target)
 {
+    cairo_status_t status;
+
     gstate->operator = CAIRO_GSTATE_OPERATOR_DEFAULT;
 
     gstate->tolerance = CAIRO_GSTATE_TOLERANCE_DEFAULT;
@@ -118,6 +125,10 @@
 
     gstate->next = NULL;
 
+    status = _cairo_gstate_set_target_surface (gstate, target);
+    if (status)
+	return status;
+
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -337,7 +348,7 @@
 }
 */
 
-cairo_status_t
+static cairo_status_t
 _cairo_gstate_set_target_surface (cairo_gstate_t *gstate, cairo_surface_t *surface)
 {
     cairo_status_t status;
@@ -376,19 +387,12 @@
     return CAIRO_STATUS_SUCCESS;
 }
 
-/* XXX: Need to decide the memory mangement semantics of this
-   function. Should it reference the surface again? */
 cairo_surface_t *
-_cairo_gstate_get_target_surface (cairo_gstate_t *gstate)
+_cairo_gstate_get_target (cairo_gstate_t *gstate)
 {
     if (gstate == NULL)
 	return NULL;
 
-/* XXX: Do we want this?
-    if (gstate->surface)
-	_cairo_surface_reference (gstate->surface);
-*/
-
     return gstate->surface;
 }
 

Index: cairo-pdf.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pdf.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo-pdf.h	28 Mar 2005 21:58:26 -0000	1.5
+++ cairo-pdf.h	6 May 2005 20:23:41 -0000	1.6
@@ -45,24 +45,6 @@
 
 CAIRO_BEGIN_DECLS
 
-void
-cairo_set_target_pdf (cairo_t	*cr,
-		      FILE	*fp,
-		      double	width_inches,
-		      double	height_inches,
-		      double	x_pixels_per_inch,
-		      double	y_pixels_per_inch);
-
-void
-cairo_set_target_pdf_for_callback (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);
-
 cairo_surface_t *
 cairo_pdf_surface_create (FILE		*fp,
 			  double	width_inches,

Index: cairo-ps.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-ps.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo-ps.h	22 Feb 2005 19:35:03 -0000	1.3
+++ cairo-ps.h	6 May 2005 20:23:41 -0000	1.4
@@ -45,14 +45,6 @@
 
 CAIRO_BEGIN_DECLS
 
-void
-cairo_set_target_ps (cairo_t	*cr,
-		     FILE	*file,
-		     double	width_inches,
-		     double	height_inches,
-		     double	x_pixels_per_inch,
-		     double	y_pixels_per_inch);
-
 /* PS-surface functions */
 
 cairo_surface_t *

Index: cairo-quartz-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-quartz-surface.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cairo-quartz-surface.c	19 Apr 2005 23:29:05 -0000	1.8
+++ cairo-quartz-surface.c	6 May 2005 20:23:41 -0000	1.9
@@ -58,30 +58,6 @@
     }
 }
 
-
-void
-cairo_set_target_quartz_context(cairo_t * cr,
-                                CGContextRef context,
-                                int width, int height)
-{
-    cairo_surface_t *surface;
-
-
-    if (cr->status && cr->status != CAIRO_STATUS_NO_TARGET_SURFACE)
-        return;
-
-    surface = cairo_quartz_surface_create(context, width, height);
-    if (surface == NULL) {
-        cr->status = CAIRO_STATUS_NO_MEMORY;
-        return;
-    }
-
-    cairo_set_target_surface(cr, surface);
-
-    /* cairo_set_target_surface takes a reference, so we must destroy ours */
-    cairo_surface_destroy(surface);
-}
-
 static cairo_surface_t *_cairo_quartz_surface_create_similar(void
                                                              *abstract_src,
                                                              cairo_format_t

Index: cairo-quartz.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-quartz.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cairo-quartz.h	22 Feb 2005 19:35:03 -0000	1.4
+++ cairo-quartz.h	6 May 2005 20:23:41 -0000	1.5
@@ -45,12 +45,6 @@
 
 CAIRO_BEGIN_DECLS
 
-void
-cairo_set_target_quartz_context(   	cairo_t		*cr,
-					CGContextRef    context,
-					int		width,
-					int		height);
-
 cairo_surface_t *
 cairo_quartz_surface_create (   CGContextRef    context,
 				int		width,

Index: cairo-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-surface.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- cairo-surface.c	3 May 2005 21:28:50 -0000	1.63
+++ cairo-surface.c	6 May 2005 20:23:41 -0000	1.64
@@ -126,7 +126,7 @@
 cairo_private cairo_status_t
 _cairo_surface_begin (cairo_surface_t *surface)
 {
-  return _cairo_surface_begin_internal (surface, FALSE);
+    return _cairo_surface_begin_internal (surface, FALSE);
 }
 
 /**

Index: cairo-win32.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-win32.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cairo-win32.h	7 Apr 2005 19:56:43 -0000	1.8
+++ cairo-win32.h	6 May 2005 20:23:41 -0000	1.9
@@ -44,10 +44,6 @@
 
 CAIRO_BEGIN_DECLS
 
-void 
-cairo_set_target_win32 (cairo_t *cr,
-			HDC      hdc);
-
 cairo_surface_t *
 cairo_win32_surface_create (HDC hdc);
 

Index: cairo-xcb.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xcb.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cairo-xcb.h	25 Mar 2005 19:47:39 -0000	1.4
+++ cairo-xcb.h	6 May 2005 20:23:41 -0000	1.5
@@ -46,13 +46,6 @@
 
 CAIRO_BEGIN_DECLS
 
-void
-cairo_set_target_xcb (cairo_t		*cr,
-		      XCBConnection	*dpy,
-		      XCBDRAWABLE	drawable,
-		      XCBVISUALTYPE	*visual,
-		      cairo_format_t	format);
-
 cairo_surface_t *
 cairo_xcb_surface_create (XCBConnection		*dpy,
 			   XCBDRAWABLE		drawable,

Index: cairo-xlib.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xlib.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cairo-xlib.h	29 Mar 2005 19:54:01 -0000	1.11
+++ cairo-xlib.h	6 May 2005 20:23:41 -0000	1.12
@@ -46,13 +46,6 @@
 
 CAIRO_BEGIN_DECLS
 
-/* XXX: This should be renamed to cairo_set_target_xlib to match the
- * other backends */
-void
-cairo_set_target_drawable (cairo_t	*cr,
-			   Display	*dpy,
-			   Drawable	drawable);
-
 cairo_surface_t *
 cairo_xlib_surface_create_for_pixmap (Display        *dpy,
 				      Pixmap	      pixmap,

Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- cairo.c	6 May 2005 19:00:22 -0000	1.87
+++ cairo.c	6 May 2005 20:23:41 -0000	1.88
@@ -74,20 +74,36 @@
 #endif
 
 
-/**
+/*
  * cairo_create:
+ * @target: target surface for the context
  * 
- * Creates a new #cairo_t with default values. The target
- * surface must be set on the #cairo_t with cairo_set_target_surface(),
- * or a backend-specific function like cairo_set_target_image() before
- * drawing with the #cairo_t.
+ * Creates a new #cairo_t with all graphics state parameters set to
+ * default values and with @target as a target surface. The target
+ * surface should be constructed with a backend-specific function such
+ * as cairo_image_surface_create (or any other
+ * cairo_<backend>_surface_create variant).
+ *
+ * This function references @target, so you can immediately
+ * call cairo_surface_destroy() on it if you don't need to
+ * maintain a separate reference to it.
+ *
+ * Note that there are restrictions on using the same surface in
+ * multiple contexts at the same time. If, after creating @cr_a with
+ * @surface you also create @cr_b with the same surface, you must
+ * ensure that @cr_b has finished using @surface before resuming use
+ * of @cr_a. Currently, the only way time at which this is guaranteed
+ * is when the the last reference to @cr_b is released with
+ * cairo_destroy(). (XXX: We need to add a cairo_finish() call to
+ * provide a way to achieve this explicitly). See also the
+ * %CAIRO_STATUS_BAD_NESTING status.
  * 
  * Return value: a newly allocated #cairo_t with a reference
  *  count of 1. The initial reference count should be released
  *  with cairo_destroy() when you are done using the #cairo_t.
- **/
+ */
 cairo_t *
-cairo_create (void)
+cairo_create (cairo_surface_t *target)
 {
     cairo_t *cr;
 
@@ -98,12 +114,18 @@
     cr->status = CAIRO_STATUS_SUCCESS;
     cr->ref_count = 1;
 
-    cr->gstate = _cairo_gstate_create ();
+    _cairo_path_fixed_init (&cr->path);
+
+    if (target == NULL) {
+	cr->gstate = NULL;
+	cr->status = CAIRO_STATUS_NULL_POINTER;
+	return cr;
+    }
+
+    cr->gstate = _cairo_gstate_create (target);
     if (cr->gstate == NULL)
 	cr->status = CAIRO_STATUS_NO_MEMORY;
 
-    _cairo_path_fixed_init (&cr->path);
-
     CAIRO_CHECK_SANITY (cr);
     return cr;
 }
@@ -180,11 +202,7 @@
     if (cr->status)
 	return;
 
-    if (cr->gstate) {
-	top = _cairo_gstate_clone (cr->gstate);
-    } else {
-	top = _cairo_gstate_create ();
-    }
+    top = _cairo_gstate_clone (cr->gstate);
 
     if (top == NULL) {
 	cr->status = CAIRO_STATUS_NO_MEMORY;
@@ -291,366 +309,6 @@
 */
 
 /**
- * cairo_set_target_surface:
- * @cr: a #cairo_t
- * @surface: a #cairo_surface_t
- * 
- * Directs output for a #cairo_t to a given surface. The surface
- * will be referenced by the #cairo_t, so you can immediately
- * call cairo_surface_destroy() on it if you don't need to
- * keep a reference to it around.
- *
- * Note that there are restrictions on using the same surface in
- * multiple contexts at the same time. If, after setting @surface as
- * the target surface of @cr_a, you set it as the target surface of
- * @cr_b, you must finish using @cr_b and unset the target surface
- * before resuming using @cr_a. Unsetting the target surface happens
- * automatically when the last reference to the context is released
- * with cairo_destroy(), or you can call cairo_set_target_surface
- * (@cr_b, %NULL) explicitly.  See also the %CAIRO_STATUS_BAD_NESTING
- * status.
- **/
-void
-cairo_set_target_surface (cairo_t *cr, cairo_surface_t *surface)
-{
-    CAIRO_CHECK_SANITY (cr);
-    if (cr->status)
-	return;
-
-    cr->status = _cairo_gstate_set_target_surface (cr->gstate, surface);
-    CAIRO_CHECK_SANITY (cr);
-}
-slim_hidden_def(cairo_set_target_surface);
-
-/**
- * cairo_set_target_image:
- * @cr: a #cairo_t
- * @data: a pointer to a buffer supplied by the application
- *    in which to write contents.
- * @format: the format of pixels in the buffer
- * @width: the width of the image to be stored in the buffer
- * @height: the eight of the image to be stored in the buffer
- * @stride: the number of bytes between the start of rows
- *   in the buffer. Having this be specified separate from @width
- *   allows for padding at the end of rows, or for writing
- *   to a subportion of a larger image.
- * 
- * Directs output for a #cairo_t to an in-memory image. The output
- * buffer must be kept around until the #cairo_t is destroyed or set
- * to to have a different target.  The initial contents of @buffer
- * will be used as the inital image contents; you must explicitly
- * clear the buffer, using, for example, cairo_rectangle() and
- * cairo_fill() if you want it cleared.
- **/
-void
-cairo_set_target_image (cairo_t		*cr,
-			unsigned char	*data,
-			cairo_format_t	 format,
-			int		 width,
-			int		 height,
-			int		 stride)
-{
-    cairo_surface_t *surface;
-
-    CAIRO_CHECK_SANITY (cr);
-    if (cr->status)
-	return;
-
-    surface = cairo_image_surface_create_for_data (data,
-						   format,
-						   width, height, stride);
-    if (surface == NULL) {
-	cr->status = CAIRO_STATUS_NO_MEMORY;
-	CAIRO_CHECK_SANITY (cr);
-	return;
-    }
-
-    cairo_set_target_surface (cr, surface);
-
-    cairo_surface_destroy (surface);
-    CAIRO_CHECK_SANITY (cr);
-}
-
-/**
- * cairo_set_target_image_no_data:
- * @cr: a #cairo_t
- * @format: the format of pixels in the buffer
- * @width: the width of the image to be stored in the buffer
- * @height: the eight of the image to be stored in the buffer
- * 
- * Directs output for a #cairo_t to an implicit image surface of the
- * given format that will be created and owned by the cairo
- * context. The initial contents of the target surface will be
- * cleared to 0 in all channels, (ie. transparent black).
- *
- * NOTE: This function has an unconventional name, but that will be
- * straightened out in a future change in which all set_target
- * functions will be renamed.
- **/
-void
-cairo_set_target_image_no_data (cairo_t		*cr,
-				cairo_format_t	format,
-				int		width,
-				int		height)
-{
-    cairo_surface_t *surface;
-
-    CAIRO_CHECK_SANITY (cr);
-    if (cr->status)
-	return;
-
-    surface = cairo_image_surface_create (format, width, height);
-    if (surface == NULL) {
-	cr->status = CAIRO_STATUS_NO_MEMORY;
-	CAIRO_CHECK_SANITY (cr);
-	return;
-    }
-
-    cairo_set_target_surface (cr, surface);
-
-    cairo_surface_destroy (surface);
-    CAIRO_CHECK_SANITY (cr);
-}
-
-#ifdef CAIRO_HAS_GLITZ_SURFACE
-
-#include "cairo-glitz.h"
-
-void
-cairo_set_target_glitz (cairo_t *cr, glitz_surface_t *surface)
-{
-    cairo_surface_t *crsurface;
-
-    CAIRO_CHECK_SANITY (cr);
-    if (cr->status)
-	return;
-
-    crsurface = cairo_glitz_surface_create (surface);
-    if (crsurface == NULL) {
-	cr->status = CAIRO_STATUS_NO_MEMORY;
-	return;
-    }
-
-    cairo_set_target_surface (cr, crsurface);
-
-    cairo_surface_destroy (crsurface);
-
-    CAIRO_CHECK_SANITY (cr);
-}
-#endif /* CAIRO_HAS_GLITZ_SURFACE */
-
-#ifdef CAIRO_HAS_PDF_SURFACE
-
-#include "cairo-pdf.h"
-
-void
-cairo_set_target_pdf_for_callback (cairo_t		*cr,
-				   cairo_write_func_t	write,
-				   cairo_destroy_func_t	destroy_closure,
-				   void			*closure,
-				   double		width_inches,
-				   double		height_inches,
-				   double		x_pixels_per_inch,
-				   double		y_pixels_per_inch)
-{
-    cairo_surface_t *surface;
-
-    CAIRO_CHECK_SANITY (cr);
-    if (cr->status)
-	return;
-
-    surface = cairo_pdf_surface_create_for_callback (write,
-						     destroy_closure, closure,
-						     width_inches, height_inches,
-						     x_pixels_per_inch, y_pixels_per_inch);
-    if (surface == NULL) {
-	cr->status = CAIRO_STATUS_NO_MEMORY;
-	return;
-    }
-
-    cairo_set_target_surface (cr, surface);
-
-    /* cairo_set_target_surface takes a reference, so we must destroy ours */
-    cairo_surface_destroy (surface);
-}
-
-void
-cairo_set_target_pdf (cairo_t	*cr,
-		      FILE	*fp,
-		      double	width_inches,
-		      double	height_inches,
-		      double	x_pixels_per_inch,
-		      double	y_pixels_per_inch)
-{
-    cairo_surface_t *surface;
-
-    CAIRO_CHECK_SANITY (cr);
-    if (cr->status)
-	return;
-
-    surface = cairo_pdf_surface_create (fp,
-					width_inches, height_inches,
-					x_pixels_per_inch,
-					y_pixels_per_inch);
-    if (surface == NULL) {
-	cr->status = CAIRO_STATUS_NO_MEMORY;
-	return;
-    }
-
-    cairo_set_target_surface (cr, surface);
-
-    /* cairo_set_target_surface takes a reference, so we must destroy ours */
-    cairo_surface_destroy (surface);
-}
-#endif /* CAIRO_HAS_PDF_SURFACE */
-
-#ifdef CAIRO_HAS_PS_SURFACE
-
-#include "cairo-ps.h"
-
-/**
- * cairo_set_target_ps:
- * @cr: a #cairo_t
- * @file: an open, writeable file
- * @width_inches: width of the output page, in inches
- * @height_inches: height of the output page, in inches
- * @x_pixels_per_inch: X resolution to use for image fallbacks;
- *   not all cairo drawing can be represented in a postscript
- *   file, so cairo will write out images for some portions
- *   of the output.
- * @y_pixels_per_inch: Y resolution to use for image fallbacks.
- * 
- * Directs output for a #cairo_t to a postscript file. The file must
- * be kept open until the #cairo_t is destroyed or set to have a
- * different target, and then must be closed by the application.
- **/
-void
-cairo_set_target_ps (cairo_t	*cr,
-		     FILE	*file,
-		     double	width_inches,
-		     double	height_inches,
-		     double	x_pixels_per_inch,
-		     double	y_pixels_per_inch)
-{
-    cairo_surface_t *surface;
-
-    surface = cairo_ps_surface_create (file,
-				       width_inches, height_inches,
-				       x_pixels_per_inch, y_pixels_per_inch);
-    if (surface == NULL) {
-	cr->status = CAIRO_STATUS_NO_MEMORY;
-	return;
-    }
-
-    cairo_set_target_surface (cr, surface);
-
-    /* cairo_set_target_surface takes a reference, so we must destroy ours */
-    cairo_surface_destroy (surface);
-}
-#endif /* CAIRO_HAS_PS_SURFACE */
-
-#ifdef CAIRO_HAS_WIN32_SURFACE
-
-#include "cairo-win32.h"
-
-void
-cairo_set_target_win32 (cairo_t *cr,
-			HDC      hdc)
-{
-    cairo_surface_t *surface;
-
-    if (cr->status && cr->status != CAIRO_STATUS_NO_TARGET_SURFACE)
-	return;
-
-    surface = cairo_win32_surface_create (hdc);
-    if (surface == NULL) {
-	cr->status = CAIRO_STATUS_NO_MEMORY;
-	return;
-    }
-
-    cairo_set_target_surface (cr, surface);
-
-    /* cairo_set_target_surface takes a reference, so we must destroy ours */
-    cairo_surface_destroy (surface);
-}
-#endif /* CAIRO_HAS_WIN32_SURFACE */
-
-#ifdef CAIRO_HAS_XCB_SURFACE
-
-#include "cairo-xcb.h"
-
-void
-cairo_set_target_xcb (cairo_t		*cr,
-		      XCBConnection	*dpy,
-		      XCBDRAWABLE		drawable,
-		      XCBVISUALTYPE	*visual,
-		      cairo_format_t	format)
-{
-    cairo_surface_t *surface;
-
-    if (cr->status && cr->status != CAIRO_STATUS_NO_TARGET_SURFACE)
-	    return;
-
-    surface = cairo_xcb_surface_create (dpy, drawable, visual, format);
-    if (surface == NULL) {
-	cr->status = CAIRO_STATUS_NO_MEMORY;
-	return;
-    }
-
-    cairo_set_target_surface (cr, surface);
-
-    /* cairo_set_target_surface takes a reference, so we must destroy ours */
-    cairo_surface_destroy (surface);
-}
-#endif /* CAIRO_HAS_XCB_SURFACE */
-
-#ifdef CAIRO_HAS_XLIB_SURFACE
-
-#include "cairo-xlib.h"
-
-/**
- * cairo_set_target_drawable:
- * @cr: a #cairo_t
- * @dpy: an X display
- * @drawable: a window or pixmap on the default screen of @dpy
- * 
- * Directs output for a #cairo_t to an Xlib drawable.  @drawable must
- * be a Window or Pixmap on the default screen of @dpy using the
- * default colormap and visual.  Using this function is slow because
- * the function must retrieve information about @drawable from the X
- * server.
- 
- * The combination of cairo_xlib_surface_create() and
- * cairo_set_target_surface() is somewhat more flexible, although
- * it still is slow.
- **/
-void
-cairo_set_target_drawable (cairo_t	*cr,
-			   Display	*dpy,
-			   Drawable	drawable)
-{
-    cairo_surface_t *surface;
-
-    if (cr->status && cr->status != CAIRO_STATUS_NO_TARGET_SURFACE)
-	    return;
-
-    surface = cairo_xlib_surface_create (dpy, drawable,
-					 DefaultVisual (dpy, DefaultScreen (dpy)),
-					 0,
-					 DefaultColormap (dpy, DefaultScreen (dpy)));
-    if (surface == NULL) {
-	cr->status = CAIRO_STATUS_NO_MEMORY;
-	return;
-    }
-
-    cairo_set_target_surface (cr, surface);
-
-    /* cairo_set_target_surface takes a reference, so we must destroy ours */
-    cairo_surface_destroy (surface);
-}
-#endif /* CAIRO_HAS_XLIB_SURFACE */
-
-/**
  * cairo_set_operator:
  * @cr: a #cairo_t
  * @op: a compositing operator, specified as a #cairo_operator_t
@@ -2444,23 +2102,26 @@
 DEPRECATE(cairo_current_matrix, cairo_get_matrix);
 
 /**
- * cairo_get_target_surface:
+ * cairo_get_target:
  * @cr: a cairo context
  * 
- * Gets the current target surface, as set by cairo_set_target_surface().
+ * Gets the target surface for the cairo context as passed to
+ * cairo_create().
  * 
- * Return value: the current target surface.
- *
- * WARNING: This function is scheduled to be removed as part of the
- * upcoming API Shakeup.
+ * Return value: the target surface, (or NULL if @cr is in an error
+ * state). This object is owned by cairo. To keep a reference to it,
+ * you must call cairo_pattern_reference().
  **/
 cairo_surface_t *
-cairo_get_target_surface (cairo_t *cr)
+cairo_get_target (cairo_t *cr)
 {
     CAIRO_CHECK_SANITY (cr);
-    return _cairo_gstate_get_target_surface (cr->gstate);
+    if (cr->status)
+	return NULL;
+
+    return _cairo_gstate_get_target (cr->gstate);
 }
-DEPRECATE (cairo_current_target_surface, cairo_get_target_surface);
+DEPRECATE (cairo_current_target_surface, cairo_get_target);
 
 void
 cairo_get_path (cairo_t			*cr,

Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- cairo.h	6 May 2005 19:00:22 -0000	1.110
+++ cairo.h	6 May 2005 20:23:41 -0000	1.111
@@ -143,7 +143,7 @@
  *  target surface for two different cairo contexts at once,
  *  and more drawing was done on the first context before the
  *  surface was unset as the target for the second context.
- *  See the documentation for cairo_set_target_surface()
+ *  See the documentation for cairo_create().
  *
  * #cairo_status_t is used to indicate errors that can occur when
  * using Cairo. In some cases it is returned directly by functions.
@@ -200,7 +200,7 @@
 
 /* Functions for manipulating state objects */
 cairo_t *
-cairo_create (void);
+cairo_create (cairo_surface_t *target);
 
 void
 cairo_reference (cairo_t *cr);
@@ -227,55 +227,6 @@
 */
 
 /* Modify state */
-void
-cairo_set_target_surface (cairo_t *cr, cairo_surface_t *surface);
-
-/**
- * cairo_format_t
- * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
- *   alpha in the upper 8 bits, then red, then green, then blue.
- *   The 32-bit quantities are stored native-endian. Pre-multiplied
- *   alpha is used. (That is, 50% transparent red is 0x80800000,
- *   not 0x80ff0000.)
- * @CAIRO_FORMAT_RGB24: each pixel is a 32-bit quantity, with
- *   the upper 8 bits unused. Red, Green, and Blue are stored
- *   in the remaining 24 bits in that order.
- * @CAIRO_FORMAT_A8: each pixel is a 8-bit quantity holding
- *   an alpha value.
- * @CAIRO_FORMAT_A1: each pixel is a 1-bit quantity holding
- *   an alpha value. Pixels are packed together into 32-bit
- *   quantities. The ordering of the bits matches the
- *   endianess of the platform. On a big-endian machine, the
- *   first pixel is in the uppermost bit, on a little-endian
- *   machine the first pixel is in the least-significant bit.
- *
- * #cairo_format_t is used to identify the memory format of
- * image data.
- */
-typedef enum cairo_format {
-    CAIRO_FORMAT_ARGB32,
-    CAIRO_FORMAT_RGB24,
-    CAIRO_FORMAT_A8,
-    CAIRO_FORMAT_A1
-} cairo_format_t;
-
-/* XXX: The naming of these two functions is reversed from their
- *      cairo_image_surface_create counterparts. We'll fix this when
- *      we eliminate all the cairo_set_target functions.
- */
-void
-cairo_set_target_image (cairo_t	       *cr,
-			unsigned char  *data,
-			cairo_format_t	format,
-			int		width,
-			int		height,
-			int		stride);
-
-void
-cairo_set_target_image_no_data (cairo_t	*cr,
-				cairo_format_t	format,
-				int	width,
-				int	height);
 
 typedef enum cairo_operator { 
     CAIRO_OPERATOR_CLEAR,
@@ -844,7 +795,7 @@
 /* XXX: Need to decide the memory management semantics of this
    function. Should it reference the surface again? */
 cairo_surface_t *
-cairo_get_target_surface (cairo_t *cr);
+cairo_get_target (cairo_t *cr);
 
 typedef void (cairo_move_to_func_t) (void *closure,
 				     double x, double y);
@@ -991,8 +942,37 @@
 
 /* Surface manipulation */
 
+/**
+ * cairo_format_t
+ * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
+ *   alpha in the upper 8 bits, then red, then green, then blue.
+ *   The 32-bit quantities are stored native-endian. Pre-multiplied
+ *   alpha is used. (That is, 50% transparent red is 0x80800000,
+ *   not 0x80ff0000.)
+ * @CAIRO_FORMAT_RGB24: each pixel is a 32-bit quantity, with
+ *   the upper 8 bits unused. Red, Green, and Blue are stored
+ *   in the remaining 24 bits in that order.
+ * @CAIRO_FORMAT_A8: each pixel is a 8-bit quantity holding
+ *   an alpha value.
+ * @CAIRO_FORMAT_A1: each pixel is a 1-bit quantity holding
+ *   an alpha value. Pixels are packed together into 32-bit
+ *   quantities. The ordering of the bits matches the
+ *   endianess of the platform. On a big-endian machine, the
+ *   first pixel is in the uppermost bit, on a little-endian
+ *   machine the first pixel is in the least-significant bit.
+ *
+ * #cairo_format_t is used to identify the memory format of
+ * image data.
+ */
+typedef enum cairo_format {
+    CAIRO_FORMAT_ARGB32,
+    CAIRO_FORMAT_RGB24,
+    CAIRO_FORMAT_A8,
+    CAIRO_FORMAT_A1
+} cairo_format_t;
+
 /* XXX: I want to remove this function, (replace with
-   cairo_set_target_scratch or similar). */
+   cairo_begin_group and friends). */
 cairo_surface_t *
 cairo_surface_create_similar (cairo_surface_t	*other,
 			      cairo_format_t	format,

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -d -r1.133 -r1.134
--- cairoint.h	3 May 2005 21:28:50 -0000	1.133
+++ cairoint.h	6 May 2005 20:23:41 -0000	1.134
@@ -926,10 +926,11 @@
 
 /* cairo_gstate.c */
 cairo_private cairo_gstate_t *
-_cairo_gstate_create (void);
+_cairo_gstate_create (cairo_surface_t *target);
 
 cairo_private cairo_status_t
-_cairo_gstate_init (cairo_gstate_t *gstate);
+_cairo_gstate_init (cairo_gstate_t  *gstate,
+		    cairo_surface_t *target);
 
 cairo_private cairo_status_t
 _cairo_gstate_init_copy (cairo_gstate_t *gstate, cairo_gstate_t *other);
@@ -952,11 +953,8 @@
 cairo_private cairo_status_t
 _cairo_gstate_end_group (cairo_gstate_t *gstate);
 
-cairo_private cairo_status_t
-_cairo_gstate_set_target_surface (cairo_gstate_t *gstate, cairo_surface_t *surface);
-
 cairo_private cairo_surface_t *
-_cairo_gstate_get_target_surface (cairo_gstate_t *gstate);
+_cairo_gstate_get_target (cairo_gstate_t *gstate);
 
 cairo_private cairo_status_t
 _cairo_gstate_set_source (cairo_gstate_t *gstate, cairo_pattern_t *source);
@@ -1818,7 +1816,6 @@
 slim_hidden_proto(cairo_rel_line_to)
 slim_hidden_proto(cairo_restore)
 slim_hidden_proto(cairo_save)
-slim_hidden_proto(cairo_set_target_surface)
 slim_hidden_proto(cairo_stroke_preserve)
 slim_hidden_proto(cairo_surface_destroy)
 slim_hidden_proto(cairo_surface_get_matrix)




More information about the cairo-commit mailing list