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
discards 9c0d7122590ec63c4a9cb6e5b019f373e84a6106 (commit)
via 40459eab2c4a3af4a5eccd1b3cbe1bd94353f9c7 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (9c0d7122590ec63c4a9cb6e5b019f373e84a6106)
N -- N -- N (40459eab2c4a3af4a5eccd1b3cbe1bd94353f9c7)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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/40459eab2c4a3af4a5eccd1b3cbe1bd94353…
commit 40459eab2c4a3af4a5eccd1b3cbe1bd94353f9c7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Jun 4 16:22:41 2012 +0200
pywrap: Fix error reporting.
The python headers define _GNU_SOURCE so the
strerror_r variant is GNU one, which may use the passed
buffer to, but that is not guaranted it also may return
pointer to some statically allocated buffer.
Also make sure _GNU_SOURCE is defined in pywrap.mk.
diff --git a/pylib/gfxprim/common.i b/pylib/gfxprim/common.i
index 66b37b0..bc99ff3 100644
--- a/pylib/gfxprim/common.i
+++ b/pylib/gfxprim/common.i
@@ -23,11 +23,9 @@
%exception funcname {
$action
if (result == NULL) {
- int errno0 = errno;
- const int errbuf_len = 128;
- char errbuf[errbuf_len];
- strerror_r(errno0, errbuf, errbuf_len);
- PyErr_Format(PyExc_RuntimeError, "Error in function %s: %s", "$name", errbuf);
+ char errbuf[128];
+ char *errmsg = strerror_r(errno, errbuf, sizeof(errbuf));
+ PyErr_Format(PyExc_RuntimeError, "Error in function %s: %s", "$name", errmsg);
return NULL;
}
}
@@ -42,11 +40,9 @@
%exception funcname {
$action
if (result != 0) {
- int errno0 = errno;
- const int errbuf_len = 128;
- char errbuf[errbuf_len];
- strerror_r(errno0, errbuf, errbuf_len);
- PyErr_Format(PyExc_RuntimeError, "Error in function %s: %s", "$name", errbuf);
+ char errbuf[128];
+ char *errmsg = strerror_r(errno, errbuf, sizeof(errbuf));
+ PyErr_Format(PyExc_RuntimeError, "Error in function %s: %s", "$name", errmsg);
return NULL;
}
}
diff --git a/pywrap.mk b/pywrap.mk
index 0ec5602..03d22cf 100644
--- a/pywrap.mk
+++ b/pywrap.mk
@@ -23,10 +23,10 @@ endif # VERBOSE
$(SWIG_LIB): $(SWIG_C)
ifdef VERBOSE
- $(CC) $< $(CFLAGS) $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
+ $(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
else # VERBOSE
@echo "LD $@"
- @$(CC) $< $(CFLAGS) $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
+ @$(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
endif # VERBOSE
endif # ifneq ($(SWIG),)
-----------------------------------------------------------------------
Summary of changes:
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 a2a5ee04d3fbbdc6fdcc4c7a932a5b11f3edee49 (commit)
from 1ef7dcb59e9b7b131e59c4965e3ce775e8b26de5 (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/a2a5ee04d3fbbdc6fdcc4c7a932a5b11f3ed…
commit a2a5ee04d3fbbdc6fdcc4c7a932a5b11f3edee49
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jun 3 15:51:08 2012 +0200
doc: Add meta-data examples.
diff --git a/doc/examples.txt b/doc/examples.txt
index 5c426f0..ec356e2 100644
--- a/doc/examples.txt
+++ b/doc/examples.txt
@@ -23,6 +23,19 @@ Example in C utilizing progress callback
include::../demos/c_simple/loaders.c[]
------------------------------------------------------------------
+Example in C using image meta-data interface
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[source,c]
+------------------------------------------------------------------
+include::../demos/c_simple/meta_data.c[]
+------------------------------------------------------------------
+
+[source,c]
+------------------------------------------------------------------
+include::../demos/c_simple/meta_data_dump.c[]
+------------------------------------------------------------------
+
Example in Python
~~~~~~~~~~~~~~~~~
-----------------------------------------------------------------------
Summary of changes:
doc/examples.txt | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 1ef7dcb59e9b7b131e59c4965e3ce775e8b26de5 (commit)
from c67470e8571d4b391c9c0440b96a9cd1d578fe10 (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/1ef7dcb59e9b7b131e59c4965e3ce775e8b2…
commit 1ef7dcb59e9b7b131e59c4965e3ce775e8b26de5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jun 3 15:37:50 2012 +0200
pywrap: Update GP_FilterParam pywrap.
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index 274c765..e12ca55 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -15,13 +15,22 @@
%include "GP_Filters.h"
/* Listed in GP_Filters.h: */
-%include "GP_FilterParam.h"
%include "GP_Point.h"
%ignore GP_Histogram::hist;
%include "GP_Stats.h"
%include "GP_Linear.h"
%include "GP_Resize.h"
+%extend GP_FilterParam {
+ ~GP_FilterParam() {
+ GP_DEBUG(2, "[wrapper] GP_FilterParamFree");
+ GP_FilterParamDestroy($self);
+ }
+}
+
+%newobject GP_FilterParamCreate;
+%include "GP_FilterParam.h"
+
/* Functions returning new allocated context */
%immutable GP_FilterSymmetryNames;
-----------------------------------------------------------------------
Summary of changes:
pylib/gfxprim/filters/filters.i | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 9ba3f4f318081d8fc506b58a782375d3b36e19b2 (commit)
from 4c2a2fda5d4751fdc40f987c9aa8b80197b79f6b (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/9ba3f4f318081d8fc506b58a782375d3b36e…
commit 9ba3f4f318081d8fc506b58a782375d3b36e19b2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jun 3 13:40:41 2012 +0200
pywrap: Update list of newobject filters.
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index 866ea9b..274c765 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -17,7 +17,6 @@
/* Listed in GP_Filters.h: */
%include "GP_FilterParam.h"
%include "GP_Point.h"
-%include "GP_Arithmetic.h"
%ignore GP_Histogram::hist;
%include "GP_Stats.h"
%include "GP_Linear.h"
@@ -26,16 +25,22 @@
/* Functions returning new allocated context */
%immutable GP_FilterSymmetryNames;
-%include "GP_Rotate.h"
-
%newobject GP_FilterMirrorH_Alloc;
%newobject GP_FilterMirrorV_Alloc;
%newobject GP_FilterRotate90_Alloc;
%newobject GP_FilterRotate180_Alloc;
%newobject GP_FilterRotate270_Alloc;
%newobject GP_FilterSymmetry_Alloc;
+%include "GP_Rotate.h"
-%include "GP_Dither.h"
%newobject GP_FilterFloydSteinberg_RGB888_Alloc;
%newobject GP_FilterHilbertPeano_RGB888_Alloc;
+%include "GP_Dither.h"
+
+%newobject GP_FilterAdditionAlloc;
+%newobject GP_FilterMultiplyAlloc;
+%newobject GP_FilterDifferenceAlloc;
+%newobject GP_FilterMaxAlloc;
+%newobject GP_FilterMinAlloc;
+%include "GP_Arithmetic.h"
-----------------------------------------------------------------------
Summary of changes:
pylib/gfxprim/filters/filters.i | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 4c2a2fda5d4751fdc40f987c9aa8b80197b79f6b (commit)
via 997b04b5ded1777428594d22cbd0ec9862bceca4 (commit)
via a0576560f951f9bb3b9d4257597c4e82910a1379 (commit)
from 427d2740236f2b4c0e9045282ca3d8d1cc37042a (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/4c2a2fda5d4751fdc40f987c9aa8b80197b7…
commit 4c2a2fda5d4751fdc40f987c9aa8b80197b79f6b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jun 3 13:36:49 2012 +0200
doc: Update filters docs.
diff --git a/doc/filters.txt b/doc/filters.txt
index fad32b2..9329361 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -13,28 +13,29 @@ Common filter API
For convenience, the filters API is unified:
-* Each filter returns pointer to destination context or 'NULL' on failure
-* The first two arguments are source and destination
-* The last argument is progress callback
-
-Each filter function could be used in two modes.
+* There are two functions for each filter
+ - first one takes destination as an argument
+ - second one allocates the destination and returns pointer to it
+* First argument(s) are always source(s)
+* Then, in case of second variant, destination
+* Other parameters follow
+* And the last argument is progress callback
+
+When using allocating version of the filter, pointer to the newly allocated
+context is returned, or in case of failure 'NULL' is returned. If filter has
+been interrupted by a callback, all allocated memory is freed and 'NULL' is
+returned.
-By passing non-'NULL' argument as filter destination user requests result to
-be stored into the destination context. The context must have correct pixel
-type and the context size must be big enough to store the result.
+When using non-allocating variant of the filter, the destination context must
+have correct pixel type and the context size must be big enough to store the
+result. The return value from such filter is either zero, in case of success,
+or non-zero when filter was interrupted by a callback.
For filters that work 'in-place' (which is explicitly said for each filter)
the source and the destination could be the same context. Note that this is
-not expected to work if you do several overlapping subcontexts and pass these
+not expected to work if you do several overlapping sub-contexts and pass these
as arguments.
-When 'NULL' is passed as destination new context for storing the result is
-allocated and returned.
-
-The return value is either pointer to destination context or 'NULL' either
-when malloc(2) has failed or if the filter is not implemented for such
-pixel_type, parameters, etc...
-
[source,c]
-------------------------------------------------------------------------------
/*
@@ -103,12 +104,106 @@ GP_Context *GP_FilterInvert(const GP_Context *src, GP_Context *dst,
Inverts the image, for each channel the result value is computed as "chan_max
- val".
+Arithmetic filters
+~~~~~~~~~~~~~~~~~~
+
+Arithmetic filters do take two contexts as an input and combines them into one
+output context.
+
+The pixel type of both input contexts must match.
+
+If size of the input contexts differs, minimum is used.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <filters/GP_Arithmetic.h>
+/* or */
+#include <GP.h>
+
+int GP_FilterAddition(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterAdditionAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Produces saturated (clamped) addition of two contexts.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <filters/GP_Arithmetic.h>
+/* or */
+#include <GP.h>
+
+int GP_FilterMultiply(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterMultiplyAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Produces saturated (clamped) multiplication of two contexts.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <filters/GP_Arigthmetic.h>
+/* or */
+#include <GP.h>
+
+int GP_FilterDifference(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterDifferenceAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
+
+-------------------------------------------------------------------------------
+
+Produces symmetric difference (i.e. abs(a - b)).
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <filters/GP_Arigthmetic.h>
+/* or */
+#include <GP.h>
+
+int GP_FilterMax(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterMaxAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
+
+int GP_FilterMin(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterMinAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Maximum and minimum filter.
+
Rotation and Symmetry filters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Filters.h>
+#include <filters/GP_Rotate.h>
+/* or */
+#include <GP.h>
int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
@@ -126,7 +221,9 @@ as large as source.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Filters.h>
+#include <filters/GP_Rotate.h>
+/* or */
+#include <GP.h>
int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
@@ -144,7 +241,9 @@ as large as source.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Filters.h>
+#include <filters/GP_Rotate.h>
+/* or */
+#include <GP.h>
int GP_FilterRotate90(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
@@ -162,7 +261,9 @@ fit rotated context (i.e. W and H are swapped).
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Filters.h>
+#include <filters/GP_Rotate.h>
+/* or */
+#include <GP.h>
int GP_FilterRotate180(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
@@ -180,7 +281,9 @@ as large as source.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Filters.h>
+#include <filters/GP_Rotate.h>
+/* or */
+#include <GP.h>
int GP_FilterRotate270(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
@@ -194,10 +297,14 @@ Rotate context by 270 degrees.
Doesn't work 'in-place' (yet).
The destination has to have the same pixel type and destination size must be
-large enough to fit rotated context (eg. W and H are swapped).
+large enough to fit rotated context (i.e. W and H are swapped).
[source,c]
-------------------------------------------------------------------------------
+#include <filters/GP_Rotate.h>
+/* or */
+#include <GP.h>
+
typedef enum GP_FilterSymmetries {
GP_ROTATE_90,
GP_ROTATE_CW = GP_ROTATE_90,
@@ -263,7 +370,7 @@ Doesn't work 'in-place' (this is quite impossible as the size of the bitmap is
changed by the filter).
If the filter destination is non 'NULL' and the 'w' and 'h' is smaller than the
-destination size the source image is interpolated into subcontext of
+destination size the source image is interpolated into sub-context of
destination defined by 'w' and 'h'.
'TODO:' this filter is implemented for RGB888 only.
http://repo.or.cz/w/gfxprim.git/commit/997b04b5ded1777428594d22cbd0ec9862bc…
commit 997b04b5ded1777428594d22cbd0ec9862bceca4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jun 3 12:22:48 2012 +0200
filters: Change arithmetics filters API.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c
index 3da5037..abdf546 100644
--- a/demos/grinder/grinder.c
+++ b/demos/grinder/grinder.c
@@ -608,19 +608,19 @@ static GP_RetCode arithmetic(GP_Context **c, const char *params)
switch (op) {
case 0:
- res = GP_FilterDifference(*c, img, NULL, progress_callback);
+ res = GP_FilterDifferenceAlloc(*c, img, progress_callback);
break;
case 1:
- res = GP_FilterAddition(*c, img, NULL, progress_callback);
+ res = GP_FilterAdditionAlloc(*c, img, progress_callback);
break;
case 2:
- res = GP_FilterMultiply(*c, img, NULL, progress_callback);
+ res = GP_FilterMultiplyAlloc(*c, img, progress_callback);
break;
case 3:
- res = GP_FilterMin(*c, img, NULL, progress_callback);
+ res = GP_FilterMinAlloc(*c, img, progress_callback);
break;
case 4:
- res = GP_FilterMax(*c, img, NULL, progress_callback);
+ res = GP_FilterMaxAlloc(*c, img, progress_callback);
break;
}
diff --git a/include/filters/GP_Arithmetic.h b/include/filters/GP_Arithmetic.h
index 9f1cb20..47fca47 100644
--- a/include/filters/GP_Arithmetic.h
+++ b/include/filters/GP_Arithmetic.h
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -34,21 +34,30 @@
/*
* Addition filter.
*
- * Produces clamped addtion.
+ * Produces saturated (clamped) addtion.
*/
-GP_Context *GP_FilterAddition(const GP_Context *src_a,
- const GP_Context *src_b,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterAddition(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterAdditionAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
+
/*
* Multiply filter.
*
- * Produces clamped multiplication.
+ * Produces saturated (clamped) multiplication.
*/
-GP_Context *GP_FilterMultiply(const GP_Context *src_a,
- const GP_Context *src_b,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterMultiply(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterMultiplyAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
/*
* Difference filter.
@@ -56,25 +65,37 @@ GP_Context *GP_FilterMultiply(const GP_Context *src_a,
* Produces symetric difference.
* eg. dst = abs(src_a - src_b)
*/
-GP_Context *GP_FilterDifference(const GP_Context *src_a,
- const GP_Context *src_b,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterDifference(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterDifferenceAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
/*
* Maximum filter.
*/
-GP_Context *GP_FilterMax(const GP_Context *src_a,
- const GP_Context *src_b,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterMax(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterMaxAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
/*
* Minimum filter.
*/
-GP_Context *GP_FilterMin(const GP_Context *src_a,
- const GP_Context *src_b,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterMin(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterMinAlloc(const GP_Context *src_a,
+ const GP_Context *src_b,
+ GP_ProgressCallback *callback);
#endif /* FILTERS_GP_ARITHMETIC_H */
diff --git a/pylib/templates/filter.arithmetic.c.t b/pylib/templates/filter.arithmetic.c.t
index e083921..d74ddce 100644
--- a/pylib/templates/filter.arithmetic.c.t
+++ b/pylib/templates/filter.arithmetic.c.t
@@ -116,10 +116,30 @@ int GP_Filter{{ name }}_Raw(const GP_Context *src_a, const GP_Context *src_b,
return 1;
}
-GP_Context *GP_Filter{{ name }}(const GP_Context *src_a, const GP_Context *src_b,
- GP_Context *dst{{ maybe_opts_l(opts) }}, GP_ProgressCallback *callback)
+int GP_Filter{{ name }}(const GP_Context *src_a, const GP_Context *src_b,
+ GP_Context *dst{{ maybe_opts_l(opts) }},
+ GP_ProgressCallback *callback)
{
- GP_Context *res = dst;
+ GP_Size w = GP_MIN(src_a->w, src_b->w);
+ GP_Size h = GP_MIN(src_a->h, src_b->h);
+
+ GP_ASSERT(src_a->pixel_type == dst->pixel_type,
+ "The src and dst pixel types must match");
+ GP_ASSERT(w <= dst->w && h <= dst->h,
+ "Destination is not big enough");
+
+ if (GP_Filter{{ name }}_Raw(src_a, src_b, dst{{ maybe_opts_l(params) }}, callback)) {
+ GP_DEBUG(1, "Operation aborted");
+ return 1;
+ }
+
+ return 0;
+}
+
+GP_Context *GP_Filter{{ name }}Alloc(const GP_Context *src_a, const GP_Context *src_b,
+ {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback)
+{
+ GP_Context *res;
GP_ASSERT(src_a->pixel_type == src_b->pixel_type,
"Pixel types for sources must match.");
@@ -127,24 +147,15 @@ GP_Context *GP_Filter{{ name }}(const GP_Context *src_a, const GP_Context *src_b
GP_Size w = GP_MIN(src_a->w, src_b->w);
GP_Size h = GP_MIN(src_a->h, src_b->h);
- if (res == NULL) {
-
- res = GP_ContextAlloc(w, h, src_a->pixel_type);
-
- if (res == NULL)
- return NULL;
- } else {
- GP_ASSERT(src_a->pixel_type == dst->pixel_type,
- "The src and dst pixel types must match");
- GP_ASSERT(w <= dst->w && h <= dst->h,
- "Destination is not big enough");
- }
+ res = GP_ContextAlloc(w, h, src_a->pixel_type);
+
+ if (res == NULL)
+ return NULL;
if (GP_Filter{{ name }}_Raw(src_a, src_b, res{{ maybe_opts_l(params) }}, callback)) {
GP_DEBUG(1, "Operation aborted");
- if (dst == NULL)
- GP_ContextFree(res);
+ GP_ContextFree(res);
return NULL;
}
http://repo.or.cz/w/gfxprim.git/commit/a0576560f951f9bb3b9d4257597c4e82910a…
commit a0576560f951f9bb3b9d4257597c4e82910a1379
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jun 3 12:22:12 2012 +0200
doc: Update backend docs.
diff --git a/doc/Makefile b/doc/Makefile
index d709a78..8d4ffbf 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,7 +1,7 @@
all: api.html examples.html
api.html: general.txt api.txt context.txt loaders.txt filters.txt - basic_types.txt drawing_api.txt
+ basic_types.txt drawing_api.txt backends.txt
asciidoc -a toc api.txt
examples.html: examples.txt ../demos/c_simple/*.c ../demos/py_simple/*.py
diff --git a/doc/backends.txt b/doc/backends.txt
index 2a614ff..9ce83d7 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -15,16 +15,16 @@ Initialization functions
[source,c]
-------------------------------------------------------------------------------
-GP_Backend *GP_BackendLinuxFBInit(const char *path);
+GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag);
-------------------------------------------------------------------------------
Initializes mmaped frame-buffer backend. The path is path to the frame-buffer
device i.e. '/dev/fbX'. This backend is not buffered, everything you draw
appears on the screen right away (an switch may be added for that purpose).
-Also note that this backend doesn't initialize any input driver. You need to
-initialize input driver in order to get keystrokes and/or pointer events.
-
+If flag is set console KBD driver is used to feed keystrokes into the event
+queue, otherwise no events are generated and you are expected to initialize
+input event driver in order to get keystrokes and/or pointer events.
[source,c]
-------------------------------------------------------------------------------
@@ -39,28 +39,47 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h,
-------------------------------------------------------------------------------
Initialize SDL as an backend driver. The backend is thread safe as all the
-operations are guarded by locks. You can't initialize more than one backend at a
-time, that is inherited SDL limitation. If you call the initialization for a
-second time, you will get a pointer to already running backend. This driver
-feeds input events into global input event queue (see input docs for details).
-If w, h and/or bpp are zero SDL tries to do a guess, most of the time wrong for
-w and h though. The caption is window caption and may be ignored for some of
-the backends. And finally flags may change the SDL to go to full-screen mode or
-make the window resizable.
+operations are guarded by locks.
+
+You can't initialize more than one backend at a time, which is inherited SDL
+limitation. If you call the initialization for a second time, you will get a
+pointer to already running backend.
+
+This driver feeds input events into global input event queue (see input docs
+for details).
+
+If w, h and/or bpp are zero SDL tries to do a guess, most of the time wrong
+for w and h though.
+
+The caption is window caption.
+
+And finally flags may change the SDL to go to full-screen mode or make the
+window resizable.
[source,c]
-------------------------------------------------------------------------------
+enum GP_BackendX11Flags {
+ /*
+ * When set, w and h is ignored and root window is used
+ */
+ GP_X11_USE_ROOT_WIN = 0x01,
+};
+
GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
unsigned int w, unsigned int h,
- const char *caption);
+ const char *caption,
+ enum GP_BackendX11Flags flags);
-------------------------------------------------------------------------------
-Returns pointer to backend. When display is NULL default display is used
-(which is what you want most of the time). This backend feeds key events into
-global input queue (pointer events not implemented yet). Note this is
-experimental version of X11 backend and will be changed to support more
-windows at a time.
+Returns pointer to initialized X11 backend or in case of failure NULL.
+
+When display is NULL default display is used (which is what you want most of the
+time).
+This backend feeds key events into global input queue.
+
+Note this is experimental version of X11 backend and will be changed to support
+more windows at a time.
Overall init function
~~~~~~~~~~~~~~~~~~~~~
@@ -95,7 +114,29 @@ initialization yields pointer to this structure. Although is possible to call
these pointers directly it's not recommended and everybody should rather use
backend inline functions instead.
-The backend API consist of several functions:
+The backend API consist GP_Backend structure and of several functions:
+
+[source,c]
+-------------------------------------------------------------------------------
+typdef struct GP_Backend {
+ /*
+ * Backend name.
+ */
+ const char *name;
+
+ /*
+ * Pointer to context app should draw to.
+ */
+ GP_Context *context;
+
+ ...
+
+ /*
+ * Connection fd. Set to -1 if not available
+ */
+ int fd;
+};
+-------------------------------------------------------------------------------
[source,c]
-------------------------------------------------------------------------------
@@ -128,3 +169,23 @@ void GP_BackendPoll(GP_Backend *backend);
Polls for backend events. For backends that do not expose file descriptor
(namely SDL) this should be called repeatedly. For other backend it may be
called either repeatedly or when data are ready on file-descriptor.
+
+[source,c]
+-------------------------------------------------------------------------------
+int GP_BackendSetCaption(GP_Backend *backend, const char *caption)
+-------------------------------------------------------------------------------
+
+Sets backend caption. On success zero is returned. On failure (backend doesn't
+support caption, operation failed) non zero is returned.
+
+[source,c]
+-------------------------------------------------------------------------------
+int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h);
+-------------------------------------------------------------------------------
+
+Resize backend, if supported. On success zero is returned and backend is
+resized, otherwise (if resize failed, or is not supported) non-zero is
+returned. If backend size already matches w and h, nothing is done.
+
+Note that backend->context pointer may change upon calling this function and
+at least backend->context->pixels pointer will change.
-----------------------------------------------------------------------
Summary of changes:
demos/grinder/grinder.c | 10 +-
doc/Makefile | 2 +-
doc/backends.txt | 99 +++++++++++++++++----
doc/filters.txt | 155 ++++++++++++++++++++++++++++-----
include/filters/GP_Arithmetic.h | 67 +++++++++-----
pylib/templates/filter.arithmetic.c.t | 45 ++++++----
6 files changed, 289 insertions(+), 89 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")