[cairo-commit] pycairo/cairo pycairo-context.c, 1.87, 1.88 pycairo-surface.c, 1.90, 1.91 cairomodule.c, 1.69, 1.70 pycairo-font.c, 1.37, 1.38

Steve Chaplin commit at pdx.freedesktop.org
Mon Nov 24 07:39:41 PST 2008


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory kemper:/tmp/cvs-serv13516/cairo

Modified Files:
	pycairo-context.c pycairo-surface.c cairomodule.c 
	pycairo-font.c 
Log Message:
'SC'

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- pycairo-context.c	12 May 2008 12:06:37 -0000	1.87
+++ pycairo-context.c	24 Nov 2008 15:39:37 -0000	1.88
@@ -2,7 +2,7 @@
  *
  * Pycairo - Python bindings for cairo
  *
- * Copyright © 2003-2005 James Henstridge
+ * Copyright © 2003 James Henstridge, Steven Chaplin
  *
  * This library is free software; you can redistribute it and/or
  * modify it either under the terms of the GNU Lesser General Public
@@ -124,7 +124,9 @@
 			  &PycairoPath_Type, &p))
 	return NULL;
 
+    Py_BEGIN_ALLOW_THREADS
     cairo_append_path (o->ctx, p->path);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -160,7 +162,9 @@
 static PyObject *
 pycairo_clip (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_clip (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -177,7 +181,9 @@
 static PyObject *
 pycairo_clip_preserve (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_clip_preserve (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -185,7 +191,9 @@
 static PyObject *
 pycairo_close_path (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_close_path (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -226,7 +234,9 @@
 static PyObject *
 pycairo_copy_page (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_copy_page (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -234,13 +244,21 @@
 static PyObject *
 pycairo_copy_path (PycairoContext *o)
 {
-    return PycairoPath_FromPath (cairo_copy_path (o->ctx));
+    cairo_path_t *cp;
+    Py_BEGIN_ALLOW_THREADS
+    cp = cairo_copy_path (o->ctx);
+    Py_END_ALLOW_THREADS
+    return PycairoPath_FromPath (cp);
 }
 
 static PyObject *
 pycairo_copy_path_flat (PycairoContext *o)
 {
-    return PycairoPath_FromPath (cairo_copy_path_flat (o->ctx));
+    cairo_path_t *cp;
+    Py_BEGIN_ALLOW_THREADS
+    cp = cairo_copy_path_flat (o->ctx);
+    Py_END_ALLOW_THREADS
+    return PycairoPath_FromPath (cp);
 }
 
 static PyObject *
@@ -287,7 +305,9 @@
 static PyObject *
 pycairo_fill (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_fill (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -304,7 +324,9 @@
 static PyObject *
 pycairo_fill_preserve (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_fill_preserve (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -639,7 +661,9 @@
     if (!PyArg_ParseTuple(args, "O!:Context.mask", &PycairoPattern_Type, &p))
 	return NULL;
 
+    Py_BEGIN_ALLOW_THREADS
     cairo_mask (o->ctx, p->pattern);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -654,7 +678,9 @@
 			   &PycairoSurface_Type, &s, &surface_x, &surface_y))
 	return NULL;
 
+    Py_BEGIN_ALLOW_THREADS
     cairo_mask_surface (o->ctx, s->surface, surface_x, surface_y);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -691,7 +717,9 @@
 static PyObject *
 pycairo_paint (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_paint (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -704,7 +732,9 @@
     if (!PyArg_ParseTuple (args, "d:Context.paint_with_alpha", &alpha))
 	return NULL;
 
+    Py_BEGIN_ALLOW_THREADS
     cairo_paint_with_alpha (o->ctx, alpha);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -1160,7 +1190,9 @@
     glyphs = _PyGlyphs_AsGlyphs (py_object, &num_glyphs);
     if (glyphs == NULL)
 	return NULL;
+    Py_BEGIN_ALLOW_THREADS
     cairo_show_glyphs (o->ctx, glyphs, num_glyphs);
+    Py_END_ALLOW_THREADS
     PyMem_Free (glyphs);
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
@@ -1169,7 +1201,9 @@
 static PyObject *
 pycairo_show_page (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_show_page (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -1185,7 +1219,9 @@
 	return NULL;
     }
 
+    Py_BEGIN_ALLOW_THREADS
     cairo_show_text (o->ctx, utf8);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -1193,7 +1229,9 @@
 static PyObject *
 pycairo_stroke (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_stroke (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }
@@ -1210,7 +1248,9 @@
 static PyObject *
 pycairo_stroke_preserve (PycairoContext *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_stroke_preserve (o->ctx);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
     Py_RETURN_NONE;
 }

Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- pycairo-surface.c	1 Sep 2008 13:56:24 -0000	1.90
+++ pycairo-surface.c	24 Nov 2008 15:39:38 -0000	1.91
@@ -2,7 +2,7 @@
  *
  * Pycairo - Python bindings for cairo
  *
- * Copyright © 2003-2005 James Henstridge
+ * Copyright © 2003 James Henstridge, Steven Chaplin
  *
  * This library is free software; you can redistribute it and/or
  * modify it either under the terms of the GNU Lesser General Public
@@ -70,9 +70,11 @@
     }
 
     switch (cairo_surface_get_type (surface)) {
+#if CAIRO_HAS_IMAGE_SURFACE
     case CAIRO_SURFACE_TYPE_IMAGE:
 	type = &PycairoImageSurface_Type;
 	break;
+#endif
 #if CAIRO_HAS_PDF_SURFACE
     case CAIRO_SURFACE_TYPE_PDF:
 	type = &PycairoPDFSurface_Type;
@@ -156,7 +158,9 @@
 static PyObject *
 surface_copy_page (PycairoSurface *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_surface_copy_page (o->surface);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface);
     Py_RETURN_NONE;
 }
@@ -187,7 +191,9 @@
 static PyObject *
 surface_flush (PycairoSurface *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_surface_flush (o->surface);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface);
     Py_RETURN_NONE;
 }
@@ -260,7 +266,9 @@
 static PyObject *
 surface_show_page (PycairoSurface *o)
 {
+    Py_BEGIN_ALLOW_THREADS
     cairo_surface_show_page (o->surface);
+    Py_END_ALLOW_THREADS
     RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface);
     Py_RETURN_NONE;
 }
@@ -274,8 +282,10 @@
 
     if (PyObject_TypeCheck (file, &PyBaseString_Type)) {
 	/* string (filename) argument */
+	Py_BEGIN_ALLOW_THREADS
 	status = cairo_surface_write_to_png (o->surface,
 					     PyString_AsString(file));
+	Py_END_ALLOW_THREADS
 
     } else {  /* file or file-like object argument */
 	PyObject* writer = PyObject_GetAttrString (file, "write");
@@ -287,8 +297,10 @@
 	    return NULL;
 	}
 	Py_DECREF(writer);
+	Py_BEGIN_ALLOW_THREADS
 	status = cairo_surface_write_to_png_stream (o->surface, _write_func,
 						    file);
+	Py_END_ALLOW_THREADS
     }
     RETURN_NULL_IF_CAIRO_ERROR(status);
     Py_RETURN_NONE;
@@ -370,6 +382,7 @@
 
 
 /* Class ImageSurface(Surface) -------------------------------------------- */
+#ifdef CAIRO_HAS_IMAGE_SURFACE
 
 static PyObject *
 image_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
@@ -424,8 +437,10 @@
 	PyErr_SetString(PyExc_TypeError, "buffer is not long enough");
 	return NULL;
     }
+    Py_BEGIN_ALLOW_THREADS
     surface = cairo_image_surface_create_for_data (buffer, format, width,
 						   height, stride);
+    Py_END_ALLOW_THREADS
     return PycairoSurface_FromSurface(surface, obj);
 }
 
@@ -453,11 +468,13 @@
 image_surface_create_from_png (PyTypeObject *type, PyObject *file)
 {
     PyObject* reader;
+    cairo_surface_t *is;
 
     if (PyObject_TypeCheck (file, &PyBaseString_Type)) {
-	return PycairoSurface_FromSurface (
-            cairo_image_surface_create_from_png (PyString_AsString(file)),
-            NULL);
+	Py_BEGIN_ALLOW_THREADS
+        is = cairo_image_surface_create_from_png (PyString_AsString(file));
+	Py_END_ALLOW_THREADS
+        return PycairoSurface_FromSurface (is, NULL);
     }
 
     /* file or file-like object argument */
@@ -471,8 +488,10 @@
     }
     Py_DECREF(reader);
 
-    return PycairoSurface_FromSurface (
-        cairo_image_surface_create_from_png_stream (_read_func, file), NULL);
+    Py_BEGIN_ALLOW_THREADS
+    is = cairo_image_surface_create_from_png_stream (_read_func, file);
+    Py_END_ALLOW_THREADS
+    return PycairoSurface_FromSurface (is, NULL);
 }
 #endif /* CAIRO_HAS_PNG_FUNCTIONS */
 
@@ -639,6 +658,7 @@
     0,                                  /* tp_is_gc */
     0,                                  /* tp_bases */
 };
+#endif /* CAIRO_HAS_IMAGE_SURFACE */
 
 
 /* Class PDFSurface(Surface) ---------------------------------------------- */
@@ -650,6 +670,7 @@
 {
     double width_in_points, height_in_points;
     PyObject *file, *writer;
+    cairo_surface_t *sfc;
 
     if (!PyArg_ParseTuple(args, "Odd:PDFSurface.__new__",
 			  &file, &width_in_points, &height_in_points))
@@ -657,10 +678,11 @@
 
     if (PyObject_TypeCheck (file, &PyBaseString_Type)) {
 	/* string (filename) argument */
-	return PycairoSurface_FromSurface (
-                  cairo_pdf_surface_create (PyString_AsString(file),
-                                     width_in_points, height_in_points),
-	       NULL);
+	Py_BEGIN_ALLOW_THREADS
+	sfc = cairo_pdf_surface_create (PyString_AsString(file),
+					width_in_points, height_in_points);
+	Py_END_ALLOW_THREADS
+	    return PycairoSurface_FromSurface (sfc, NULL);
     }
     /* file or file-like object argument */
     writer = PyObject_GetAttrString (file, "write");
@@ -673,10 +695,11 @@
     }
     Py_DECREF(writer);
 
-    return PycairoSurface_FromSurface (
-	       cairo_pdf_surface_create_for_stream (_write_func, file,
-		   width_in_points, height_in_points),
-	   file);
+    Py_BEGIN_ALLOW_THREADS
+    sfc = cairo_pdf_surface_create_for_stream (_write_func, file,
+					       width_in_points, height_in_points);
+    Py_END_ALLOW_THREADS
+    return PycairoSurface_FromSurface (sfc, file);
 }
 
 static PyObject *
@@ -753,6 +776,7 @@
 {
     double width_in_points, height_in_points;
     PyObject *file, *writer;
+    cairo_surface_t *sfc;
 
     if (!PyArg_ParseTuple(args, "Odd:PSSurface.__new__",
 			  &file, &width_in_points, &height_in_points))
@@ -760,11 +784,11 @@
 
     if (PyObject_TypeCheck (file, &PyBaseString_Type)) {
 	/* string (filename) argument */
-	return PycairoSurface_FromSurface (
-                  cairo_ps_surface_create (PyString_AsString(file),
-                                     width_in_points, height_in_points),
-	       NULL);
-
+        Py_BEGIN_ALLOW_THREADS
+	sfc = cairo_ps_surface_create (PyString_AsString(file),
+				 width_in_points, height_in_points);
+        Py_END_ALLOW_THREADS
+	return PycairoSurface_FromSurface (sfc, NULL);
     }
     /* else: file or file-like object argument */
     writer = PyObject_GetAttrString (file, "write");
@@ -777,10 +801,11 @@
     }
     Py_DECREF(writer);
 
-    return PycairoSurface_FromSurface (
-	       cairo_ps_surface_create_for_stream (_write_func, file,
-                   width_in_points, height_in_points),
-	       file);
+    Py_BEGIN_ALLOW_THREADS
+    sfc = cairo_ps_surface_create_for_stream (_write_func, file,
+					width_in_points, height_in_points);
+    Py_END_ALLOW_THREADS
+    return PycairoSurface_FromSurface (sfc, file);
 }
 
 static PyObject *
@@ -943,6 +968,7 @@
 {
     double width_in_points, height_in_points;
     PyObject *file, *writer;
+    cairo_surface_t *sfc; 
 
     if (!PyArg_ParseTuple(args, "Odd:SVGSurface.__new__",
 			  &file, &width_in_points, &height_in_points))
@@ -950,10 +976,11 @@
 
     if (PyObject_TypeCheck (file, &PyBaseString_Type)) {
 	/* string (filename) argument */
-	return PycairoSurface_FromSurface (
-                  cairo_svg_surface_create (PyString_AsString(file),
-                                     width_in_points, height_in_points),
-	       NULL);
+        Py_BEGIN_ALLOW_THREADS
+	sfc = cairo_svg_surface_create (PyString_AsString(file),
+				  width_in_points, height_in_points);
+        Py_END_ALLOW_THREADS
+	return PycairoSurface_FromSurface (sfc, NULL);
     }
     /* else: file or file-like object argument */
     writer = PyObject_GetAttrString (file, "write");
@@ -966,10 +993,11 @@
     }
     Py_DECREF(writer);
 
-    return PycairoSurface_FromSurface (
-	       cairo_svg_surface_create_for_stream (_write_func, file,
-	           width_in_points, height_in_points),
-	       file);
+    Py_BEGIN_ALLOW_THREADS
+    sfc = cairo_svg_surface_create_for_stream (_write_func, file,
+					 width_in_points, height_in_points);
+    Py_END_ALLOW_THREADS
+    return PycairoSurface_FromSurface (sfc, file);
 }
 
 static PyMethodDef svg_surface_methods[] = {

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- cairomodule.c	9 Aug 2008 03:32:20 -0000	1.69
+++ cairomodule.c	24 Nov 2008 15:39:38 -0000	1.70
@@ -2,7 +2,7 @@
  *
  * Pycairo - Python bindings for cairo
  *
- * Copyright © 2003-2005 James Henstridge
+ * Copyright © 2003 James Henstridge, Steven Chaplin
  *
  * This library is free software; you can redistribute it and/or
  * modify it either under the terms of the GNU Lesser General Public
@@ -36,11 +36,11 @@
 #endif
 #include "pycairo-private.h"
 
+/* to read CAIRO_PS_LEVEL_* constants */
 #ifdef CAIRO_HAS_PS_SURFACE
 #  include <cairo-ps.h>
 #endif
 
-
 #define VERSION_MAJOR 1
 #define VERSION_MINOR 6
 #define VERSION_MICRO 5
@@ -104,7 +104,11 @@
     &PycairoScaledFont_Type,   PycairoScaledFont_FromScaledFont,
 
     &PycairoSurface_Type,
+#ifdef CAIRO_HAS_IMAGE_SURFACE
     &PycairoImageSurface_Type,
+#else
+    0,
+#endif
 #ifdef CAIRO_HAS_PDF_SURFACE
     &PycairoPDFSurface_Type,
 #else
@@ -203,9 +207,11 @@
     PycairoSurface_Type.tp_base = &PyBaseObject_Type;
     if (PyType_Ready(&PycairoSurface_Type) < 0)
         return;
+#ifdef CAIRO_HAS_IMAGE_SURFACE
     PycairoImageSurface_Type.tp_base = &PycairoSurface_Type;
     if (PyType_Ready(&PycairoImageSurface_Type) < 0)
         return;
+#endif
 #ifdef CAIRO_HAS_PDF_SURFACE
     PycairoPDFSurface_Type.tp_base = &PycairoSurface_Type;
     if (PyType_Ready(&PycairoPDFSurface_Type) < 0)
@@ -273,9 +279,12 @@
 
     Py_INCREF(&PycairoSurface_Type);
     PyModule_AddObject(m, "Surface", (PyObject *)&PycairoSurface_Type);
+
+#ifdef CAIRO_HAS_IMAGE_SURFACE
     Py_INCREF(&PycairoImageSurface_Type);
     PyModule_AddObject(m, "ImageSurface",
 		       (PyObject *)&PycairoImageSurface_Type);
+#endif
 
 #ifdef CAIRO_HAS_PDF_SURFACE
     Py_INCREF(&PycairoPDFSurface_Type);
@@ -332,6 +341,11 @@
 #else
     PyModule_AddIntConstant(m, "HAS_GLITZ_SURFACE", 0);
 #endif
+#if CAIRO_HAS_IMAGE_SURFACE
+    PyModule_AddIntConstant(m, "HAS_IMAGE_SURFACE", 1);
+#else
+    PyModule_AddIntConstant(m, "HAS_IMAGE_SURFACE", 0);
+#endif
 #if CAIRO_HAS_PDF_SURFACE
     PyModule_AddIntConstant(m, "HAS_PDF_SURFACE", 1);
 #else
@@ -352,6 +366,11 @@
 #else
     PyModule_AddIntConstant(m, "HAS_SVG_SURFACE", 0);
 #endif
+#if CAIRO_HAS_USER_FONT
+    PyModule_AddIntConstant(m, "HAS_USER_FONT", 1);
+#else
+    PyModule_AddIntConstant(m, "HAS_USER_FONT", 0);
+#endif
 #if CAIRO_HAS_QUARTZ_SURFACE
     PyModule_AddIntConstant(m, "HAS_QUARTZ_SURFACE", 1);
 #else

Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- pycairo-font.c	11 Dec 2007 02:56:48 -0000	1.37
+++ pycairo-font.c	24 Nov 2008 15:39:38 -0000	1.38
@@ -2,7 +2,7 @@
  *
  * Pycairo - Python bindings for cairo
  *
- * Copyright © 2003-2006 James Henstridge
+ * Copyright © 2003 James Henstridge, Steven Chaplin
  *
  * This library is free software; you can redistribute it and/or
  * modify it either under the terms of the GNU Lesser General Public
@@ -218,6 +218,14 @@
 }
 
 static PyObject *
+scaled_font_get_scale_matrix (PycairoScaledFont *o)
+{
+    cairo_matrix_t matrix;
+    cairo_scaled_font_get_scale_matrix (o->scaled_font, &matrix);
+    return PycairoMatrix_FromMatrix (&matrix);
+}
+
+static PyObject *
 scaled_font_text_extents (PycairoScaledFont *o, PyObject *obj)
 {
     cairo_text_extents_t extents;
@@ -248,9 +256,11 @@
      * cairo_scaled_font_get_font_options
      * cairo_scaled_font_glyph_extents
      */
-    {"extents",       (PyCFunction)scaled_font_extents,       METH_NOARGS},
-    {"get_font_face", (PyCFunction)scaled_font_get_font_face, METH_NOARGS},
-    {"text_extents",  (PyCFunction)scaled_font_text_extents,  METH_O},
+    {"extents",       (PyCFunction)scaled_font_extents,        METH_NOARGS},
+    {"get_font_face", (PyCFunction)scaled_font_get_font_face,  METH_NOARGS},
+    {"get_scale_matrix", (PyCFunction)scaled_font_get_scale_matrix,
+                                                               METH_VARARGS},
+    {"text_extents",  (PyCFunction)scaled_font_text_extents,   METH_O},
     {NULL, NULL, 0, NULL},
 };
 



More information about the cairo-commit mailing list