Merge lp:~ahmed-a-ammar/pigment-python/pigment-python-0.3-expose-set_from_system_buffer into lp:pigment-python/0.3

Proposed by Ahmed Ammar
Status: Needs review
Proposed branch: lp:~ahmed-a-ammar/pigment-python/pigment-python-0.3-expose-set_from_system_buffer
Merge into: lp:pigment-python/0.3
Diff against target: 85 lines (+64/-0)
2 files modified
pgm/pgm.defs (+13/-0)
pgm/pgmimage.override (+51/-0)
To merge this branch: bzr merge lp:~ahmed-a-ammar/pigment-python/pigment-python-0.3-expose-set_from_system_buffer
Reviewer Review Type Date Requested Status
Loïc Molinari Pending
Review via email: mp+28972@code.launchpad.net
To post a comment you must log in.
154. By Ahmed Ammar

Fixed CPU consumption problem. This really doesn't belong in .override
anyway. TODO.

Unmerged revisions

154. By Ahmed Ammar

Fixed CPU consumption problem. This really doesn't belong in .override
anyway. TODO.

153. By Ahmed Ammar

Expose pgm_image_set_from_system_buffer to python as
PgmImage.set_from_system_buffer. Using g_timeout_add to keep image
updated.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'pgm/pgm.defs'
2--- pgm/pgm.defs 2009-04-27 14:50:38 +0000
3+++ pgm/pgm.defs 2010-07-09 21:41:41 +0000
4@@ -1705,6 +1705,19 @@
5 )
6 )
7
8+(define-method set_from_system_buffer
9+ (unblock-threads #t)
10+ (of-object "PgmImage")
11+ (c-name "pgm_image_set_from_system_buffer")
12+ (return-type "PgmError")
13+ (parameters
14+ '("PgmImagePixelFormat" "format")
15+ '("guint" "width")
16+ '("guint" "height")
17+ '("gconstpointer" "system_buffer")
18+ )
19+)
20+
21 (define-method set_from_image
22 (unblock-threads #t)
23 (of-object "PgmImage")
24
25=== modified file 'pgm/pgmimage.override'
26--- pgm/pgmimage.override 2008-09-17 16:25:11 +0000
27+++ pgm/pgmimage.override 2010-07-09 21:41:41 +0000
28@@ -1128,6 +1128,57 @@
29 }
30
31 %%
32+override pgm_image_set_from_system_buffer kwargs
33+static gboolean
34+update_image (gpointer data)
35+{
36+ PgmDrawable *img;
37+
38+ img = (PgmDrawable*) data;
39+
40+ pgm_image_system_buffer_lock (PGM_IMAGE (img));
41+ pgm_image_system_buffer_unlock (PGM_IMAGE (img));
42+
43+ return TRUE;
44+}
45+
46+static PyObject *
47+_wrap_pgm_image_set_from_system_buffer (PyGObject *self,
48+ PyObject *args,
49+ PyObject *kwargs)
50+{
51+ static char *kwlist[] =
52+ { "format", "width", "height", "system_buffer", NULL };
53+ unsigned int py_format, py_width, py_height;
54+ unsigned long long py_system_buffer;
55+ gint ret;
56+ gconstpointer system_buffer;
57+
58+ system_buffer = g_slice_new(unsigned long);
59+
60+ if (!PyArg_ParseTupleAndKeywords (args, kwargs,
61+ "IIIK:PgmImage.set_image_from_system_buffer",
62+ kwlist, &py_format, &py_width,
63+ &py_height, &py_system_buffer))
64+ return NULL;
65+
66+ pyg_begin_allow_threads;
67+
68+ *(unsigned long*)system_buffer = py_system_buffer;
69+
70+ ret = pgm_image_set_from_system_buffer (PGM_IMAGE (self->obj),
71+ py_format, py_width, py_height,
72+ system_buffer);
73+
74+ g_timeout_add (100, update_image, PGM_IMAGE (self->obj));
75+
76+ pyg_end_allow_threads;
77+
78+ return pyg_enum_from_gtype (PGM_TYPE_ERROR, ret);
79+}
80+
81+
82+%%
83 override pgm_image_set_from_gst_buffer kwargs
84 static PyObject *
85 _wrap_pgm_image_set_from_gst_buffer (PyGObject *self,

Subscribers

People subscribed via source and target branches

to all changes: