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 5fb7aa901f930330ad55c1441a96869424d3c3c7 (commit) via 1f78ab9179ac3d887fea911e05418de46be3bbfe (commit) via 8cc879f18c8ac80554a923ed3c4d7587402d974a (commit) from ff0706d61e00ba22fcb83e4902461b1832ab1023 (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/5fb7aa901f930330ad55c1441a96869424d3c...
commit 5fb7aa901f930330ad55c1441a96869424d3c3c7 Author: Cyril Hrubis metan@ucw.cz Date: Wed Oct 31 19:18:00 2012 +0100
gfx: algo: Fix negative and zero radius for CircleSeg.
diff --git a/libs/gfx/algo/CircleSeg.algo.h b/libs/gfx/algo/CircleSeg.algo.h index dc176a3..0b3931b 100644 --- a/libs/gfx/algo/CircleSeg.algo.h +++ b/libs/gfx/algo/CircleSeg.algo.h @@ -74,10 +74,21 @@ * FN_NAME - name of the function to be defined */ #define DEF_CIRCLE_SEG_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) -void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, unsigned int r, +void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int r, uint8_t seg_flags, PIXVAL_T pixval) { int x, y, error; ++ /* Special case for r == 0 */ + if (r == 0) { + if (seg_flags) + PUTPIXEL(context, xcenter, ycenter, pixval); + return; + } ++ /* Clip negative r */ + r = r < 0 ? -r : r; + for (x = 0, error = -r, y = r; y >= 0; y--) { /* Iterate X until we can pass to the next line. */ http://repo.or.cz/w/gfxprim.git/commit/1f78ab9179ac3d887fea911e05418de46be3b...
commit 1f78ab9179ac3d887fea911e05418de46be3bbfe Author: Cyril Hrubis metan@ucw.cz Date: Wed Oct 31 19:17:39 2012 +0100
tests: gfx: Add tests for CircleSeg.
diff --git a/tests/gfx/CircleSeg.c b/tests/gfx/CircleSeg.c new file mode 100644 index 0000000..69767ec --- /dev/null +++ b/tests/gfx/CircleSeg.c @@ -0,0 +1,257 @@ +/***************************************************************************** + * 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-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <string.h> +#include <errno.h> +#include <sys/stat.h> + +#include <core/GP_Context.h> +#include <gfx/GP_CircleSeg.h> + +#include "tst_test.h" + +#include "common.h" + +static const char circle_empty_11x11[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char circle_r_0_11x11[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char circle_r_1_s_3_11x11[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char circle_r_1_s_4_11x11[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char circle_r_2_s_1_2_11x11[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, +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0, 0, 0, 0, 0, 0, +}; + +static int test_circle(const char *pattern, GP_Size w, GP_Size h, + GP_Coord x, GP_Coord y, const int r, uint8_t seg_flag) +{ + GP_Context *c; + int err; + + c = GP_ContextAlloc(w, h, GP_PIXEL_G8); + + if (c == NULL) { + tst_report(0, "Failed to allocate context"); + return TST_UNTESTED; + } + + /* zero the pixels buffer */ + memset(c->pixels, 0, c->w * c->h); + + GP_CircleSeg(c, x, y, r, seg_flag, 1); + + err = compare_buffers(pattern, c); + + if (err) { + tst_report(0, "Patterns are different"); + return TST_FAILED; + } + + return TST_SUCCESS; +} + +static int test_circle_r_0_s_1(void) +{ + return test_circle(circle_r_0_11x11, 11, 11, 5, 5, 0, GP_CIRCLE_SEG1); +} + +static int test_circle_r_0_s_0(void) +{ + return test_circle(circle_empty_11x11, 11, 11, 5, 5, 0, 0); +} + +static int test_circle_r_1_s_1(void) +{ + return test_circle(circle_r_1_s_1_11x11, 11, 11, 5, 5, 1, GP_CIRCLE_SEG1); +} + +static int test_circle_r_1_s_2(void) +{ + return test_circle(circle_r_1_s_2_11x11, 11, 11, 5, 5, 1, GP_CIRCLE_SEG2); +} + +static int test_circle_r_1_s_3(void) +{ + return test_circle(circle_r_1_s_3_11x11, 11, 11, 5, 5, 1, GP_CIRCLE_SEG3); +} + +static int test_circle_r_1_s_4(void) +{ + return test_circle(circle_r_1_s_4_11x11, 11, 11, 5, 5, 1, GP_CIRCLE_SEG4); +} + +static int test_circle_r_2_s_1_2(void) +{ + return test_circle(circle_r_2_s_1_2_11x11, 11, 11, 5, 5, 2, + GP_CIRCLE_SEG1|GP_CIRCLE_SEG2); +} + +static int test_circle_r_2_s_1_3(void) +{ + return test_circle(circle_r_2_s_1_3_11x11, 11, 11, 5, 5, 2, + GP_CIRCLE_SEG1|GP_CIRCLE_SEG3); +} + +static int test_circle_r_2_s_1_4(void) +{ + return test_circle(circle_r_2_s_1_4_11x11, 11, 11, 5, 5, 2, + GP_CIRCLE_SEG1|GP_CIRCLE_SEG4); +} + +static int test_circle_r__2_s_1_3(void) +{ + return test_circle(circle_r_2_s_1_3_11x11, 11, 11, 5, 5, -2, + GP_CIRCLE_SEG1|GP_CIRCLE_SEG3); +} + +const struct tst_suite tst_suite = { + .suite_name = "GFX CircleSeg Testsuite", + .tests = { + {.name = "CircleSeg Seg0 r=0", .tst_fn = test_circle_r_0_s_0}, + {.name = "CircleSeg Seg1 r=0", .tst_fn = test_circle_r_0_s_1}, + {.name = "CircleSeg Seg1 r=1", .tst_fn = test_circle_r_1_s_1}, + {.name = "CircleSeg Seg2 r=1", .tst_fn = test_circle_r_1_s_2}, + {.name = "CircleSeg Seg3 r=1", .tst_fn = test_circle_r_1_s_3}, + {.name = "CircleSeg Seg4 r=1", .tst_fn = test_circle_r_1_s_4}, + {.name = "CircleSeg Seg1|2 r=2", .tst_fn = test_circle_r_2_s_1_2}, + {.name = "CircleSeg Seg1|3 r=2", .tst_fn = test_circle_r_2_s_1_3}, + {.name = "CircleSeg Seg1|4 r=2", .tst_fn = test_circle_r_2_s_1_4}, + {.name = "CircleSeg Seg1|3 r=-2", .tst_fn = test_circle_r__2_s_1_3}, + {.name = NULL} + } +}; diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile index aa601b9..4cbf36a 100644 --- a/tests/gfx/Makefile +++ b/tests/gfx/Makefile @@ -3,9 +3,10 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=gfx_benchmark Circle +APPS=gfx_benchmark Circle CircleSeg
Circle: common.o +CircleSeg: common.o
include ../tests.mk
diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh index 6761955..e9ba8ef 100755 --- a/tests/gfx/runtest.sh +++ b/tests/gfx/runtest.sh @@ -11,3 +11,4 @@ export LIBC_FATAL_STDERR_=1
#LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./CircleSeg "$@"
http://repo.or.cz/w/gfxprim.git/commit/8cc879f18c8ac80554a923ed3c4d7587402d9...
commit 8cc879f18c8ac80554a923ed3c4d7587402d974a Author: Cyril Hrubis metan@ucw.cz Date: Wed Oct 31 18:46:33 2012 +0100
tests: gfx: Move common code to file.
diff --git a/tests/gfx/Circle.c b/tests/gfx/Circle.c index 0482e99..d159632 100644 --- a/tests/gfx/Circle.c +++ b/tests/gfx/Circle.c @@ -29,6 +29,8 @@
#include "tst_test.h"
+#include "common.h" + static const char circle_r_0_11x11[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -99,45 +101,6 @@ static const char circle_r_5_half_11x11[] = { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, };
-static void dump_buffer(const char *pattern, int x, int y) -{ - int i, j; - - for (i = 0; i < y; i++) { - for (j = 0; j < x; j++) - printf("%2x ", pattern[j + i * y]); - printf("n"); - } -} - -static void dump_buffers(const char *pattern, const GP_Context *c) -{ - printf("Expected patternn"); - dump_buffer(pattern, c->w, c->h); - printf("Rendered patternn"); - dump_buffer((char*)c->pixels, c->w, c->h); -} - -static int compare_buffers(const char *pattern, const GP_Context *c) -{ - GP_Size x, y; - int err = 0; - - for (x = 0; x < c->w; x++) { - for (y = 0; y < c->h; y++) { - if (pattern[x + y * c->h] != - ((char*)c->pixels)[x + y * c->h]) { - err++; - } - } - } - - if (err) - dump_buffers(pattern, c); - - return err; -} - static int test_circle(const char *pattern, GP_Size w, GP_Size h, GP_Coord x, GP_Coord y, const int r) { diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile index 15c1984..aa601b9 100644 --- a/tests/gfx/Makefile +++ b/tests/gfx/Makefile @@ -5,6 +5,8 @@ CSOURCES=$(shell echo *.c)
APPS=gfx_benchmark Circle
+Circle: common.o + include ../tests.mk
include $(TOPDIR)/app.mk diff --git a/tests/gfx/common.c b/tests/gfx/common.c new file mode 100644 index 0000000..d261dfd --- /dev/null +++ b/tests/gfx/common.c @@ -0,0 +1,64 @@ +/***************************************************************************** + * 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-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <stdio.h> + +#include "common.h" + +static void dump_buffer(const char *pattern, int x, int y) +{ + int i, j; + + for (i = 0; i < y; i++) { + for (j = 0; j < x; j++) + printf("%2x ", pattern[j + i * y]); + printf("n"); + } +} + +void dump_buffers(const char *pattern, const GP_Context *c) +{ + printf("Expected patternn"); + dump_buffer(pattern, c->w, c->h); + printf("Rendered patternn"); + dump_buffer((char*)c->pixels, c->w, c->h); +} + +int compare_buffers(const char *pattern, const GP_Context *c) +{ + GP_Size x, y; + int err = 0; + + for (x = 0; x < c->w; x++) { + for (y = 0; y < c->h; y++) { + if (pattern[x + y * c->h] != + ((char*)c->pixels)[x + y * c->h]) { + err++; + } + } + } + + if (err) + dump_buffers(pattern, c); + + return err; +} diff --git a/tests/gfx/common.h b/tests/gfx/common.h new file mode 100644 index 0000000..65b9d19 --- /dev/null +++ b/tests/gfx/common.h @@ -0,0 +1,32 @@ +/***************************************************************************** + * 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-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#include <core/GP_Context.h> + +void dump_buffers(const char *pattern, const GP_Context *c); + +int compare_buffers(const char *pattern, const GP_Context *c); + +#endif /* __COMMON_H__ */
-----------------------------------------------------------------------
Summary of changes: libs/gfx/algo/CircleSeg.algo.h | 13 +- tests/gfx/Circle.c | 41 +--- tests/gfx/CircleSeg.c | 257 ++++++++++++++++++++ tests/gfx/Makefile | 5 +- .../loaders_example.c => tests/gfx/common.c | 59 +++--- include/input/GP_Input.h => tests/gfx/common.h | 15 +- tests/gfx/runtest.sh | 1 + 7 files changed, 315 insertions(+), 76 deletions(-) create mode 100644 tests/gfx/CircleSeg.c copy demos/c_simple/loaders_example.c => tests/gfx/common.c (70%) copy include/input/GP_Input.h => tests/gfx/common.h (88%)
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.