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 1d8b9f67ffd1b38ef96f2b19ced13fba548c6fcb (commit) from d4b06d880a619f82d52e6de8dafddd36f84b76ac (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/1d8b9f67ffd1b38ef96f2b19ced13fba548c6...
commit 1d8b9f67ffd1b38ef96f2b19ced13fba548c6fcb Author: Cyril Hrubis metan@ucw.cz Date: Fri Jan 25 22:58:13 2013 +0100
gfx: Add tests and fix Anti Aliased PutPixel/HLine.
diff --git a/include/gfx/GP_HLineAA.h b/include/gfx/GP_HLineAA.h index 6889840..b253ae2 100644 --- a/include/gfx/GP_HLineAA.h +++ b/include/gfx/GP_HLineAA.h @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -38,7 +38,8 @@ #include "core/GP_Context.h"
/* - * Anti Aliased Horizontal Line respecting context rotation flags and with clipping. + * Anti Aliased Horizontal Line respecting context rotation flags and with + * clipping. */ void GP_HLineAA(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel); diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t index c08f68b..dac3b8d 100644 --- a/libs/gfx/GP_HLineAA.gen.c.t +++ b/libs/gfx/GP_HLineAA.gen.c.t @@ -1,3 +1,25 @@ +/***************************************************************************** + * 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 * + * * + *****************************************************************************/ + %% extends "base.c.t"
{% block descr %}Anti Aliased Horizontal Line{% endblock %} @@ -11,48 +33,60 @@
#define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255))
+/* + * Computes pixel in buffer that we should start drawing in. + * + * This is different at the start and the end of the HLine. The difference is + * in where do integer coordinates belong (gfxprim puts integer coordinates in + * the middle of pixels this is where the +1/2 comes from. + */ +#define TO_X_S(x) GP_FP_FLOOR_TO_INT((x) + GP_FP_1_2) +#define TO_X_E(x) GP_FP_CEIL_TO_INT((x) - GP_FP_1_2) + void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { + /* Nothing to draw */ + if (x0 == x1) + return; + if (x1 < x0) GP_SWAP(x1, x0); - x0 -= GP_FP_1_2; - x1 += GP_FP_1_2; - y -= GP_FP_1_2; + GP_Coord int_x0 = TO_X_S(x0); + GP_Coord int_x1 = TO_X_E(x1); + GP_Coord int_y = GP_FP_FLOOR_TO_INT(y);
- GP_Coord int_x0 = GP_FP_TO_INT(x0); - GP_Coord int_x1 = GP_FP_TO_INT(x1); - GP_Coord int_y = GP_FP_TO_INT(y); + printf("%f %f %f -> %i %i %in", GP_FP_TO_FLOAT(x0), GP_FP_TO_FLOAT(x1), GP_FP_TO_FLOAT(y), int_x0, int_x1, int_y);
- /* Line is shorter than two pixels */ - if (int_x0 == int_x1) { - //TODO - return; - } - - /* Draw the starting and ending pixel */ - uint8_t perc; + /* Draw the four starting and ending pixels */ + unsigned int perc; + unsigned int w; - perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), GP_FP_RFRAC(x0))); + w = GP_FP_RFRAC(x0 + GP_FP_1_2); + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), w)); GP_MixPixel_Raw_Clipped(context, int_x0, int_y, pixel, perc);
- perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), GP_FP_RFRAC(x0))); + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), w)); GP_MixPixel_Raw_Clipped(context, int_x0, int_y+1, pixel, perc); - - - perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), GP_FP_FRAC(x1))); - GP_MixPixel_Raw_Clipped(context, int_x1, int_y, pixel, perc);
- perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), GP_FP_FRAC(x1))); - GP_MixPixel_Raw_Clipped(context, int_x1, int_y+1, pixel, perc); + if (int_x0 != int_x1) { + w = GP_FP_RFRAC(x0 + GP_FP_1_2);
- /* Draw the middle pixels */ - uint8_t up = FP_TO_PERC(GP_FP_RFRAC(y)); - uint8_t lp = FP_TO_PERC(GP_FP_FRAC(y)); + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), w)); + GP_MixPixel_Raw_Clipped(context, int_x1, int_y, pixel, perc); + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), w)); + GP_MixPixel_Raw_Clipped(context, int_x1, int_y+1, pixel, perc); + }
GP_Coord x; + /* Now fill the inner part of the HLine */ + uint8_t up = FP_TO_PERC(GP_FP_RFRAC(y)); + uint8_t lp = FP_TO_PERC(GP_FP_FRAC(y)); + for (x = int_x0 + 1; x < int_x1; x++) { GP_MixPixel_Raw_Clipped(context, x, int_y, pixel, up); GP_MixPixel_Raw_Clipped(context, x, int_y+1, pixel, lp); diff --git a/libs/gfx/GP_PutPixelAA.gen.c.t b/libs/gfx/GP_PutPixelAA.gen.c.t index c7eeefe..da47d7a 100644 --- a/libs/gfx/GP_PutPixelAA.gen.c.t +++ b/libs/gfx/GP_PutPixelAA.gen.c.t @@ -1,3 +1,25 @@ +/***************************************************************************** + * 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 * + * * + *****************************************************************************/ + %% extends "base.c.t"
{% block descr %}Anti Aliased Put Pixel{% endblock %} @@ -17,8 +39,6 @@ void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel pixel) { - x -= GP_FP_1_2; - y -= GP_FP_1_2; GP_Coord int_x = GP_FP_TO_INT(x); GP_Coord int_y = GP_FP_TO_INT(y); GP_Coord frac_x = GP_FP_FRAC(x); diff --git a/tests/gfx/HLineAA.c b/tests/gfx/HLineAA.c new file mode 100644 index 0000000..d0f8656 --- /dev/null +++ b/tests/gfx/HLineAA.c @@ -0,0 +1,325 @@ +/***************************************************************************** + * 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_HLineAA.h> + +#include "tst_test.h" + +#include "common.h" + +struct testcase { + /* line description */ + GP_Coord x0; + GP_Coord x1; + GP_Coord y; + + /* expected result */ + GP_Size w, h; + const char pixmap[]; +}; + +static int test_line(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_HLineAA(c, t->x0, t->x1, t->y, 0xff); + + err = compare_buffers(t->pixmap, c); + + if (err) + return TST_FAILED; + + return TST_SUCCESS; +} + +static struct testcase testcase_line_len_0_1 = { + .x0 = (1<<8), + .x1 = (1<<8), + .y = (1<<8), + + .w = 3, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_0_2 = { + .x0 = (1<<8) + (1<<7), + .x1 = (1<<8) + (1<<7), + .y = (1<<8), + + .w = 3, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_0_3 = { + .x0 = (1<<8), + .x1 = (1<<8), + .y = (1<<8) + (1<<7), + + .w = 3, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_0_4 = { + .x0 = (1<<8) + (1<<7), + .x1 = (1<<8) + (1<<7), + .y = (1<<8) + (1<<7), + + .w = 3, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_0_5 = { + .x0 = (1<<8) + (1<<3) + 1, + .x1 = (1<<8) + (1<<3), + .y = (1<<8) + (1<<2), + + .w = 3, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_05_1 = { + .x0 = (1<<8), + .x1 = (1<<8) + (1<<7), + .y = (1<<8), + + .w = 3, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_05_2 = { + .x0 = (1<<8), + .x1 = (1<<8) + (1<<7), + .y = (1<<8) + (1<<7), + + .w = 3, + .h = 4, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0x40, 0x00, + 0x00, 0x40, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_1_1 = { + .x0 = (1<<8), + .x1 = (2<<8), + .y = (1<<8), + + .w = 4, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_1_2 = { + .x0 = (1<<8) + (1<<7), + .x1 = (2<<8) + (1<<7), + .y = (1<<8), + + .w = 4, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_1_3 = { + .x0 = (1<<8), + .x1 = (2<<8), + .y = (1<<8) + (1<<7), + + .w = 4, + .h = 4, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x40, 0x00, + 0x00, 0x40, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_1_4 = { + .x0 = (1<<8) + (1<<7), + .x1 = (2<<8) + (1<<7), + .y = (1<<8) + (1<<7), + + .w = 4, + .h = 4, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_4_1 = { + .x0 = (1<<8), + .x1 = (4<<8), + .y = (1<<8), + + .w = 6, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0xff, 0xff, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_len_4_2 = { + .x0 = (1<<8), + .x1 = (4<<8), + .y = (1<<8) + (1<<7), + + .w = 6, + .h = 4, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x80, 0x80, 0x40, 0x00, + 0x00, 0x40, 0x80, 0x80, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + } +}; + +const struct tst_suite tst_suite = { + .suite_name = "HLineAA Testsuite", + .tests = { + {.name = "HLineAA len=0 1", + .tst_fn = test_line, + .data = &testcase_line_len_0_1}, + + {.name = "HLineAA len=0 2", + .tst_fn = test_line, + .data = &testcase_line_len_0_2}, + + {.name = "HLineAA len=0 3", + .tst_fn = test_line, + .data = &testcase_line_len_0_3}, + + {.name = "HLineAA len=0 4", + .tst_fn = test_line, + .data = &testcase_line_len_0_4}, + + {.name = "HLineAA len=0 5", + .tst_fn = test_line, + .data = &testcase_line_len_0_5}, + + {.name = "HLineAA len=0.5 1", + .tst_fn = test_line, + .data = &testcase_line_len_05_1}, + + {.name = "HLineAA len=0.5 2", + .tst_fn = test_line, + .data = &testcase_line_len_05_2}, + + {.name = "LineAA len=1 1", + .tst_fn = test_line, + .data = &testcase_line_len_1_1}, + + {.name = "LineAA len=1 2", + .tst_fn = test_line, + .data = &testcase_line_len_1_2}, + + {.name = "LineAA len=1 3", + .tst_fn = test_line, + .data = &testcase_line_len_1_3}, + + {.name = "LineAA len=1 4", + .tst_fn = test_line, + .data = &testcase_line_len_1_4}, + + {.name = "LineAA len=4 1", + .tst_fn = test_line, + .data = &testcase_line_len_4_1}, + + {.name = "LineAA len=4 2", + .tst_fn = test_line, + .data = &testcase_line_len_4_2}, + + {.name = NULL} + } +}; diff --git a/tests/gfx/LineAA.c b/tests/gfx/LineAA.c new file mode 100644 index 0000000..f4a5d45 --- /dev/null +++ b/tests/gfx/LineAA.c @@ -0,0 +1,160 @@ +/***************************************************************************** + * 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_LineAA.h> + +#include "tst_test.h" + +#include "common.h" + +struct testcase { + /* line description */ + GP_Coord x0; + GP_Coord y0; + GP_Coord x1; + GP_Coord y1; + + /* expected result */ + GP_Size w, h; + const char pixmap[]; +}; + +static int test_line(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_LineAA(c, t->x0, t->y0, t->x1, t->y1, 0xff); + + err = compare_buffers(t->pixmap, c); + + if (err) + return TST_FAILED; + + return TST_SUCCESS; +} + +static struct testcase testcase_line_1px = { + .x0 = (1<<8) + (1<<7), + .y0 = (1<<8) + (1<<7), + .x1 = (1<<8) + (1<<7), + .y1 = (1<<8) + (1<<7), + + .w = 3, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0xff, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_2px = { + .x0 = (1<<8), + .y0 = (1<<8), + .x1 = (2<<8), + .y1 = (2<<8), + + .w = 4, + .h = 4, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_2px_h = { + .x0 = (1<<8), + .y0 = (1<<8), + .x1 = (2<<8), + .y1 = (1<<8), + + .w = 4, + .h = 4, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_line_2px_v = { + .x0 = (1<<8), + .y0 = (1<<8), + .x1 = (1<<8), + .y1 = (2<<8), + + .w = 4, + .h = 4, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; + + +const struct tst_suite tst_suite = { + .suite_name = "LineAA Testsuite", + .tests = { + {.name = "LineAA 1px", + .tst_fn = test_line, + .data = &testcase_line_1px}, + + {.name = "LineAA 2px", + .tst_fn = test_line, + .data = &testcase_line_2px}, + + {.name = "LineAA 2px horizontal", + .tst_fn = test_line, + .data = &testcase_line_2px_h}, + + {.name = "LineAA 2px vertical", + .tst_fn = test_line, + .data = &testcase_line_2px_v}, + + {.name = NULL} + } +}; diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile index 0229a5c..ddfdca3 100644 --- a/tests/gfx/Makefile +++ b/tests/gfx/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/pre.mk CSOURCES=$(shell echo *.c)
APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse HLine- VLine + VLine PutPixelAA HLineAA LineAA
Circle: common.o FillCircle: common.o @@ -14,6 +14,9 @@ CircleSeg: common.o Polygon: common.o HLine: common.o VLine: common.o +PutPixelAA: common.o +HLineAA: common.o +LineAA: common.o
include ../tests.mk
diff --git a/tests/gfx/PutPixelAA.c b/tests/gfx/PutPixelAA.c new file mode 100644 index 0000000..55f46de --- /dev/null +++ b/tests/gfx/PutPixelAA.c @@ -0,0 +1,148 @@ +/***************************************************************************** + * 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_PutPixelAA.h> + +#include "tst_test.h" + +#include "common.h" + +struct testcase { + /* pixel description */ + GP_Coord x; + GP_Coord y; + + /* expected result */ + GP_Size w, h; + const char pixmap[]; +}; + +static int test_pixel(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_PutPixelAA(c, t->x, t->y, 0xff); + + err = compare_buffers(t->pixmap, c); + + if (err) + return TST_FAILED; + + return TST_SUCCESS; +} + +static struct testcase testcase_pixel_center = { + .x = (1<<8), + .y = (1<<8), + + .w = 3, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0xff, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_pixel_hcenter = { + .x = (1<<8), + .y = (1<<8) + (1<<7), + + .w = 3, + .h = 4, + + .pixmap = { + 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, + 0x00, 0x80, 0x00, + 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_pixel_vcenter = { + .x = (1<<8) + (1<<7), + .y = (1<<8), + + .w = 4, + .h = 3, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; + +static struct testcase testcase_pixel = { + .x = (1<<8) + (1<<7), + .y = (1<<8) + (1<<7), + + .w = 4, + .h = 4, + + .pixmap = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x40, 0x00, + 0x00, 0x40, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; + +const struct tst_suite tst_suite = { + .suite_name = "PutPixelAA Testsuite", + .tests = { + {.name = "PutPixelAA center", + .tst_fn = test_pixel, + .data = &testcase_pixel_center}, + + {.name = "PutPixelAA hcenter", + .tst_fn = test_pixel, + .data = &testcase_pixel_hcenter}, + + {.name = "PutPixelAA vcenter", + .tst_fn = test_pixel, + .data = &testcase_pixel_vcenter}, + + {.name = "PutPixelAA", + .tst_fn = test_pixel, + .data = &testcase_pixel}, + + {.name = NULL} + } +}; diff --git a/tests/gfx/common.c b/tests/gfx/common.c index a52d007..35a6d13 100644 --- a/tests/gfx/common.c +++ b/tests/gfx/common.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -30,7 +30,7 @@ static void dump_buffer(const char *pattern, int w, int h)
for (y = 0; y < h; y++) { for (x = 0; x < w; x++) - printf("%2x ", pattern[x + y * w]); + printf("%2x ", (uint8_t)pattern[x + y * w]); printf("n"); } } @@ -57,7 +57,7 @@ void dump_buffers(const char *pattern, const GP_Context *c) else printf(" * "); } else { - printf("%2x ", pattern[idx]); + printf("%2x ", (uint8_t)pattern[idx]); }
} diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh index faf62bf..2dc6ddf 100755 --- a/tests/gfx/runtest.sh +++ b/tests/gfx/runtest.sh @@ -18,3 +18,7 @@ LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./F LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Ellipse "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./CircleSeg "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Polygon "$@" + +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./PutPixelAA "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./HLineAA "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./LineAA "$@"
-----------------------------------------------------------------------
Summary of changes: include/gfx/GP_HLineAA.h | 5 +- libs/gfx/GP_HLineAA.gen.c.t | 84 +++++++--- libs/gfx/GP_PutPixelAA.gen.c.t | 24 +++- tests/gfx/HLineAA.c | 325 ++++++++++++++++++++++++++++++++++++++++ tests/gfx/{Line.c => LineAA.c} | 178 ++++++---------------- tests/gfx/Makefile | 5 +- tests/gfx/PutPixelAA.c | 148 ++++++++++++++++++ tests/gfx/common.c | 6 +- tests/gfx/runtest.sh | 4 + 9 files changed, 616 insertions(+), 163 deletions(-) create mode 100644 tests/gfx/HLineAA.c copy tests/gfx/{Line.c => LineAA.c} (50%) create mode 100644 tests/gfx/PutPixelAA.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.