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 f7cb41744ef49b26625e2c6c9e7deb64a6ba0018 (commit)
via 9962b69ac47d514051afb83b0942655ff9e76991 (commit)
from e596ea9912cfde653e3048e64d3a821328975f14 (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/f7cb41744ef49b26625e2c6c9e7deb64a6ba…
commit f7cb41744ef49b26625e2c6c9e7deb64a6ba0018
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 19 16:23:13 2013 +0200
tests: core: Add test for Convert_Scale operations
There are few failures that are caused by slightly
incorrect rounding on upsampling but these are not fatal.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/Convert_Scale.gen.c.t b/tests/core/Convert_Scale.gen.c.t
new file mode 100644
index 0000000..a3ce1b5
--- /dev/null
+++ b/tests/core/Convert_Scale.gen.c.t
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * 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(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+%% extends "base.test.c.t"
+
+%% block body
+
+#include <stdio.h>
+#include <math.h>
+
+#include <core/GP_Convert_Scale.gen.h>
+
+#include "tst_test.h"
+
+%% set max = 16
+
+%% for i in range(1, max)
+%% for j in range(1, max)
+static int check_convert_{{ i }}_{{ j }}(void)
+{
+ unsigned int v, res, exp_res, fail = 0;
+ float fres;
+
+ for (v = 0; v < {{ 2 ** i - 1 }}; v++) {
+ res = GP_SCALE_VAL_{{ i }}_{{ j }}(v);
+%% if j > i
+ /*
+ * We have {{ 2**i }} values and we need to map them to
+ * subset of {{ 2**j }} values while making sure 0 -> 0
+ * and {{ 2**i - 1 }} -> {{ 2**j - 1 }} and that the
+ * mapping is as evenly distributed as possible.
+ *
+ * So we map the input to 0-1 interval by dividing it by
+ * maximal input value {{ 2**i - 1 }} and then multiply
+ * it by output maximal value {{ 2**j - 1}}.
+ */
+ fres = (v / {{ (2.00 ** i - 1) }}) * {{ (2.00 ** j - 1) }};
+ exp_res = round(fres);
+%% else
+ /*
+ * We have {{ 2**i }} values that must be mapped to {{ 2**j }}
+ * so we do simple division and floor() which maps the values
+ * evenly, 0 -> 0 and {{ 2**i - 1 }} -> {{ 2**j - 1 }}.
+ *
+ * In terms for implementation this is just bitshift.
+ */
+ fres = v * {{ (2.00 ** j) / (2.00 ** i) }};
+ exp_res = floor(fres);
+%% endif
+
+ if (res != exp_res) {
+ if (fail < 5)
+ tst_msg("GP_SCALE_{{ i }}_{{ j }}(%i) = %i, "
+ "expected %i %f", v, res, exp_res, fres);
+ fail++;
+ }
+ }
+
+ if (fail) {
+ if (fail > 5)
+ tst_msg("+ next %u failures", fail - 5);
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+%% endfor
+%% endfor
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Pixel Conversions Testsuite",
+ .tests = {
+%% for i in range(1, max)
+%% for j in range(1, max)
+ {.name = "SCALE_{{ i }}_{{ j }}()",
+ .tst_fn = check_convert_{{ i }}_{{ j }}},
+%% endfor
+%% endfor
+ {.name = NULL}
+ }
+};
+
+%% endblock body
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 2c0d363..c770fc5 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -4,9 +4,11 @@ include $(TOPDIR)/pre.mk
CSOURCES=Context.c Pixel.c
-GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c Convert.gen.c BlitConv.gen.c
+GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c Convert.gen.c BlitConv.gen.c + Convert_Scale.gen.c
-APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen
+APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen + Convert_Scale.gen
include ../tests.mk
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt
index 45702bb..3edab32 100644
--- a/tests/core/test_list.txt
+++ b/tests/core/test_list.txt
@@ -4,4 +4,5 @@ Context
Pixel
GetPutPixel.gen
Convert.gen
+Convert_Scale.gen
BlitConv.gen
http://repo.or.cz/w/gfxprim.git/commit/9962b69ac47d514051afb83b0942655ff9e7…
commit 9962b69ac47d514051afb83b0942655ff9e76991
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 18 12:50:15 2013 +0200
tests: core: Convert.gen.c: Add more cases.
Some of them fail, I'm not yet sure if these
are wrong tests of rounding errors in the
implementation.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
index 84159f1..57bc4d2 100644
--- a/tests/core/Convert.gen.c.t
+++ b/tests/core/Convert.gen.c.t
@@ -102,6 +102,58 @@ static GP_Pixel get_white(GP_PixelType pixel_type)
}
/*
+ * Returns 50% gray color for particular pixel type.
+ */
+static GP_Pixel get_gray(GP_PixelType pixel_type)
+{
+ switch (pixel_type) {
+%% for pt in pixeltypes
+ case {{ pt.C_enum }}:
+%% if pt.is_cmyk()
+%% set K = pt.chans['K']
+ /* Gray in CMYK modifies K */
+ return {{ hex(round(K.max / 2.00)) }}{{ K.C_shift }};
+%% elif pt.is_rgb()
+%% set R = pt.chans['R']
+%% set G = pt.chans['G']
+%% set B = pt.chans['B']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Gray in RGBA */
+ return {{ A.C_mask }} |
+ ({{ hex(round(R.max / 2.00)) }}{{ R.C_shift }}) |
+ ({{ hex(round(G.max / 2.00)) }}{{ G.C_shift }}) |
+ ({{ hex(round(B.max / 2.00)) }}{{ B.C_shift }});
+%% else
+ /* Gray Plain old RGB */
+ return ({{ hex(round(R.max / 2.00)) }}{{ R.C_shift }}) |
+ ({{ hex(round(G.max / 2.00)) }}{{ G.C_shift }}) |
+ ({{ hex(round(B.max / 2.00)) }}{{ B.C_shift }});
+%% endif
+%% elif pt.is_gray()
+%% set V = pt.chans['V']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Gray in Grayscale with Alpha */
+ return {{ A.C_mask }} |
+ ({{ hex(round(V.max / 2.00)) }}{{ V.C_shift }});
+%% else
+ /* Grayscale */
+ return {{ hex(round(V.max / 2.00)) }}{{ V.C_shift }};
+%% endif
+%% else
+ tst_msg("FIXME: Unsupported conversion to %s",
+ GP_PixelTypeName(pixel_type));
+ exit(TST_INTERR);
+%% endif
+%% endfor
+ default:
+ tst_msg("Invalid pixel type %i", pixel_type);
+ exit(TST_INTERR);
+ }
+}
+
+/*
* Returns red color for particular pixel type.
*/
static GP_Pixel get_red(GP_PixelType pixel_type)
@@ -171,14 +223,24 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi
%% for pt1 in pixeltypes
%% if not pt1.is_unknown() and not pt1.is_palette()
%% if pt1.name not in ['RGB888', 'RGBA8888']
+{#- White -#}
{{ gen_convert_and_check('white', pt1.name, 'RGB888') }}
{{ gen_convert_and_check('white', pt1.name, 'RGBA8888') }}
{{ gen_convert_and_check('white', 'RGB888', pt1.name) }}
{{ gen_convert_and_check('white', 'RGBA8888', pt1.name) }}
+{#- Black -#}
{{ gen_convert_and_check('black', pt1.name, 'RGB888') }}
{{ gen_convert_and_check('black', pt1.name, 'RGBA8888') }}
{{ gen_convert_and_check('black', 'RGB888', pt1.name) }}
{{ gen_convert_and_check('black', 'RGBA8888', pt1.name) }}
+{#- Grayscale -#}
+%% if pt1.name not in ['G1']
+{{ gen_convert_and_check('gray', pt1.name, 'RGB888') }}
+{{ gen_convert_and_check('gray', pt1.name, 'RGBA8888') }}
+%% endif
+{{ gen_convert_and_check('gray', 'RGB888', pt1.name) }}
+{{ gen_convert_and_check('gray', 'RGBA8888', pt1.name) }}
+{#- Red -#}
%% if not pt1.is_gray()
{{ gen_convert_and_check('red', pt1.name, 'RGB888') }}
{{ gen_convert_and_check('red', pt1.name, 'RGBA8888') }}
@@ -203,14 +265,24 @@ const struct tst_suite tst_suite = {
%% for pt1 in pixeltypes
%% if not pt1.is_unknown() and not pt1.is_palette()
%% if pt1.name not in ['RGB888', 'RGBA8888']
+{#- White -#}
{{ gen_suite_entry('white', pt1.name, 'RGB888') }}
{{ gen_suite_entry('white', pt1.name, 'RGBA8888') }}
{{ gen_suite_entry('white', 'RGB888', pt1.name) }}
{{ gen_suite_entry('white', 'RGBA8888', pt1.name) }}
+{#- Black -#}
{{ gen_suite_entry('black', pt1.name, 'RGB888') }}
{{ gen_suite_entry('black', pt1.name, 'RGBA8888') }}
{{ gen_suite_entry('black', 'RGB888', pt1.name) }}
{{ gen_suite_entry('black', 'RGBA8888', pt1.name) }}
+{#- Gray -#}
+%% if pt1.name not in ['G1']
+{{ gen_suite_entry('gray', pt1.name, 'RGB888') }}
+{{ gen_suite_entry('gray', pt1.name, 'RGBA8888') }}
+%% endif
+{{ gen_suite_entry('gray', 'RGB888', pt1.name) }}
+{{ gen_suite_entry('gray', 'RGBA8888', pt1.name) }}
+{#- Red -#}
%% if not pt1.is_gray()
{{ gen_suite_entry('red', pt1.name, 'RGB888') }}
{{ gen_suite_entry('red', pt1.name, 'RGBA8888') }}
-----------------------------------------------------------------------
Summary of changes:
tests/core/Convert.gen.c.t | 72 +++++++++++++++++++
tests/core/{Pixel.c => Convert_Scale.gen.c.t} | 93 ++++++++++++++++--------
tests/core/Makefile | 6 +-
tests/core/test_list.txt | 1 +
4 files changed, 139 insertions(+), 33 deletions(-)
copy tests/core/{Pixel.c => Convert_Scale.gen.c.t} (51%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 ea54d1823b32741eebb6465568654e8d1bcd4354 (commit)
from 1db276a11bc1bca52f361c7e9f7e4cf2933353d6 (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/ea54d1823b32741eebb6465568654e8d1bcd…
commit ea54d1823b32741eebb6465568654e8d1bcd4354
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 14 23:31:21 2013 +0200
spiv: Update help and keys help.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index f16be8c..93dd301 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -709,9 +709,24 @@ static void init_caches(struct loader_params *params)
static const char *keys_help[] = {
"Keyboard control:",
"",
+ "Esc, Enter, Q - quit spiv",
+ "",
+ "< KP Minus - zoom out by 1.5",
+ ">, KP Plus - zoom in by 1.5",
+ "R - rotate by 90 degrees clockwise",
+ "Up, Down, Left, Right - move image by 1px",
+ " (by 10 with Shift)",
+ "",
+ "Space - move to the next image",
+ "BackSpace - move to the prev image",
+ "PgDown - move to the start of directory",
+ "PgUp - move to the end of directory",
+ "Home - move to the first image",
+ "End - move to the last image",
+ "",
"I - toggle show info box",
"P - toggle show progress",
- "R - rotate by 90 degrees",
+ "",
"] - change to next resampling method",
"[ - change to prev resampling method",
" (current method is shown in info box)",
@@ -719,17 +734,6 @@ static const char *keys_help[] = {
"D - drop image cache",
"H - toggle help",
"",
- "Esc",
- "Enter",
- "Q - quit spiv",
- "",
- "PgDown - move 10 images forward",
- "PgUp - move 10 images backward",
- "",
- "Space - move to the next image",
- "",
- "BckSpc - move to the prev image",
- "",
"1 - resize spiv window to the image size",
"2 - resize spiv window to the half of the image size",
"3 - resize spiv window to the third of the image size",
@@ -757,6 +761,8 @@ static void print_help(void)
printf("-e pixel_typentturns on backend type emulationn");
printf("tfor example -e G1 sets 1-bit grayscalenn");
printf("-r anglentrotate display 90,180 or 270 degreesnn");
+ printf("-z sets zoom modent-zf zoom is set and modified by usern");
+ printf("t-zw zoom is fixed to window size (currently default)nn");
printf("-bntpass backend init string to backend initn");
printf("tpass -b help for more infonn");
@@ -783,7 +789,7 @@ static void show_help(void)
GP_Fill(c, black_pixel);
for (i = 0; i < keys_help_len; i++) {
- GP_Print(c, NULL, 20, i * 15, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ GP_Print(c, NULL, 20, 2 + i * 15, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white_pixel, black_pixel, "%s", keys_help[i]);
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")