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 5d9d976eb5371267bad2e285f6de5f02712ce86b (commit) via fe168a48fb444c9bccacd07549bda653bf91cbdb (commit) from 5885e81e95f27117da33f1b68cdd7a88c3fad9c6 (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/5d9d976eb5371267bad2e285f6de5f02712ce...
commit 5d9d976eb5371267bad2e285f6de5f02712ce86b Author: Cyril Hrubis metan@ucw.cz Date: Mon Nov 11 00:08:23 2013 +0100
gfx: GP_FillRect: Check y coords for context intersection.
This optimizes cases where y coordinate is out of the context.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/gfx/GP_Rect.c b/libs/gfx/GP_Rect.c index be07b8b..618c788 100644 --- a/libs/gfx/GP_Rect.c +++ b/libs/gfx/GP_Rect.c @@ -75,6 +75,9 @@ void GP_FillRectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, if (y0 > y1) GP_SWAP(y0, y1);
+ y0 = GP_MAX(0, y0); + y1 = GP_MIN(y1, (GP_Coord)context->h - 1); + GP_Coord y; for (y = y0; y <= y1; y++) GP_HLine_Raw(context, x0, x1, y, pixel); @@ -97,7 +100,7 @@ void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1);
- GP_FillRect_Raw(context, x0, y0, x1, y1, pixel); + GP_FillRectXYXY_Raw(context, x0, y0, x1, y1, pixel); }
void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
http://repo.or.cz/w/gfxprim.git/commit/fe168a48fb444c9bccacd07549bda653bf91c...
commit fe168a48fb444c9bccacd07549bda653bf91cbdb Author: Cyril Hrubis metan@ucw.cz Date: Sun Nov 10 23:47:39 2013 +0100
test: gfx: Add test for FillRect.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/gfx/FillRect.c b/tests/gfx/FillRect.c new file mode 100644 index 0000000..bd30ad5 --- /dev/null +++ b/tests/gfx/FillRect.c @@ -0,0 +1,326 @@ +/***************************************************************************** + * 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-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <string.h> +#include <errno.h> +#include <sys/stat.h> + +#include <core/GP_Context.h> +#include <gfx/GP_Rect.h> + +#include "tst_test.h" + +#include "common.h" + +struct testcase { + /* rect description */ + GP_Coord x1; + GP_Coord y1; + GP_Coord x2; + GP_Coord y2; + + /* expected result */ + GP_Size w, h; + const char pixmap[]; +}; + +static int test_rect(const struct testcase *t) +{ + GP_Context *c; + int err; + + c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + + if (c == NULL) { + tst_err("Failed to allocate context"); + return TST_UNTESTED; + } + + /* zero the pixels buffer */ + memset(c->pixels, 0, c->w * c->h); + + GP_FillRect(c, t->x1, t->y1, t->x2, t->y2, 1); + + err = compare_buffers(t->pixmap, c); + + if (err) + return TST_FAILED; + + return TST_SUCCESS; +} + +struct testcase testcase_rect_1 = { + .x1 = 2, + .y1 = 2, + .x2 = 2, + .y2 = 2, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_rect_9a = { + .x1 = 1, + .y1 = 1, + .x2 = 3, + .y2 = 3, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 1, 1, 1, 0, + 0, 1, 1, 1, 0, + 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_rect_9b = { + .x1 = 3, + .y1 = 3, + .x2 = 1, + .y2 = 1, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 1, 1, 1, 0, + 0, 1, 1, 1, 0, + 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_rect_9lu = { + .x1 = -2147483648, + .y1 = -2147483648, + .x2 = 2, + .y2 = 2, + + .w = 5, + .h = 5, + + .pixmap = { + 1, 1, 1, 0, 0, + 1, 1, 1, 0, 0, + 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_rect_9ld = { + .x1 = -2147483648, + .y1 = 2, + .x2 = 2, + .y2 = 2147483647, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, + 1, 1, 1, 0, 0, + 1, 1, 1, 0, 0, + } +}; + +struct testcase testcase_rect_9ru = { + .x1 = 2, + .y1 = -2147483648, + .x2 = 2147483647, + .y2 = 2, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 1, 1, 1, + 0, 0, 1, 1, 1, + 0, 0, 1, 1, 1, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_rect_9rd = { + .x1 = 2, + .y1 = 2, + .x2 = 2147483647, + .y2 = 2147483647, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, + 0, 0, 1, 1, 1, + 0, 0, 1, 1, 1, + } +}; + +struct testcase testcase_rect_9r = { + .x1 = -2147483648, + .y1 = 3, + .x2 = 2, + .y2 = 1, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, + 1, 1, 1, 0, 0, + 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_rect_9l = { + .x1 = 2, + .y1 = 3, + .x2 = 2147483647, + .y2 = 1, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, + 0, 0, 1, 1, 1, + 0, 0, 1, 1, 1, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_rect_9u = { + .x1 = 1, + .y1 = -2147483648, + .x2 = 3, + .y2 = 2, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 1, 1, 1, 0, + 0, 1, 1, 1, 0, + 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_rect_9d = { + .x1 = 1, + .y1 = 2, + .x2 = 3, + .y2 = 2147483647, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 1, 1, 1, 0, + 0, 1, 1, 1, 0, + 0, 1, 1, 1, 0, + } +}; + +const struct tst_suite tst_suite = { + .suite_name = "FillRect Testsuite", + .tests = { + {.name = "FillRect x1=x2 y1=y2", + .tst_fn = test_rect, + .data = &testcase_rect_1}, + + {.name = "FillRect x1<x2 y1<y2", + .tst_fn = test_rect, + .data = &testcase_rect_9a}, + + {.name = "FillRect x1>x2 y1>y2", + .tst_fn = test_rect, + .data = &testcase_rect_9b}, + + {.name = "FillRect x1,y1 out of context", + .tst_fn = test_rect, + .data = &testcase_rect_9lu, + .timeout = 2}, + + {.name = "FillRect x1,y2 out of context", + .tst_fn = test_rect, + .data = &testcase_rect_9ld, + .timeout = 2}, + + {.name = "FillRect x2,y1 out of context", + .tst_fn = test_rect, + .data = &testcase_rect_9ru, + .timeout = 2}, + + {.name = "FillRect x2,y2 out of context", + .tst_fn = test_rect, + .data = &testcase_rect_9rd, + .timeout = 2}, + + {.name = "FillRect x1 out of context", + .tst_fn = test_rect, + .data = &testcase_rect_9r, + .timeout = 2}, + + {.name = "FillRect x2 out of context", + .tst_fn = test_rect, + .data = &testcase_rect_9l, + .timeout = 2}, + + {.name = "FillRect y1 out of context", + .tst_fn = test_rect, + .data = &testcase_rect_9u, + .timeout = 2}, + + {.name = "FillRect y2 out of context", + .tst_fn = test_rect, + .data = &testcase_rect_9d, + .timeout = 2}, + + {.name = NULL} + } +}; diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile index 2094107..c93bf99 100644 --- a/tests/gfx/Makefile +++ b/tests/gfx/Makefile @@ -5,7 +5,7 @@ CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) GENSOURCES=APICoverage.gen.c
APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse HLine- VLine PutPixelAA HLineAA LineAA APICoverage.gen FillEllipse + VLine PutPixelAA HLineAA LineAA APICoverage.gen FillEllipse FillRect
Circle: common.o FillCircle: common.o @@ -19,6 +19,7 @@ VLine: common.o PutPixelAA: common.o HLineAA: common.o LineAA: common.o +FillRect: common.o
include ../tests.mk
diff --git a/tests/gfx/test_list.txt b/tests/gfx/test_list.txt index ff64600..b801c5b 100644 --- a/tests/gfx/test_list.txt +++ b/tests/gfx/test_list.txt @@ -11,6 +11,7 @@ Ellipse FillEllipse CircleSeg Polygon +FillRect
PutPixelAA HLineAA
-----------------------------------------------------------------------
Summary of changes: libs/gfx/GP_Rect.c | 5 +- tests/gfx/FillRect.c | 326 +++++++++++++++++++++++++++++++++++++++++++++++ tests/gfx/Makefile | 3 +- tests/gfx/test_list.txt | 1 + 4 files changed, 333 insertions(+), 2 deletions(-) create mode 100644 tests/gfx/FillRect.c
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.