[cairo-commit] pycairo/cairo pycairo-context.c, 1.61, 1.62 cairomodule.c, 1.45, 1.46 pycairo-surface.c, 1.51, 1.52

Steve Chaplin commit at pdx.freedesktop.org
Tue Aug 9 03:54:46 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv3144/cairo

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

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- pycairo-context.c	8 Aug 2005 12:16:35 -0000	1.61
+++ pycairo-context.c	9 Aug 2005 10:54:44 -0000	1.62
@@ -291,6 +291,12 @@
 }
 
 static PyObject *
+pycairo_get_antialias (PycairoContext *o)
+{
+    return PyInt_FromLong (cairo_get_antialias (o->ctx));
+}
+
+static PyObject *
 pycairo_get_current_point (PycairoContext *o)
 {
     double x, y;
@@ -655,6 +661,20 @@
 }
 
 static PyObject *
+pycairo_set_antialias (PycairoContext *o, PyObject *args)
+{
+    cairo_antialias_t antialias = CAIRO_ANTIALIAS_DEFAULT;
+
+    if (!PyArg_ParseTuple(args, "|i:Context.set_antialias", &antialias))
+	return NULL;
+
+    cairo_set_antialias (o->ctx, antialias);
+    if (Pycairo_Check_Status (cairo_status (o->ctx)))
+	return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
 pycairo_set_dash (PycairoContext *o, PyObject *args)
 {
     double *dashes, offset = 0;
@@ -1095,6 +1115,7 @@
     {"fill_extents",    (PyCFunction)pycairo_fill_extents,   METH_NOARGS},
     {"fill_preserve",   (PyCFunction)pycairo_fill_preserve,  METH_NOARGS},
     {"font_extents",    (PyCFunction)pycairo_font_extents,   METH_NOARGS},
+    {"get_antialias",   (PyCFunction)pycairo_get_antialias,  METH_NOARGS},
     {"get_fill_rule",   (PyCFunction)pycairo_get_fill_rule,  METH_NOARGS},
     {"get_font_face",   (PyCFunction)pycairo_get_font_face,  METH_NOARGS},
     {"get_font_matrix", (PyCFunction)pycairo_get_font_matrix,METH_NOARGS},
@@ -1131,6 +1152,7 @@
     {"save",            (PyCFunction)pycairo_save,           METH_NOARGS},
     {"scale",           (PyCFunction)pycairo_scale,          METH_VARARGS},
     {"select_font_face",(PyCFunction)pycairo_select_font_face,METH_VARARGS},
+    {"set_antialias",   (PyCFunction)pycairo_set_antialias,  METH_VARARGS},
     {"set_dash",        (PyCFunction)pycairo_set_dash,       METH_VARARGS},
     {"set_fill_rule",   (PyCFunction)pycairo_set_fill_rule,  METH_VARARGS},
     {"set_font_face",   (PyCFunction)pycairo_set_font_face,  METH_O},

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- cairomodule.c	1 Aug 2005 15:24:38 -0000	1.45
+++ cairomodule.c	9 Aug 2005 10:54:44 -0000	1.46
@@ -1,4 +1,4 @@
-/* -*- mode: C; c-basic-offset: 4 -*- 
+/* -*- mode: C; c-basic-offset: 4 -*-
  *
  * Pycairo - Python bindings for cairo
  *
@@ -162,7 +162,7 @@
     Py_INCREF(&PycairoSurface_Type);
     PyModule_AddObject(m, "Surface", (PyObject *)&PycairoSurface_Type);
     Py_INCREF(&PycairoImageSurface_Type);
-    PyModule_AddObject(m, "ImageSurface", 
+    PyModule_AddObject(m, "ImageSurface",
 		       (PyObject *)&PycairoImageSurface_Type);
 
 #ifdef CAIRO_HAS_PDF_SURFACE
@@ -177,7 +177,7 @@
 
 #ifdef CAIRO_HAS_WIN32_SURFACE
     Py_INCREF(&PycairoWin32Surface_Type);
-    PyModule_AddObject(m, "Win32Surface", 
+    PyModule_AddObject(m, "Win32Surface",
 		       (PyObject *)&PycairoWin32Surface_Type);
 #endif
 
@@ -251,44 +251,22 @@
 #endif
 
 #define CONSTANT(x) PyModule_AddIntConstant(m, #x, CAIRO_##x)
-    CONSTANT(FORMAT_ARGB32);
-    CONSTANT(FORMAT_RGB24);
-    CONSTANT(FORMAT_A8);
-    CONSTANT(FORMAT_A1);
+    CONSTANT(ANTIALIAS_DEFAULT);
+    CONSTANT(ANTIALIAS_NONE);
+    CONSTANT(ANTIALIAS_GRAY);
+    CONSTANT(ANTIALIAS_SUBPIXEL);
 
     CONSTANT(CONTENT_COLOR);
     CONSTANT(CONTENT_ALPHA);
     CONSTANT(CONTENT_COLOR_ALPHA);
 
-    CONSTANT(OPERATOR_CLEAR);
-
-    CONSTANT(OPERATOR_SOURCE);
-    CONSTANT(OPERATOR_OVER);
-    CONSTANT(OPERATOR_IN);
-    CONSTANT(OPERATOR_OUT);
-    CONSTANT(OPERATOR_ATOP);
-
-    CONSTANT(OPERATOR_DEST);
-    CONSTANT(OPERATOR_DEST_OVER);
-    CONSTANT(OPERATOR_DEST_IN);
-    CONSTANT(OPERATOR_DEST_OUT);
-    CONSTANT(OPERATOR_DEST_ATOP);
-
-    CONSTANT(OPERATOR_XOR);
-    CONSTANT(OPERATOR_ADD);
-    CONSTANT(OPERATOR_SATURATE);
+    CONSTANT(EXTEND_NONE);
+    CONSTANT(EXTEND_REPEAT);
+    CONSTANT(EXTEND_REFLECT);
 
     CONSTANT(FILL_RULE_WINDING);
     CONSTANT(FILL_RULE_EVEN_ODD);
 
-    CONSTANT(LINE_CAP_BUTT);
-    CONSTANT(LINE_CAP_ROUND);
-    CONSTANT(LINE_CAP_SQUARE);
-
-    CONSTANT(LINE_JOIN_MITER);
-    CONSTANT(LINE_JOIN_ROUND);
-    CONSTANT(LINE_JOIN_BEVEL);
-
     CONSTANT(FILTER_FAST);
     CONSTANT(FILTER_GOOD);
     CONSTANT(FILTER_BEST);
@@ -303,9 +281,36 @@
     CONSTANT(FONT_SLANT_ITALIC);
     CONSTANT(FONT_SLANT_OBLIQUE);
 
-    CONSTANT(EXTEND_NONE);
-    CONSTANT(EXTEND_REPEAT);
-    CONSTANT(EXTEND_REFLECT);
+    CONSTANT(FORMAT_ARGB32);
+    CONSTANT(FORMAT_RGB24);
+    CONSTANT(FORMAT_A8);
+    CONSTANT(FORMAT_A1);
+
+    CONSTANT(LINE_CAP_BUTT);
+    CONSTANT(LINE_CAP_ROUND);
+    CONSTANT(LINE_CAP_SQUARE);
+
+    CONSTANT(LINE_JOIN_MITER);
+    CONSTANT(LINE_JOIN_ROUND);
+    CONSTANT(LINE_JOIN_BEVEL);
+
+    CONSTANT(OPERATOR_CLEAR);
+
+    CONSTANT(OPERATOR_SOURCE);
+    CONSTANT(OPERATOR_OVER);
+    CONSTANT(OPERATOR_IN);
+    CONSTANT(OPERATOR_OUT);
+    CONSTANT(OPERATOR_ATOP);
+
+    CONSTANT(OPERATOR_DEST);
+    CONSTANT(OPERATOR_DEST_OVER);
+    CONSTANT(OPERATOR_DEST_IN);
+    CONSTANT(OPERATOR_DEST_OUT);
+    CONSTANT(OPERATOR_DEST_ATOP);
+
+    CONSTANT(OPERATOR_XOR);
+    CONSTANT(OPERATOR_ADD);
+    CONSTANT(OPERATOR_SATURATE);
 
     CONSTANT(PATH_MOVE_TO);
     CONSTANT(PATH_LINE_TO);

Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- pycairo-surface.c	1 Aug 2005 15:24:38 -0000	1.51
+++ pycairo-surface.c	9 Aug 2005 10:54:44 -0000	1.52
@@ -1,4 +1,4 @@
-/* -*- mode: C; c-basic-offset: 4 -*- 
+/* -*- mode: C; c-basic-offset: 4 -*-
  *
  * Pycairo - Python bindings for cairo
  *
@@ -53,12 +53,12 @@
  *        meaning a base cairo.Surface type, or it can be a subclass of
  *        cairo.Surface.
  * base - the base object used to create the context, or NULL.
- *        it is referenced to keep it alive while the cairo_surface_t is 
+ *        it is referenced to keep it alive while the cairo_surface_t is
  *        being used
  * Return value: New reference or NULL on failure
  */
 PyObject *
-PycairoSurface_FromSurface (cairo_surface_t *surface, PyTypeObject *type, 
+PycairoSurface_FromSurface (cairo_surface_t *surface, PyTypeObject *type,
 			    PyObject *base)
 {
     PyObject *o;
@@ -120,7 +120,7 @@
 			   &content, &width, &height))
 	return NULL;
 
-    surface = cairo_surface_create_similar (o->surface, content, 
+    surface = cairo_surface_create_similar (o->surface, content,
 					    width, height);
     /* bug #2765 - "How do we identify surface types?"
      * should pass surface type as arg2
@@ -140,6 +140,16 @@
 }
 
 static PyObject *
+surface_flush (PycairoSurface *o)
+{
+    cairo_surface_flush (o->surface);
+
+    if (Pycairo_Check_Status (cairo_surface_status(o->surface)))
+	return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
 surface_get_font_options (PycairoSurface *o)
 {
     cairo_font_options_t *options = cairo_font_options_create();
@@ -150,11 +160,29 @@
 }
 
 static PyObject *
+surface_mark_dirty (PycairoSurface *o, PyObject *args, PyObject *kwds)
+{
+    static char *kwlist[] = {"x", "y", "width", "height", NULL};
+    int x = 0, y = 0, width = -1, height = -1;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds,
+				     "|iiii:Surface.mark_dirty", kwlist,
+				     &x, &y, &width, &height))
+	return NULL;
+
+    cairo_surface_mark_dirty_rectangle (o->surface, x, y, width, height);
+
+    if (Pycairo_Check_Status (cairo_surface_status(o->surface)))
+	return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
 surface_set_device_offset (PycairoSurface *o, PyObject *args)
 {
     double x_offset, y_offset;
 
-    if (!PyArg_ParseTuple (args, "dd:Surface.set_device_offset", 
+    if (!PyArg_ParseTuple (args, "dd:Surface.set_device_offset",
 			   &x_offset, &y_offset))
 	return NULL;
 
@@ -189,8 +217,10 @@
      */
     {"create_similar", (PyCFunction)surface_create_similar,    METH_VARARGS },
     {"finish",         (PyCFunction)surface_finish,            METH_NOARGS },
+    {"flush",          (PyCFunction)surface_flush,             METH_NOARGS },
     {"get_font_options",(PyCFunction)surface_get_font_options, METH_NOARGS },
-    {"set_device_offset",(PyCFunction)surface_set_device_offset, 
+    {"mark_dirty",     (PyCFunction)surface_mark_dirty,        METH_KEYWORDS },
+    {"set_device_offset",(PyCFunction)surface_set_device_offset,
                                                                 METH_VARARGS },
 #ifdef CAIRO_HAS_PNG_FUNCTIONS
     {"write_to_png",   (PyCFunction)surface_write_to_png,      METH_VARARGS },
@@ -324,12 +354,12 @@
 	return NULL;
     }
     surface = cairo_image_surface_create_for_data(
-		                          (unsigned char *) array->data, 
+		                          (unsigned char *) array->data,
 					  format,
 					  array->dimensions[1],
 					  array->dimensions[0],
 					  array->strides[0]);
-    return PycairoSurface_FromSurface(surface, &PycairoImageSurface_Type, 
+    return PycairoSurface_FromSurface(surface, &PycairoImageSurface_Type,
 				      (PyObject *)array);
 }
 #endif /* HAVE_NUMPY */
@@ -379,7 +409,7 @@
 
     surface = cairo_image_surface_create_for_data
 	((unsigned char *)data, format, width, height, stride);
-    return PycairoSurface_FromSurface(surface, &PycairoImageSurface_Type, 
+    return PycairoSurface_FromSurface(surface, &PycairoImageSurface_Type,
 				      NULL);
     /* FIXME: get surface to hold a reference to buffer */
 }
@@ -387,7 +417,7 @@
 
 
 #ifdef CAIRO_HAS_PNG_FUNCTIONS
-static cairo_status_t 
+static cairo_status_t
 pycairo_read_func (void *closure, unsigned char *data, unsigned int length)
 {
     if (fread (data, 1, (size_t) length, (FILE *)closure) != length)
@@ -413,18 +443,18 @@
 	fp = PyFile_AsFile(o);
 
     } else {
-	PyErr_SetString(PyExc_TypeError, 
+	PyErr_SetString(PyExc_TypeError,
 			"ImageSurface.create_from_png takes one argument "
 			"which must be a filename (str) or file object");
 	return NULL;
     }
 
-    surface = cairo_image_surface_create_from_png_stream (pycairo_read_func, 
+    surface = cairo_image_surface_create_from_png_stream (pycairo_read_func,
 							  fp);
     if (PyObject_TypeCheck (o, &PyBaseString_Type))
 	fclose (fp);
 
-    return PycairoSurface_FromSurface (surface, &PycairoImageSurface_Type, 
+    return PycairoSurface_FromSurface (surface, &PycairoImageSurface_Type,
 				       NULL);
 }
 #endif /* CAIRO_HAS_PNG_FUNCTIONS */
@@ -444,15 +474,15 @@
 
 static PyMethodDef image_surface_methods[] = {
 #ifdef HAVE_NUMPY
-    {"create_for_array",(PyCFunction)image_surface_create_for_array, 
+    {"create_for_array",(PyCFunction)image_surface_create_for_array,
                                                    METH_VARARGS | METH_CLASS },
 #endif
 #if 0
-    {"create_for_data",(PyCFunction)image_surface_create_for_data, 
+    {"create_for_data",(PyCFunction)image_surface_create_for_data,
                                                    METH_VARARGS | METH_CLASS },
 #endif
 #ifdef CAIRO_HAS_PNG_FUNCTIONS
-    {"create_from_png", (PyCFunction)image_surface_create_from_png, 
+    {"create_from_png", (PyCFunction)image_surface_create_from_png,
                                                    METH_O | METH_CLASS },
 #endif
     {"get_height",    (PyCFunction)image_surface_get_height,      METH_NOARGS},
@@ -525,7 +555,7 @@
 
     o = type->tp_alloc(type, 0);
     if (o) {
-	surface = cairo_pdf_surface_create (filename, width_in_points, 
+	surface = cairo_pdf_surface_create (filename, width_in_points,
 					    height_in_points);
 	if (Pycairo_Check_Status (cairo_surface_status (surface))) {
 	    cairo_surface_destroy (surface);
@@ -618,7 +648,7 @@
 
     o = type->tp_alloc(type, 0);
     if (o) {
-	surface = cairo_ps_surface_create (filename, width_in_points, 
+	surface = cairo_ps_surface_create (filename, width_in_points,
 					   height_in_points);
 	if (Pycairo_Check_Status (cairo_surface_status (surface))) {
 	    cairo_surface_destroy (surface);
@@ -776,7 +806,7 @@
 #ifdef HAVE_NUMPY
 /* load the Numeric Python module
  * Return 1 if Numeric is available,
- *        0 and set exception if it is not. 
+ *        0 and set exception if it is not.
  *
  * copied from pygtk
  */




More information about the cairo-commit mailing list