This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via d05bcd076fd9c8539d48030a2153444fb7602cb5 (commit) via 1a247c93429de2f36141c09e0927f31ac7594f41 (commit) via 1f508b76b65df78df2c88ff026f4f42ec0fb8dd7 (commit) from 5b9a67f154c6251afb1203702830b837297a1030 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/d05bcd076fd9c8539d48030a2153444fb7602...
commit d05bcd076fd9c8539d48030a2153444fb7602cb5 Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 7 12:03:08 2013 +0100
doc: Add a better favicon and fix <title>
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf index be8e2dd..1191a13 100644 --- a/doc/asciidoc.conf +++ b/doc/asciidoc.conf @@ -12,8 +12,7 @@ icons <meta name="description" content="{description}" /> <meta name="keywords" content="{keywords}" /> <link rel="icon" type="image/png" href="favicon.png"> -<title>{title}</title> -{title%}<title>{doctitle=}</title> +<title>GFXprim</title> <link rel="stylesheet" href="{stylesdir=.}/{theme=asciidoc}.css" type="text/css" /> {doctype-manpage}<link rel="stylesheet" href="{stylesdir=.}/{theme=asciidoc}-manpage.css" type="text/css" /> ifdef::quirks[] diff --git a/doc/favicon.png b/doc/favicon.png index e35dc42..39e3e53 100644 Binary files a/doc/favicon.png and b/doc/favicon.png differ
http://repo.or.cz/w/gfxprim.git/commit/1a247c93429de2f36141c09e0927f31ac7594...
commit 1a247c93429de2f36141c09e0927f31ac7594f41 Author: Cyril Hrubis metan@ucw.cz Date: Sun Dec 1 23:53:34 2013 +0100
pywrap: Add swig typemap for GP_ProgressCallback
* Add typemap for GP_ProgressCallback - now a python function (or a touple of arguments) is converted to GP_ProgressCallback proxy transparently
* Add python progress callback documentation
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/py_simple/progress_callback.py b/demos/py_simple/progress_callback.py index b4b0b3e..17b1570 100755 --- a/demos/py_simple/progress_callback.py +++ b/demos/py_simple/progress_callback.py @@ -6,8 +6,13 @@ import gfxprim.core as core import gfxprim.loaders as loaders import gfxprim.filters as filters
-def progress_callback(callback): - sys.stdout.write("rLoading %3.2f%%" % callback) +def progress_callback1(perc): + sys.stdout.write("rLoading %3.2f%%" % perc) + sys.stdout.flush() + return 0 + +def progress_callback2(perc, args): + sys.stdout.write("r%s %3.2f%%" % (args[1], perc)) sys.stdout.flush() return 0
@@ -16,16 +21,15 @@ def main(): print("Takes an image as an argument") sys.exit(1)
- callback = core.c_core.GP_ProgressCallback(progress_callback) - try: - img = loaders.Load(sys.argv[1], callback) + img = loaders.Load(sys.argv[1], progress_callback1) print('') except OSError as detail: print("Failed to load image '%s': %s" % (sys.argv[1], detail)) exit(1)
try: + callback = (progress_callback2, "Gaussian Blur") img = img.filters.GaussianBlurAlloc(50, 50, callback) print('') except OSError: diff --git a/doc/core_python.txt b/doc/core_python.txt index 033846d..6e48824 100644 --- a/doc/core_python.txt +++ b/doc/core_python.txt @@ -135,6 +135,20 @@ import gfxprim.core as core
The PixelTypes array stores all supported pixel types
+[[Progress_Callback]] +Progress Callback +~~~~~~~~~~~~~~~~~ + +Progress callback is a last parameter of link:loaders_python.html[loaders] and +link:filters_python.html[filters]. It can be either a python function or a +touple with a function at the first position. + +Progress callback must return an integer number. Returning non-zero will abort +the operation and the function, called with the callback as a parameter, will +return 'OSError' with errno set to 'ECANCELED'. + +TIP: See link:example_py_progress_callback.html[callback example]. + Debug Functions ~~~~~~~~~~~~~~~
diff --git a/doc/example_py_progress_callback.txt b/doc/example_py_progress_callback.txt new file mode 100644 index 0000000..4826759 --- /dev/null +++ b/doc/example_py_progress_callback.txt @@ -0,0 +1,9 @@ +Progress Callback +----------------- +A very simple program that shows +link:core_python.html#Progress_Callback[progress callback] usage. + +[source,python] +------------------------------------------------------------------ +include::../demos/py_simple/progress_callback.py[] +------------------------------------------------------------------ diff --git a/doc/filters_python.txt b/doc/filters_python.txt index a1d260a..19d50cf 100644 --- a/doc/filters_python.txt +++ b/doc/filters_python.txt @@ -9,7 +9,8 @@ from submodule as +img.filters.Foo(..)+. Note that in the second case the image is passed automatically as a first parameter.
If filter has been aborted from callback 'OSError' with 'errno' set to -'ECANCELED' is raised. +'ECANCELED' is raised, see progress callback +link:core_python.html#Progress_Callback[documentation] for more information.
Point Filters ~~~~~~~~~~~~~ diff --git a/doc/loaders_python.txt b/doc/loaders_python.txt index 00c5cef..136b533 100644 --- a/doc/loaders_python.txt +++ b/doc/loaders_python.txt @@ -39,8 +39,9 @@ format.
May raise 'OSError' with errno set to 'EIO' when file is damaged.
-May raise 'OSError' with errno set to 'ECANCELED' when action was interrupted -by callback. +May raise 'OSError' with errno set to 'ECANCELED' when action was aborted from +callback. See progress callback +link:core_python.html#Progress_Callback[documentation] for more.
[source,python] diff --git a/pylib/gfxprim/common.i b/pylib/gfxprim/common.i index 47ae8f0..462e937 100644 --- a/pylib/gfxprim/common.i +++ b/pylib/gfxprim/common.i @@ -11,12 +11,100 @@
%nodefaultctor;
+ /* - * All progress callbacks have default NULL value + * Python callback proxy. Calls a python function passed via self->priv */ +%{ +#include <core/GP_ProgressCallback.h> +#include <core/GP_Debug.h> + +struct gp_proxy_params { + PyObject *callback; + PyObject *args; +}; + +int gp_proxy_callback(GP_ProgressCallback *self) +{ + struct gp_proxy_params *params = self->priv; + PyObject *res, *args; + int ret; + + GP_DEBUG(2, "[wrapper] Proxy Callback called"); + + if (params->args) + args = Py_BuildValue("(f, O)", self->percentage, params->args); + else + args = Py_BuildValue("(f)", self->percentage); + + res = PyEval_CallObject(params->callback, args); + + /* Parse Error, Interruption, etc. */ + if (res == NULL) { + PyErr_Print(); + GP_WARN("Error while calling callback, aborting"); + return 1; + } + + if (PyInt_Check(res)) { + ret = PyInt_AsLong(res); + } else { + GP_WARN("Wrong type returned from callback, aborting"); + return 1; + } + + Py_DECREF(res); + Py_DECREF(args); + + return ret; +} +%} + +/* + * Progress Callback typemap, package python function into proxy callback structure + * and passes it to the C function. + * + * The python callback object can either be a function or a tuple with a function + * as a first parameter + */ +%typemap(in) GP_ProgressCallback *callback (GP_ProgressCallback callback_proxy, + struct gp_proxy_params proxy_params) +{ + if (PyTuple_Check($input) && PyTuple_GET_SIZE($input) > 0) { + if (!PyCallable_Check(PyTuple_GetItem($input, 0))) { + PyErr_SetString(PyExc_TypeError, + "first arg in tuple must be callable"); + return NULL; + } + proxy_params.callback = PyTuple_GetItem($input, 0); + proxy_params.args = $input; + + } else { + if (!PyCallable_Check($input)) { + PyErr_SetString(PyExc_TypeError, + "parameter must be callable"); + return NULL; + } + + proxy_params.callback = $input; + proxy_params.args = NULL; + } + + if ($input) { + callback_proxy.callback = gp_proxy_callback; + callback_proxy.priv = &proxy_params; + $1 = &callback_proxy; + } else { + $1 = NULL; + } +} + +/* + * All progress callbacks have default NULL value %typemap(default) GP_ProgressCallback *callback { $1 = NULL; } + */
/* * Error handling declarations diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i index 8f578d2..88f9450 100644 --- a/pylib/gfxprim/core/core.i +++ b/pylib/gfxprim/core/core.i @@ -28,78 +28,6 @@ %include "GP_Debug.h"
/* - * Callback proxy, calls the python callback from C source - */ -%{ -static int GP_ProgressCallbackProxy(GP_ProgressCallback *self) -{ - PyObject *obj = self->priv; - PyObject *res, *args; - int ret; - - GP_DEBUG(2, "[wrapper] Proxy Callback called"); - - args = Py_BuildValue("(f)", self->percentage); - - res = PyEval_CallObject(obj, args); - - /* Parse Error, Interruption, etc. */ - if (res == NULL) { - GP_WARN("Error while calling callback, aborting"); - return 1; - } - - if (PyInt_Check(res)) { - ret = PyInt_AsLong(res); - } else { - GP_WARN("Wrong type returned from callback, aborting"); - return 1; - } - - Py_DECREF(res); - - return ret; -} -%} - -%ignore GP_ProgressCallbackReport; -%ignore GP_ProgressCallbackDone; -%include "GP_ProgressCallback.h" - -/* - * Progress callback constructor, desctructor and proxy function. - */ -%extend GP_ProgressCallback { - ~GP_ProgressCallback() { - GP_DEBUG(2, "[wrapper] freeing Proxy Callback"); - free($self); - Py_XDECREF($self->priv); - } - GP_ProgressCallback(PyObject* obj) { - GP_ProgressCallback *res; - - if (!PyCallable_Check(obj)) { - GP_WARN("Callback must be callable python object"); - return NULL; - } - - Py_XINCREF(obj); - - res = malloc(sizeof(GP_ProgressCallback)); - - if (res == NULL) - return NULL; - - res->priv = obj; - res->callback = GP_ProgressCallbackProxy; - - GP_DEBUG(2, "[wrapper] creating Proxy Callback"); - - return res; - } -}; - -/* * Color and pixel types */
http://repo.or.cz/w/gfxprim.git/commit/1f508b76b65df78df2c88ff026f4f42ec0fb8...
commit 1f508b76b65df78df2c88ff026f4f42ec0fb8dd7 Author: Cyril Hrubis metan@ucw.cz Date: Sun Dec 1 23:52:05 2013 +0100
doc: Remove generated file examples.txt from index
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/examples.txt b/doc/examples.txt deleted file mode 100644 index d96b7f8..0000000 --- a/doc/examples.txt +++ /dev/null @@ -1,38 +0,0 @@ -List of examples ----------------- -Following pages contains a list of all code examples, the source -files could be found and are compiled in the +demos/c_simple/+ and -+demos/py_simple+ directories in the source tree. - -.List C examples -[grid="rows"] -[options="autowidth,header",cols="<,<m"] -|=========================== -| Example | Source filename(s) -| link:example_SDL_glue.html[SDL Glue] | SDL_glue.c -| link:example_backend.html[Graphics Backend] | backend_example.c -| link:example_backend_timers.html[Backend Timers] | backend_timers_example.c -| link:example_debug_handler.html[Custom Debug Message Handler] | debug_handler.c -| link:example_fonts.html[Font and Text rendering] | fonttest.c -fileview.c -| link:example_gaussian_noise.html[Gaussian Additive Noise Filter] | gaussian_noise.c -| link:example_input.html[Input Events Handling] | input_example.c -| link:example_loader_registration.html[Image Loader Registration] | loaders_register.c -| link:example_loaders_progress_callback.html[Loaders with Progress Callback] | loaders.c -| link:example_v4l2.html[Grabbers (v4l2) Examples] | v4l2_grab.c -v4l2_show.c -| link:example_x11_windows.html[X11 Backend with multiple windows] | x11_windows.c -|=========================== -.List Python examples -[grid="rows"] -[options="autowidth,header",cols="<,<m"] -|=========================== -| Example | Source filename(s) -| link:example_py_backends.html[Backend Init] | backends.py -| link:example_py_blur.html[Gaussian Blur Filter] | blur.py -| link:example_py_convolution.html[Box Blur Convolution] | convolution.py -| link:example_py_dithering.html[Floyd-Steinberg Dithering] | dither.py -| link:example_py_gfx.html[GFX Primitives] | gfx.py -| link:example_py_showimage.html[Showimage] | showimage.py -| link:example_py_x11_windows.html[X11 backend with multiple windows] | x11_windows.py -|===========================
-----------------------------------------------------------------------
Summary of changes: demos/py_simple/progress_callback.py | 14 +++-- doc/asciidoc.conf | 3 +- doc/core_python.txt | 14 +++++ doc/example_py_progress_callback.txt | 9 +++ doc/examples.txt | 38 -------------- doc/favicon.png | Bin 609 -> 873 bytes doc/filters_python.txt | 3 +- doc/loaders_python.txt | 5 +- pylib/gfxprim/common.i | 90 +++++++++++++++++++++++++++++++++- pylib/gfxprim/core/core.i | 72 --------------------------- 10 files changed, 127 insertions(+), 121 deletions(-) create mode 100644 doc/example_py_progress_callback.txt delete mode 100644 doc/examples.txt
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.