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 02150e7e23c559f9378d189e7435c2497284a4e9 (commit) via 04b114db0cc700aa394c5ef91dfc4b34ac55a654 (commit) from d5c09d5b8cd72e73f0e0df4110a3981f943d44f9 (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/02150e7e23c559f9378d189e7435c2497284a...
commit 02150e7e23c559f9378d189e7435c2497284a4e9 Author: Cyril Hrubis metan@ucw.cz Date: Thu Mar 21 20:04:46 2013 +0100
pywrap: core: Implement progress callback.
This is first working version of progress callback.
Beware the python API will change.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/py_simple/progress_callback.py b/demos/py_simple/progress_callback.py new file mode 100755 index 0000000..707f0ca --- /dev/null +++ b/demos/py_simple/progress_callback.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +import sys + +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}%".format(callback)) + return 0 + +def main(): + if len(sys.argv) != 2: + print("Takes an image as an argument") + sys.exit(1) + + callback = core.c_core.GP_ProgressCallback(progress_callback) + + img = loaders.Load(sys.argv[1], callback) + print() + + img = filters.FilterGaussianBlurAlloc(img, 50, 50, callback) + print() + +if __name__ == '__main__': + main() diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i index 6e616a1..2657327 100644 --- a/pylib/gfxprim/core/core.i +++ b/pylib/gfxprim/core/core.i @@ -15,12 +15,10 @@ %include "GP_Transform.h" %include "GP_GetSetBits.h" %include "GP_Transform.h" -%include "GP_ProgressCallback.h"
/* * Make members of GP_DebugMsg structure immutable */ - %immutable GP_DebugMsg::level; %immutable GP_DebugMsg::file; %immutable GP_DebugMsg::fn; @@ -30,6 +28,76 @@ %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 */ + if (res == NULL) { + GP_WARN("Parse 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; +} +%} + +%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/04b114db0cc700aa394c5ef91dfc4b34ac55a...
commit 04b114db0cc700aa394c5ef91dfc4b34ac55a654 Author: Cyril Hrubis metan@ucw.cz Date: Thu Mar 21 20:03:32 2013 +0100
loaders: GP_Loader: Fix signature warning.
Do not print signature warning when operation was canceled by callback.
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c index 0cce654..9f4f4ad 100644 --- a/libs/loaders/GP_Loader.c +++ b/libs/loaders/GP_Loader.c @@ -279,9 +279,9 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
/* * Avoid further work if signature was correct but the loader issued - * ENOSYS. + * ENOSYS or ECANCELED. */ - if (ext_load != NULL && errno == ENOSYS) + if (ext_load != NULL && (errno == ENOSYS || errno == ECANCELED)) return NULL;
sig_load = loader_by_signature(src_path);
-----------------------------------------------------------------------
Summary of changes: demos/py_simple/progress_callback.py | 27 +++++++++++++ libs/loaders/GP_Loader.c | 4 +- pylib/gfxprim/core/core.i | 72 +++++++++++++++++++++++++++++++++- 3 files changed, 99 insertions(+), 4 deletions(-) create mode 100755 demos/py_simple/progress_callback.py
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.