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 71f52a5f96a206b5aeb9562de37143a731d6bbc4 (commit)
via aab22729cba114c6be378df856d356d3d1bd4ea8 (commit)
from c70943a639eabdf53615fb48e6206ed4ed020d1b (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/71f52a5f96a206b5aeb9562de37143a731d6…
commit 71f52a5f96a206b5aeb9562de37143a731d6bbc4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 31 23:56:16 2013 +0200
loaders: BMP: Fix progress callback percentage.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index 70f701d..7530794 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -526,7 +526,7 @@ static int read_palette(FILE *f, struct bitmap_info_header *header,
GP_PutPixel_Raw_24BPP(context, x, ry, p);
}
- if (GP_ProgressCallbackReport(callback, header->h - y -1,
+ if (GP_ProgressCallbackReport(callback, y,
context->h, context->w)) {
GP_DEBUG(1, "Operation aborted");
return ECANCELED;
@@ -575,7 +575,7 @@ static int read_bitfields_or_rgb(FILE *f, struct bitmap_info_header *header,
break;
}
- if (GP_ProgressCallbackReport(callback, header->h - y -1,
+ if (GP_ProgressCallbackReport(callback, y,
context->h, context->w)) {
GP_DEBUG(1, "Operation aborted");
return ECANCELED;
http://repo.or.cz/w/gfxprim.git/commit/aab22729cba114c6be378df856d356d3d1bd…
commit aab22729cba114c6be378df856d356d3d1bd4ea8
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 31 16:49:43 2013 +0200
core: Remove now unused GP_WritePixel.gen.c.t
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/core/GP_WritePixel.gen.c.t b/libs/core/GP_WritePixel.gen.c.t
deleted file mode 100644
index 89ecc1f..0000000
--- a/libs/core/GP_WritePixel.gen.c.t
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************************
- * 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.h.t'
-
-{% block description %}Write pixel{% endblock %}
-
-{% block body %}
-
-#include "core/GP_GetSetBits.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.gen.h"
-#include "core/GP_Debug.h"
-
-{# Some pixel types has hand written optimized functions #}
-%% set hand_optimized = ['1BPP_LE', '1BPP_BE',
- '2BPP_LE', '2BPP_BE',
- '4BPP_LE', '4BPP_BE',
- '8BPP', '16BPP',
- '24BPP', '32BPP']
-
-%% for ps in pixelsizes
-%% if ps.suffix not in hand_optimized
-%% if ps.needs_bit_endian()
-void GP_WritePixels_{{ ps.suffix }}(void *start, uint8_t off,
- size_t cnt, unsigned int val)
-{
- GP_TODO("Unimplemented");
-}
-%% else
-void GP_WritePixels_{{ ps.suffix }}(void *start, size_t cnt, unsigned int val)
-{
- GP_TODO("Unimplemented");
-}
-%% endif
-
-%% endif
-%% endfor
-
-{% endblock body %}
diff --git a/libs/core/Makefile b/libs/core/Makefile
index 46a46d3..c392a2b 100644
--- a/libs/core/Makefile
+++ b/libs/core/Makefile
@@ -2,7 +2,7 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c GP_Convert.gen.c - GP_GammaCorrection.gen.c GP_WritePixel.gen.c
+ GP_GammaCorrection.gen.c
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=core
-----------------------------------------------------------------------
Summary of changes:
libs/core/GP_WritePixel.gen.c.t | 59 ---------------------------------------
libs/core/Makefile | 2 +-
libs/loaders/GP_BMP.c | 4 +-
3 files changed, 3 insertions(+), 62 deletions(-)
delete mode 100644 libs/core/GP_WritePixel.gen.c.t
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 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.")