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, generate has been updated via b964f56ae4fe0a0a48f16fc18a8daec953acb3cc (commit) from 3037f6a8d06bf7262dbaf15395affd4e241fad1d (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/b964f56ae4fe0a0a48f16fc18a8daec953acb...
commit b964f56ae4fe0a0a48f16fc18a8daec953acb3cc Author: Cyril Hrubis metan@ucw.cz Date: Sun Oct 30 17:41:16 2011 +0100
Changed the filter API (hopefully this is final version).
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index f372bf5..beb69e2 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -217,13 +217,13 @@ static GP_RetCode rotate(GP_Context **c, const char *params)
switch (rot) { case 0: - res = GP_FilterRotate90(*c, progress_callback); + res = GP_FilterRotate90(*c, NULL, progress_callback); break; case 1: - res = GP_FilterRotate180(*c, progress_callback); + res = GP_FilterRotate180(*c, NULL, progress_callback); break; case 2: - res = GP_FilterRotate270(*c, progress_callback); + res = GP_FilterRotate270(*c, NULL, progress_callback); break; } diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h index daa8287..245e3c2 100644 --- a/include/filters/GP_Rotate.h +++ b/include/filters/GP_Rotate.h @@ -40,7 +40,14 @@ void GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback);
-GP_Context *GP_FilterMirrorH(const GP_Context *src, +/* + * Mirrors bitmap horizontally. + * + * If dst is NULL, new bitmap is allocated. + * + * Returns pointer to destination bitmap or NULL if allocation failed. + */ +GP_Context *GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback);
/* @@ -51,14 +58,21 @@ GP_Context *GP_FilterMirrorH(const GP_Context *src, void GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback);
-GP_Context *GP_FilterMirrorV(const GP_Context *src, +/* + * Mirrors bitmap vertically. + * + * If dst is NULL, new bitmap is allocated. + * + * Returns pointer to destination bitmap or NULL if allocation failed. + */ +GP_Context *GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback);
/* * Rotate context by 90, 180 and 270. * * Doesn't work 'in place'. The contexts must have equal pixel_type size must - * match the rotated size size (is equal for 180 and swapped for 90 and 270). + * match the rotated size (is equal for 180 and swapped for 90 and 270). */ void GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback); @@ -69,7 +83,30 @@ void GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst, void GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback);
-typedef enum GP_FilterRotation { +/* + * Rotate the context by 90, 180, 270. + * + * If dst is NULL, new bitmap is allocated. + * + * Returns pointer to destination bitmap or NULL if allocation failed. + */ +GP_Context *GP_FilterRotate90(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback); + +GP_Context *GP_FilterRotate180(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback); + +GP_Context *GP_FilterRotate270(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback); + +/* + * Calls a symmetry filter on bitmap. + * + * If dst is NULL, new bitmap is allocated. + * + * Returns pointer to destination bitmap or NULL if allocation failed. + */ +typedef enum GP_FilterSymmetries { GP_ROTATE_90, GP_ROTATE_CW = GP_ROTATE_90, GP_ROTATE_180, @@ -77,32 +114,10 @@ typedef enum GP_FilterRotation { GP_ROTATE_CCW = GP_ROTATE_270, GP_MIRROR_H, GP_MIRROR_V, -} GP_FilterRotation; - -void GP_FilterRotate_Raw(const GP_Context *src, GP_Context *dst, - GP_FilterRotation rotation, - GP_ProgressCallback *callback); - -GP_Context *GP_FilterRotate(const GP_Context *context, - GP_FilterRotation rotation, - GP_ProgressCallback *callback); +} GP_FilterSymmetries;
-static inline GP_Context *GP_FilterRotate90(const GP_Context *src, - GP_ProgressCallback *callback) -{ - return GP_FilterRotate(src, GP_ROTATE_90, callback); -} - -static inline GP_Context *GP_FilterRotate180(const GP_Context *src, - GP_ProgressCallback *callback) -{ - return GP_FilterRotate(src, GP_ROTATE_180, callback); -} - -static inline GP_Context *GP_FilterRotate270(const GP_Context *src, - GP_ProgressCallback *callback) -{ - return GP_FilterRotate(src, GP_ROTATE_270, callback); -} +GP_Context *GP_FilterSymmetry(const GP_Context *src, GP_Context *dst, + GP_FilterSymmetries symmetry, + GP_ProgressCallback *callback);
#endif /* FILTERS_GP_ROTATE_H */ diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c index ea7ae0a..73987e7 100644 --- a/libs/filters/GP_Rotate.c +++ b/libs/filters/GP_Rotate.c @@ -53,8 +53,49 @@ void GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallbackDone(callback); }
+GP_Context *GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + if (dst == NULL) { + dst = GP_ContextCopy(src, 0); + + if (dst == NULL) + return NULL; + } else { + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->w && src->h <= dst->h, + "Destination is not big enough"); + } + + GP_FilterMirrorH_Raw(src, dst, callback); + + return dst; +} + + +GP_Context *GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + if (dst == NULL) { + dst = GP_ContextCopy(src, 0); + + if (dst == NULL) + return NULL; + } else { + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->w && src->h <= dst->h, + "Destination is not big enough"); + } + + GP_FilterMirrorV_Raw(src, dst, callback); + + return dst; +} + void GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst, - GP_ProgressCallback *callback) + GP_ProgressCallback *callback) { #warning FIXME: Callbacks, faster algorighm?
@@ -62,53 +103,82 @@ void GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst, GP_FilterMirrorH_Raw(dst, dst, callback); }
-void GP_FilterRotate_Raw(const GP_Context *src, GP_Context *dst, - GP_FilterRotation rotation, - GP_ProgressCallback *callback) +GP_Context *GP_FilterRotate90(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { - switch (rotation) { - case GP_ROTATE_90: - GP_FilterRotate90_Raw(src, dst, callback); - break; - case GP_ROTATE_180: - GP_FilterRotate180_Raw(src, dst, callback); - break; - case GP_ROTATE_270: - GP_FilterRotate270_Raw(src, dst, callback); - break; - case GP_MIRROR_H: - GP_FilterMirrorH_Raw(src, dst, callback); - break; - case GP_MIRROR_V: - GP_FilterMirrorV_Raw(src, dst, callback); - break; + if (dst == NULL) { + dst = GP_ContextAlloc(src->h, src->w, src->pixel_type); + + if (dst == NULL) + return NULL; + } else { + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->h && src->h <= dst->w, + "Destination is not big enough"); } + + GP_FilterRotate90_Raw(src, dst, callback); + + return dst; }
-GP_Context *GP_FilterRotate(const GP_Context *context, - GP_FilterRotation rotation, - GP_ProgressCallback *callback) +GP_Context *GP_FilterRotate180(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { - GP_Size w = context->w; - GP_Size h = context->h; - - switch (rotation) { - case GP_ROTATE_90: - case GP_ROTATE_270: - GP_SWAP(w, h); - break; - default: - break; + if (dst == NULL) { + dst = GP_ContextCopy(src, 0); + + if (dst == NULL) + return NULL; + } else { + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->w && src->h <= dst->h, + "Destination is not big enough"); }
- GP_Context *ret = GP_ContextAlloc(w, h, context->pixel_type); + GP_FilterRotate180_Raw(src, dst, callback); + + return dst; +}
- if (unlikely(ret == NULL)) { - GP_DEBUG(1, "Malloc failed :("); - return NULL; +GP_Context *GP_FilterRotate270(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + if (dst == NULL) { + dst = GP_ContextAlloc(src->h, src->w, src->pixel_type); + + if (dst == NULL) + return NULL; + } else { + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->h && src->h <= dst->w, + "Destination is not big enough"); }
- GP_FilterRotate_Raw(context, ret, rotation, callback); + GP_FilterRotate270_Raw(src, dst, callback); + + return dst; +} + +GP_Context *GP_FilterSymmetry(const GP_Context *src, GP_Context *dst, + GP_FilterSymmetries symmetry, + GP_ProgressCallback *callback) +{ + switch (symmetry) { + case GP_ROTATE_90: + return GP_FilterRotate90(src, dst, callback); + case GP_ROTATE_180: + return GP_FilterRotate180(src, dst, callback); + case GP_ROTATE_270: + return GP_FilterRotate270(src, dst, callback); + case GP_MIRROR_H: + return GP_FilterMirrorH(src, dst, callback); + case GP_MIRROR_V: + return GP_FilterMirrorV(src, dst, callback); + }
- return ret; + return NULL; }
-----------------------------------------------------------------------
Summary of changes: demos/grinder/grinder.c | 6 +- include/filters/GP_Rotate.h | 75 +++++++++++++--------- libs/filters/GP_Rotate.c | 148 +++++++++++++++++++++++++++++++----------- 3 files changed, 157 insertions(+), 72 deletions(-)
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.