[cairo-commit] pycairo/cairo pycairo-private.h, 1.45, 1.46 pycairo.h, 1.47, 1.48 pycairo-pattern.c, 1.40, 1.41 pycairo-context.c, 1.88, 1.89 pycairo-surface.c, 1.92, 1.93
Steve Chaplin
commit at pdx.freedesktop.org
Wed Dec 10 00:19:01 PST 2008
Committed by: stevech1097
Update of /cvs/cairo/pycairo/cairo
In directory kemper:/tmp/cvs-serv17225/cairo
Modified Files:
pycairo-private.h pycairo.h pycairo-pattern.c
pycairo-context.c pycairo-surface.c
Log Message:
'SC'
Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- pycairo-private.h 12 May 2008 12:06:37 -0000 1.45
+++ pycairo-private.h 10 Dec 2008 08:18:58 -0000 1.46
@@ -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,7 +70,8 @@
extern PyTypeObject PycairoGradient_Type;
extern PyTypeObject PycairoLinearGradient_Type;
extern PyTypeObject PycairoRadialGradient_Type;
-PyObject *PycairoPattern_FromPattern (cairo_pattern_t *pattern);
+PyObject *PycairoPattern_FromPattern (cairo_pattern_t *pattern,
+ PyObject *base);
extern PyTypeObject PycairoScaledFont_Type;
PyObject *PycairoScaledFont_FromScaledFont (cairo_scaled_font_t *scaled_font);
Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- pycairo.h 1 May 2006 02:20:15 -0000 1.47
+++ pycairo.h 10 Dec 2008 08:18:58 -0000 1.48
@@ -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
@@ -65,6 +65,7 @@
typedef struct {
PyObject_HEAD
cairo_pattern_t *pattern;
+ PyObject *base; /* base object used to create pattern, or NULL */
} PycairoPattern;
#define PycairoSolidPattern PycairoPattern
Index: pycairo-pattern.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-pattern.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- pycairo-pattern.c 1 Sep 2008 13:56:24 -0000 1.40
+++ pycairo-pattern.c 10 Dec 2008 08:18:58 -0000 1.41
@@ -46,12 +46,16 @@
* PycairoLinearGradient, or
* PycairoRadialGradient from a cairo_pattern_t.
* pattern - a cairo_pattern_t to 'wrap' into a Python object.
- * it is unreferenced if the PycairoPattern creation fails, or if the
- * pattern has an error status.
+ * It is unreferenced if the PycairoPattern creation fails, or if the
+ * pattern has an error status.
+ * base - the base object used to create the pattern, or NULL.
+ * It is referenced to keep it alive while the cairo_pattern_t is being used.
+ * For PycairoSurfacePattern base should be the PycairoSurface, for other
+ # patterns it should be NULL.
* Return value: New reference or NULL on failure
*/
PyObject *
-PycairoPattern_FromPattern (cairo_pattern_t *pattern)
+PycairoPattern_FromPattern (cairo_pattern_t *pattern, PyObject *base)
{
PyTypeObject *type = NULL;
PyObject *o;
@@ -82,10 +86,13 @@
}
o = type->tp_alloc(type, 0);
- if (o == NULL)
+ if (o == NULL) {
cairo_pattern_destroy (pattern);
- else
+ } else {
((PycairoPattern *)o)->pattern = pattern;
+ Py_XINCREF(base);
+ ((PycairoPattern *)o)->base = base;
+ }
return o;
}
@@ -96,6 +103,8 @@
cairo_pattern_destroy (o->pattern);
o->pattern = NULL;
}
+ Py_CLEAR(o->base);
+
o->ob_type->tp_free((PyObject *)o);
}
@@ -196,7 +205,8 @@
double r, g, b, a = 1.0;
if (!PyArg_ParseTuple (args, "ddd|d:SolidPattern.__new__", &r, &g, &b, &a))
return NULL;
- return PycairoPattern_FromPattern (cairo_pattern_create_rgba (r, g, b, a));
+ return PycairoPattern_FromPattern (cairo_pattern_create_rgba (r, g, b, a),
+ NULL);
}
static PyObject *
@@ -263,11 +273,12 @@
surface_pattern_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PycairoSurface *s;
+ PyObject *o;
if (!PyArg_ParseTuple (args, "O!:SurfacePattern.__new__",
&PycairoSurface_Type, &s))
return NULL;
return PycairoPattern_FromPattern (
- cairo_pattern_create_for_surface (s->surface));
+ cairo_pattern_create_for_surface (s->surface), s);
}
static PyObject *
@@ -467,7 +478,7 @@
&x0, &y0, &x1, &y1))
return NULL;
return PycairoPattern_FromPattern (
- cairo_pattern_create_linear (x0, y0, x1, y1));
+ cairo_pattern_create_linear (x0, y0, x1, y1), NULL);
}
static PyObject *
@@ -539,7 +550,8 @@
&cx0, &cy0, &radius0, &cx1, &cy1, &radius1))
return NULL;
return PycairoPattern_FromPattern (
- cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1));
+ cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1),
+ NULL);
}
static PyObject *
Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- pycairo-context.c 24 Nov 2008 15:39:37 -0000 1.88
+++ pycairo-context.c 10 Dec 2008 08:18:58 -0000 1.89
@@ -482,7 +482,7 @@
pycairo_get_source (PycairoContext *o)
{
return PycairoPattern_FromPattern (
- cairo_pattern_reference (cairo_get_source (o->ctx)));
+ cairo_pattern_reference (cairo_get_source (o->ctx)), NULL);
}
static PyObject *
@@ -751,7 +751,7 @@
static PyObject *
pycairo_pop_group (PycairoContext *o)
{
- return PycairoPattern_FromPattern (cairo_pop_group (o->ctx));
+ return PycairoPattern_FromPattern (cairo_pop_group (o->ctx), NULL);
}
static PyObject *
Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- pycairo-surface.c 10 Dec 2008 06:51:30 -0000 1.92
+++ pycairo-surface.c 10 Dec 2008 08:18:58 -0000 1.93
@@ -49,11 +49,10 @@
* PycairoWin32Surface, or
* PycairoXlibSurface from a cairo_surface_t.
* surface - a cairo_surface_t to 'wrap' into a Python object.
- * it is unreferenced if the PycairoSurface creation fails, or if
- * the cairo_surface_t has an error status
- * base - the base object used to create the context, or NULL.
- * it is referenced to keep it alive while the cairo_surface_t is
- * being used
+ * It is unreferenced if the PycairoSurface creation fails, or if the
+ * cairo_surface_t has an error status.
+ * base - the base object used to create the surface, or NULL.
+ * It is referenced to keep it alive while the cairo_surface_t is being used.
* Return value: New reference or NULL on failure
*/
PyObject *
More information about the cairo-commit
mailing list