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 3037f6a8d06bf7262dbaf15395affd4e241fad1d (commit) via a8f1ba07c9863cdda6b55a7b82fb35fbe55758a9 (commit) via bcaa19c8129a6bcaac8a3640979e91135c016846 (commit) via 828d02ecb1948597d7f7b83e86f15e7bb7ca9164 (commit) from 7d1c1b2c4aeef95941109cbdc5707eff6ad0a36f (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/3037f6a8d06bf7262dbaf15395affd4e241fa...
commit 3037f6a8d06bf7262dbaf15395affd4e241fad1d Author: Cyril Hrubis metan@ucw.cz Date: Thu Oct 27 23:07:13 2011 +0200
Rewrote rotate and mirror filters.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index 26d6d0d..f372bf5 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -213,18 +213,49 @@ static GP_RetCode rotate(GP_Context **c, const char *params) return GP_EINVAL; }
+ GP_Context *res = NULL; + switch (rot) { case 0: - GP_RotateCW(*c); + res = GP_FilterRotate90(*c, progress_callback); break; case 1: - GP_MirrorV(*c); - GP_MirrorH(*c); + res = GP_FilterRotate180(*c, progress_callback); break; case 2: - GP_RotateCCW(*c); + res = GP_FilterRotate270(*c, progress_callback); break; } + + if (res == NULL) + return GP_ENOMEM; + + GP_ContextFree(*c); + *c = res; + + return GP_ESUCCESS; +} + +/* mirror filter */ + +static struct param mirror_params[] = { + {"vert", PARAM_BOOL, "mirror vertically", NULL, NULL}, + {"horiz", PARAM_BOOL, "mirror horizontally", NULL, NULL}, + {NULL, 0, NULL, NULL, NULL} +}; + +static GP_RetCode mirror(GP_Context **c, const char *params) +{ + int vert = 0, horiz = 0; + + if (param_parse(params, mirror_params, "mirror", param_err, &vert, &horiz)) + return GP_EINVAL; + + if (vert) + GP_FilterMirrorV_Raw(*c, *c, progress_callback); + + if (horiz) + GP_FilterMirrorH_Raw(*c, *c, progress_callback);
return GP_ESUCCESS; } @@ -334,9 +365,10 @@ struct filter { };
static struct filter filter_table[] = { - {"resize", "resize image by given ratio", resize_params, resize}, - {"scale", "scale image to given width and height", scale_params, scale}, {"rotate", "rotate image", rotate_params, rotate}, + {"mirror", "mirror vertically/horizontally", mirror_params, mirror}, + {"scale", "scale image to given width and height", scale_params, scale}, + {"resize", "resize image by given ratio", resize_params, resize}, {"bright", "alter image brightness", bright_params, bright}, {"contrast", "alter image contrast", contrast_params, contrast}, {"invert", "inverts image", invert_params, invert}, diff --git a/demos/grinder/params.c b/demos/grinder/params.c index d2dbfb9..17aebb9 100644 --- a/demos/grinder/params.c +++ b/demos/grinder/params.c @@ -183,6 +183,39 @@ int set_int(int *res, char *val) return 0; }
+static char *bool_false[] = { + "No", + "False", + "Off", + NULL +}; + +static char *bool_true[] = { + "Yes", + "True", + "On", + NULL +}; + +int set_bool(int *res, char *val) +{ + unsigned int i; + + for (i = 0; bool_false[i] != NULL; i++) + if (!strcasecmp(val, bool_false[i])) { + *res = 0; + return 0; + } + + for (i = 0; bool_true[i] != NULL; i++) + if (!strcasecmp(val, bool_true[i])) { + *res = 1; + return 0; + } + + return 1; +} + int set_float(float *res, char *val) { char *end; @@ -269,7 +302,11 @@ int param_parse(const char *params, const struct param *param_desc, void *priv,
switch (param_desc[i].type) { case PARAM_BOOL: - + if ((ret = set_bool(arg, values[pos]))) { + CALL_ERR_CALLBACK(err, ¶m_desc[i], + values[pos], priv); + goto err; + } break; case PARAM_INT: if ((ret = set_int(arg, values[pos]))) { diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h index e73b0fe..daa8287 100644 --- a/include/filters/GP_Rotate.h +++ b/include/filters/GP_Rotate.h @@ -16,42 +16,93 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
- GP_Context in place rotations. + GP_Context rotations and mirroring.
*/
-#ifndef GP_ROTATE_H -#define GP_ROTATE_H +#ifndef FILTERS_GP_ROTATE_H +#define FILTERS_GP_ROTATE_H
#include "core/GP_Context.h" +#include "GP_Filter.h"
/* * Mirror horizontally. + * + * Works 'in place'. The contexts must have equal pixel_type and size. */ -GP_RetCode GP_MirrorH(GP_Context *context); +void GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback); + +GP_Context *GP_FilterMirrorH(const GP_Context *src, + GP_ProgressCallback *callback);
/* * Mirror vertically + * + * Works 'in place'. The contexts must have equal pixel_type and size. */ -GP_RetCode GP_MirrorV(GP_Context *context); +void GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback);
-/* - * Rotate clockwise. - */ -GP_RetCode GP_RotateCW(GP_Context *context); +GP_Context *GP_FilterMirrorV(const GP_Context *src, + GP_ProgressCallback *callback);
/* - * Rotate counter clockwise. + * 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). */ -GP_RetCode GP_RotateCCW(GP_Context *context); +void GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback); + +void GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback); + +void GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback); + +typedef enum GP_FilterRotation { + GP_ROTATE_90, + GP_ROTATE_CW = GP_ROTATE_90, + GP_ROTATE_180, + GP_ROTATE_270, + 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); + +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); +}
-#endif /* GP_ROTATE_H */ +#endif /* FILTERS_GP_ROTATE_H */ diff --git a/libs/filters/GP_MirrorV.gen.c.t b/libs/filters/GP_MirrorV.gen.c.t new file mode 100644 index 0000000..c696349 --- /dev/null +++ b/libs/filters/GP_MirrorV.gen.c.t @@ -0,0 +1,44 @@ +%% extends "base.c.t" + +%% block descr +Vertical Mirror alogorithm +%% endblock + +%% block body + +#include "core/GP_GetPutPixel.h" +#include "core/GP_Debug.h" +#include "GP_Rotate.h" + +%% for ps in pixelsizes +void GP_MirrorV_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + uint32_t x, y; + GP_Pixel tmp; + + GP_DEBUG(1, "Mirroring image vertically %ux%u", src->w, src->h); + + for (x = 0; x < src->w/2; x++) { + uint32_t xm = src->w - x - 1; + for (y = 0; y < src->h; y++) { + tmp = GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y); + GP_PutPixel_Raw_{{ ps.suffix }}(dst, x, y, GP_GetPixel_Raw_{{ ps.suffix }}(src, xm, y)); + GP_PutPixel_Raw_{{ ps.suffix }}(dst, xm, y, tmp); + } + + if (callback != NULL && x % 100 == 0) + GP_ProgressCallbackReport(callback, 200.00 * x / src->w); + } + + GP_ProgressCallbackDone(callback); +} + +%% endfor + +void GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + GP_FN_PER_BPP_CONTEXT(GP_MirrorV_Raw, src, src, dst, callback); +} +%% endblock body diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c index 513b969..ea7ae0a 100644 --- a/libs/filters/GP_Rotate.c +++ b/libs/filters/GP_Rotate.c @@ -16,10 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -30,66 +27,88 @@
#include <string.h>
-#include "algo/GP_MirrorV.algo.h" - -GP_RetCode GP_MirrorH(GP_Context *context) +void GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { - uint32_t bpr = context->bytes_per_row; + uint32_t bpr = src->bytes_per_row; uint8_t buf[bpr]; uint32_t y;
- if (context == NULL) - return GP_ENULLPTR; + GP_DEBUG(1, "Mirroring image horizontally %ux%u", src->w, src->h);
- for (y = 0; y < context->h/2; y++) { - uint8_t *l1 = context->pixels + bpr * y; - uint8_t *l2 = context->pixels + bpr * (context->h - y - 1); + #warning FIXME: non byte aligned pixels + + for (y = 0; y < src->h/2; y++) { + uint8_t *l1 = dst->pixels + bpr * y; + uint8_t *l2 = dst->pixels + bpr * (src->h - y - 1);
memcpy(buf, l1, bpr); memcpy(l1, l2, bpr); memcpy(l2, buf, bpr); + + if (callback != NULL && y % 100 == 0) + GP_ProgressCallbackReport(callback, 200.00 * y / src->h); }
- return GP_ESUCCESS; + GP_ProgressCallbackDone(callback); }
-/* Generate mirror functions per BPP */ -GP_DEF_FFN_PER_BPP(GP_MirrorV, DEF_MIRRORV_FN) - -GP_RetCode GP_MirrorV(GP_Context *context) +void GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { - if (context == NULL) - return GP_ENULLPTR; + #warning FIXME: Callbacks, faster algorighm?
- GP_FN_PER_BPP_CONTEXT(GP_MirrorV, context, context); - - return GP_ESUCCESS; + GP_FilterMirrorV_Raw(src, dst, NULL); + GP_FilterMirrorH_Raw(dst, dst, callback); }
-#include "algo/GP_Rotate.algo.h" - -/* Generate Rotate functions per BPP */ -GP_DEF_FFN_PER_BPP(GP_RotateCW, DEF_ROTATECW_FN) - -GP_RetCode GP_RotateCW(GP_Context *context) +void GP_FilterRotate_Raw(const GP_Context *src, GP_Context *dst, + GP_FilterRotation rotation, + GP_ProgressCallback *callback) { - if (context == NULL) - return GP_ENULLPTR; - - GP_FN_RET_PER_BPP_CONTEXT(GP_RotateCW, context, context); - - return GP_ENOIMPL; + 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; + } }
-/* Generate Rotate functions per BPP */ -GP_DEF_FFN_PER_BPP(GP_RotateCCW, DEF_ROTATECCW_FN) - -GP_RetCode GP_RotateCCW(GP_Context *context) +GP_Context *GP_FilterRotate(const GP_Context *context, + GP_FilterRotation rotation, + GP_ProgressCallback *callback) { - if (context == NULL) - return GP_ENULLPTR; + 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; + } + + GP_Context *ret = GP_ContextAlloc(w, h, context->pixel_type); + + if (unlikely(ret == NULL)) { + GP_DEBUG(1, "Malloc failed :("); + return NULL; + }
- GP_FN_RET_PER_BPP_CONTEXT(GP_RotateCCW, context, context); + GP_FilterRotate_Raw(context, ret, rotation, callback);
- return GP_ENOIMPL; + return ret; } diff --git a/libs/filters/GP_Rotate.gen.c.t b/libs/filters/GP_Rotate.gen.c.t new file mode 100644 index 0000000..9ef7bd9 --- /dev/null +++ b/libs/filters/GP_Rotate.gen.c.t @@ -0,0 +1,71 @@ +%% extends "base.c.t" + +%% block descr +Vertical Mirror alogorithm +%% endblock + +%% block body + +#include "core/GP_Debug.h" +#include "core/GP_GetPutPixel.h" +#include "GP_Rotate.h" + +%% for ps in pixelsizes +void GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + uint32_t x, y; + + GP_DEBUG(1, "Rotating image by 90 %ux%u", src->w, src->h); + + for (x = 0; x < src->w; x++) { + for (y = 0; y < src->h; y++) { + uint32_t yr = src->h - y - 1; + GP_PutPixel_Raw_{{ ps.suffix }}(dst, yr, x, GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y)); + } + + if (callback != NULL && x % 100 == 0) + GP_ProgressCallbackReport(callback, 100.00 * x / src->w); + } + + GP_ProgressCallbackDone(callback); +} + +%% endfor + +void GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + GP_FN_PER_BPP_CONTEXT(GP_FilterRotate90_Raw, src, src, dst, callback); +} + +%% for ps in pixelsizes +void GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + uint32_t x, y; + + GP_DEBUG(1, "Rotating image by 270 %ux%u", src->w, src->h); + + for (x = 0; x < src->w; x++) { + for (y = 0; y < src->h; y++) { + uint32_t xr = src->w - x - 1; + GP_PutPixel_Raw_{{ ps.suffix }}(dst, y, xr, GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y)); + } + + if (callback != NULL && x % 100 == 0) + GP_ProgressCallbackReport(callback, 100.00 * x / src->w); + } + + GP_ProgressCallbackDone(callback); +} + +%% endfor + +void GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + GP_FN_PER_BPP_CONTEXT(GP_FilterRotate270_Raw, src, src, dst, callback); +} + +%% endblock body diff --git a/libs/filters/Makefile b/libs/filters/Makefile index bd5ed37..8133fb0 100644 --- a/libs/filters/Makefile +++ b/libs/filters/Makefile @@ -1,5 +1,6 @@ TOPDIR=../.. -GENSOURCES=GP_Brightness.gen.c GP_Contrast.gen.c GP_Invert.gen.c +GENSOURCES=GP_Brightness.gen.c GP_Contrast.gen.c GP_Invert.gen.c+ GP_MirrorV.gen.c GP_Rotate.gen.c GENHEADERS= CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) LIBNAME=filters diff --git a/libs/filters/algo/GP_MirrorV.algo.h b/libs/filters/algo/GP_MirrorV.algo.h deleted file mode 100644 index 6555700..0000000 --- a/libs/filters/algo/GP_MirrorV.algo.h +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - - -#define DEF_MIRRORV_FN(FN_NAME, CONTEXT_T, PIXEL_T, PUTPIXEL, GETPIXEL) -void FN_NAME(CONTEXT_T context) -{ - uint32_t x, y; - PIXEL_T tmp; -- for (x = 0; x < context->w/2; x++) { - uint32_t xm = context->w - x - 1; - for (y = 0; y < context->h; y++) { - tmp = GETPIXEL(context, x, y); -- PUTPIXEL(context, x, y, GETPIXEL(context, xm, y)); - PUTPIXEL(context, xm, y, tmp); - } - } -} diff --git a/libs/filters/algo/GP_Rotate.algo.h b/libs/filters/algo/GP_Rotate.algo.h deleted file mode 100644 index bc7528d..0000000 --- a/libs/filters/algo/GP_Rotate.algo.h +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include "core/GP_Common.h" -#include "core/GP_Context.h" - -#define DEF_ROTATECW_FN(FN_NAME, CONTEXT_T, PIXEL_T, PUTPIXEL, GETPIXEL) -GP_RetCode FN_NAME(CONTEXT_T context) -{ - uint32_t x, y; - CONTEXT_T tmp; -- tmp = GP_ContextCopy(context, GP_COPY_WITH_PIXELS); -- if (tmp == NULL) - return GP_ENOMEM; -- GP_SWAP(context->w, context->h); -- context->bytes_per_row = GP_CALC_ROW_SIZE(context->pixel_type, - context->w); -- for (x = 0; x < tmp->w; x++) { - for (y = 0; y < tmp->h; y++) { - uint32_t yr = tmp->h - y - 1; - PUTPIXEL(context, yr, x, GETPIXEL(tmp, x, y)); - } - } -- GP_ContextFree(tmp); -- return GP_ESUCCESS; -} - -#define DEF_ROTATECCW_FN(FN_NAME, CONTEXT_T, PIXEL_T, PUTPIXEL, GETPIXEL) -GP_RetCode FN_NAME(CONTEXT_T context) -{ - uint32_t x, y; - CONTEXT_T tmp; -- tmp = GP_ContextCopy(context, GP_COPY_WITH_PIXELS); -- if (tmp == NULL) - return GP_ENOMEM; -- GP_SWAP(context->w, context->h); -- context->bytes_per_row = GP_CALC_ROW_SIZE(context->pixel_type, - context->w); -- for (x = 0; x < tmp->w; x++) { - for (y = 0; y < tmp->h; y++) { - uint32_t xr = tmp->w - x - 1; - PUTPIXEL(context, y, xr, GETPIXEL(tmp, x, y)); - } - } -- GP_ContextFree(tmp); -- return GP_ESUCCESS; -}
http://repo.or.cz/w/gfxprim.git/commit/a8f1ba07c9863cdda6b55a7b82fb35fbe5575...
commit a8f1ba07c9863cdda6b55a7b82fb35fbe55758a9 Author: Cyril Hrubis metan@ucw.cz Date: Thu Oct 27 21:06:31 2011 +0200
Add missing linker flag.
diff --git a/tests/drivers/Makefile b/tests/drivers/Makefile index 664900d..28ea051 100644 --- a/tests/drivers/Makefile +++ b/tests/drivers/Makefile @@ -1,4 +1,4 @@ -LDFLAGS=-L../../build/ -lGP -lpng -ldl +LDFLAGS=-L../../build/ -lGP -lpng -ldl -ljpeg INCLUDE=-I../../include # Some warnings are triggered only with -O2 # thuss added here
http://repo.or.cz/w/gfxprim.git/commit/bcaa19c8129a6bcaac8a3640979e91135c016...
commit bcaa19c8129a6bcaac8a3640979e91135c016846 Author: Cyril Hrubis metan@ucw.cz Date: Thu Oct 27 16:40:09 2011 +0000
Add context offset.
This is first step for subcontexes for non byte alignes pixel types.
diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h index 6bc244c..00138df 100644 --- a/include/core/GP_Context.h +++ b/include/core/GP_Context.h @@ -36,10 +36,16 @@ /* This structure holds all information needed for drawing into an image. */ typedef struct GP_Context { uint8_t *pixels; /* pointer to image pixels */ - uint8_t bpp; /* values: 1, 2, 4, 8, 16, 24, 32 */ + uint8_t bpp; /* pixel length in bits */ uint32_t bytes_per_row; uint32_t w; /* width in pixels */ uint32_t h; /* height in pixels */ + /* + * Row bit offset. The offset is ignored for byte aligned pixels. + * Basically it's used for non aligned pixels with combination + * with subcontextes. + */ + uint8_t offset;
GP_PixelType pixel_type; /* hardware pixel format */
diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h index 599da1d..0cd7661 100644 --- a/include/core/GP_GetPutPixel.h +++ b/include/core/GP_GetPutPixel.h @@ -67,4 +67,9 @@ static inline void GP_PutPixel_Raw(GP_Context *context, int x, int y, context, x, y, p); }
+/* + * Returns pixel offset. + */ +uint8_t GP_PixelAddrOffset(GP_Coord x, GP_PixelType pixel_type); + #endif /* CORE_GP_GETPUTPIXEL_H */ diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c index 0ce6342..83c9f73 100644 --- a/libs/core/GP_Context.c +++ b/libs/core/GP_Context.c @@ -52,6 +52,7 @@ GP_Context *GP_ContextCopy(const GP_Context *src, int flag)
new->bpp = src->bpp; new->bytes_per_row = src->bytes_per_row; + new->offset = 0;
new->w = src->w; new->h = src->h; @@ -66,7 +67,6 @@ GP_Context *GP_ContextCopy(const GP_Context *src, int flag) new->free_pixels = 1;
return new; - }
GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type) @@ -87,6 +87,7 @@ GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type) context->pixels = pixels; context->bpp = bpp; context->bytes_per_row = bpr; + context->offset = 0;
context->w = w; context->h = h; @@ -140,6 +141,8 @@ GP_Context *GP_ContextSubContext(GP_Context *context, GP_Coord x, GP_Coord y,
ret->bpp = context->bpp; ret->bytes_per_row = context->bytes_per_row; + ret->offset = (context->offset + + GP_PixelAddrOffset(x, context->pixel_type)) % 8;
ret->w = w; ret->h = h; @@ -169,7 +172,7 @@ GP_RetCode GP_ContextDump(GP_Context *context, const char *path) for (y = 0; y < context->h; y++) { for (x = 0; x < context->bytes_per_row; x++) fprintf(f, "0x%02x ", ((uint8_t *)context->pixels) - [y * context->bytes_per_row + x]); + [y * context->bytes_per_row + x]); fprintf(f, "n"); }
diff --git a/libs/core/GP_GetPutPixel.c b/libs/core/GP_GetPutPixel.c index 774be54..6550275 100644 --- a/libs/core/GP_GetPutPixel.c +++ b/libs/core/GP_GetPutPixel.c @@ -37,3 +37,10 @@ void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel p) if (!GP_PIXEL_IS_CLIPPED(context, x, y)) GP_PutPixel_Raw(context, x, y, p); } + +uint8_t GP_PixelAddrOffset(GP_Coord x, GP_PixelType pixel_type) +{ + GP_FN_RET_PER_BPP_PIXELTYPE(GP_PIXEL_ADDR_OFFSET, pixel_type, x); + + return 0; +} diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c index 98dc0d0..bedaf14 100644 --- a/libs/core/GP_Pixel.c +++ b/libs/core/GP_Pixel.c @@ -28,8 +28,8 @@ #include "GP_Debug.h" #include "GP_Pixel.h"
-static const GP_PixelTypeChannel *get_channel(const GP_PixelTypeDescription *desc, - const char *name) +static const GP_PixelTypeChannel * +get_channel(const GP_PixelTypeDescription *desc, const char *name) { unsigned int i;
@@ -115,8 +115,9 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff, { unsigned int i; - GP_DEBUG(1, "Looking up Pixel R %08x %08x G %08x %08x B %08x %08x size %u", - rsize, roff, gsize, goff, bsize, boff, bits_per_pixel); + GP_DEBUG(1, "Looking up Pixel R %08x %08x G %08x %08x B %08x %08x " + "size %u", rsize, roff, gsize, goff, bsize, boff, + bits_per_pixel);
for (i = 0; i < GP_PIXEL_MAX; i++) { const GP_PixelTypeChannel *r, *g, *b, *a;
http://repo.or.cz/w/gfxprim.git/commit/828d02ecb1948597d7f7b83e86f15e7bb7ca9...
commit 828d02ecb1948597d7f7b83e86f15e7bb7ca9164 Author: Cyril Hrubis metan@ucw.cz Date: Thu Oct 27 16:02:32 2011 +0000
Remove (hopefuly) last function with T prefix.
diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h index 9d9b7be..599da1d 100644 --- a/include/core/GP_GetPutPixel.h +++ b/include/core/GP_GetPutPixel.h @@ -57,13 +57,6 @@ static inline GP_Pixel GP_GetPixel_Raw(const GP_Context *context, int x, int y) */ void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel p);
-//TODO: This is the same as GP_PutPixel -static inline void GP_TPutPixel(GP_Context *context, GP_Coord x, GP_Coord y, - GP_Pixel p) -{ - GP_PutPixel(context, x, y, p); -} - /* * Version of PutPixel without transformations nor border checking. */
-----------------------------------------------------------------------
Summary of changes: demos/grinder/grinder.c | 44 +++++++++++++-- demos/grinder/params.c | 39 +++++++++++++- include/core/GP_Context.h | 8 ++- include/core/GP_GetPutPixel.h | 12 ++-- include/filters/GP_Rotate.h | 83 ++++++++++++++++++++++----- libs/core/GP_Context.c | 7 ++- libs/core/GP_GetPutPixel.c | 7 ++ libs/core/GP_Pixel.c | 9 ++- libs/filters/GP_MirrorV.gen.c.t | 44 +++++++++++++++ libs/filters/GP_Rotate.c | 105 ++++++++++++++++++++-------------- libs/filters/GP_Rotate.gen.c.t | 71 +++++++++++++++++++++++ libs/filters/Makefile | 3 +- libs/filters/algo/GP_MirrorV.algo.h | 42 -------------- libs/filters/algo/GP_Rotate.algo.h | 83 --------------------------- tests/drivers/Makefile | 2 +- 15 files changed, 352 insertions(+), 207 deletions(-) create mode 100644 libs/filters/GP_MirrorV.gen.c.t create mode 100644 libs/filters/GP_Rotate.gen.c.t delete mode 100644 libs/filters/algo/GP_MirrorV.algo.h delete mode 100644 libs/filters/algo/GP_Rotate.algo.h
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.