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 125caf8cdfeee0056f22bd69a1d4673bc08b386e (commit) from 69fe54806e58e8f78860761e97b90d592199b665 (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/125caf8cdfeee0056f22bd69a1d4673bc08b3...
commit 125caf8cdfeee0056f22bd69a1d4673bc08b386e Author: Cyril Hrubis metan@ucw.cz Date: Sat May 11 00:31:02 2013 +0200
test: core: Add Blit Conversions tests.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/core/BlitConv.gen.c.t b/tests/core/BlitConv.gen.c.t new file mode 100644 index 0000000..6e95acc --- /dev/null +++ b/tests/core/BlitConv.gen.c.t @@ -0,0 +1,174 @@ +/***************************************************************************** + * 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.test.c.t" + +%% block body + +#include <stdio.h> + +#include <core/GP_Context.h> +#include <core/GP_Convert.h> +#include <core/GP_GetPutPixel.h> +#include <core/GP_Blit.h> + +#include "tst_test.h" + +static void fill_context(GP_Context *c, GP_Pixel p) +{ + GP_Coord x, y; + + for (x = 0; x < (GP_Coord)c->w; x++) + for (y = 0; y < (GP_Coord)c->h; y++) + GP_PutPixel(c, x, y, p); +} + +static void mess_context(GP_Context *c) +{ + GP_Coord y; + unsigned int i; + + for (y = 0; y < (GP_Coord)c->h; y++) { + uint8_t *row = GP_PIXEL_ADDR(c, 0, y); + for (i = 0; i < c->bytes_per_row; i++) { + row[i] = y ^ i; + } + } +} + +static int check_filled(GP_Context *c, GP_Pixel p) +{ + GP_Coord x, y; + GP_Pixel pc; + + for (x = 0; x < (GP_Coord)c->w; x++) { + for (y = 0; y < (GP_Coord)c->h; y++) { + pc = GP_GetPixel(c, x, y); + if (p != pc) { + tst_msg("Pixels different %08x %08x", p, pc); + return 1; + } + } + } + + return 0; +} + +%% for pt1 in pixeltypes +%% if not pt1.is_unknown() and not pt1.is_palette() +%% for pt2 in pixeltypes +%% if not pt2.is_unknown() and not pt2.is_palette() +static int blit_black_{{ pt1.name }}_to_{{ pt2.name }}(void) +{ + GP_Context *src = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt1.name }}); + GP_Context *dst = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt2.name }}); + + if (src == NULL || dst == NULL) { + GP_ContextFree(src); + GP_ContextFree(dst); + tst_msg("Malloc failed :("); + return TST_UNTESTED; + } + + /* Fill source with black, destination with pseudo random mess */ +%% if pt1.is_alpha() + GP_Pixel black_src = GP_RGBAToContextPixel(0, 0, 0, 0xff, src); +%% else + GP_Pixel black_src = GP_RGBToContextPixel(0, 0, 0, src); +%% endif +%% if pt2.is_alpha() + GP_Pixel black_dst = GP_RGBAToContextPixel(0, 0, 0, 0xff, src); +%% else + GP_Pixel black_dst = GP_RGBToContextPixel(0, 0, 0, dst); +%% endif + + fill_context(src, black_src); + mess_context(dst); + + GP_Blit(src, 0, 0, src->w, src->h, dst, 0, 0); + + if (check_filled(dst, black_dst)) + return TST_FAILED; + + return TST_SUCCESS; +} + +static int blit_white_{{ pt1.name }}_to_{{ pt2.name }}(void) +{ + GP_Context *src = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt1.name }}); + GP_Context *dst = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt2.name }}); + + if (src == NULL || dst == NULL) { + GP_ContextFree(src); + GP_ContextFree(dst); + tst_msg("Malloc failed :("); + return TST_UNTESTED; + } + + /* Fill source with white, destination with pseudo random mess */ +%% if pt1.is_alpha() + GP_Pixel white_src = GP_RGBAToContextPixel(0xff, 0xff, 0xff, 0xff, src); +%% else + GP_Pixel white_src = GP_RGBToContextPixel(0xff, 0xff, 0xff, src); +%% endif +%% if pt2.is_alpha() + GP_Pixel white_dst = GP_RGBAToContextPixel(0xff, 0xff, 0xff, 0xff, src); +%% else + GP_Pixel white_dst = GP_RGBToContextPixel(0xff, 0xff, 0xff, dst); +%% endif + + fill_context(src, white_src); + mess_context(dst); + + GP_Blit(src, 0, 0, src->w, src->h, dst, 0, 0); + + if (check_filled(dst, white_dst)) + return TST_FAILED; + + return TST_SUCCESS; +} + +%% endif +%% endfor +%% endif +%% endfor + +const struct tst_suite tst_suite = { + .suite_name = "Blit Conversions Testsuite", + .tests = { +%% for pt1 in pixeltypes +%% if not pt1.is_unknown() and not pt1.is_palette() +%% for pt2 in pixeltypes +%% if not pt2.is_unknown() and not pt2.is_palette() + {.name = "blit black {{ pt1.name }} to {{ pt2.name }}", + .tst_fn = blit_black_{{ pt1.name }}_to_{{ pt2.name }}}, + {.name = "blit white {{ pt1.name }} to {{ pt2.name }}", + .tst_fn = blit_white_{{ pt1.name }}_to_{{ pt2.name }}}, +%% endif +%% endfor +%% endif +%% endfor + {.name = NULL} + } +}; + +%% endblock body diff --git a/tests/core/Makefile b/tests/core/Makefile index 8aa4196..2fb3c86 100644 --- a/tests/core/Makefile +++ b/tests/core/Makefile @@ -4,9 +4,9 @@ include $(TOPDIR)/pre.mk
CSOURCES=Context.c Pixel.c
-GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c +GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c BlitConv.gen.c
-APPS=WritePixel.gen Pixel Context GetPutPixel.gen +APPS=WritePixel.gen Pixel Context GetPutPixel.gen BlitConv.gen
include ../tests.mk
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt index 89cbedd..432bef9 100644 --- a/tests/core/test_list.txt +++ b/tests/core/test_list.txt @@ -3,3 +3,4 @@ WritePixel.gen Context Pixel GetPutPixel.gen +BlitConv.gen
-----------------------------------------------------------------------
Summary of changes: tests/core/BlitConv.gen.c.t | 174 +++++++++++++++++++++++++++++++++++++++++++ tests/core/Makefile | 4 +- tests/core/test_list.txt | 1 + 3 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 tests/core/BlitConv.gen.c.t
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.