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 e596ea9912cfde653e3048e64d3a821328975f14 (commit) via c21eede58f5a634eb89685bfe3b4cc689a21cbcc (commit) via 86959990865d791b8c411c58db7a0aec37b7425d (commit) from ea54d1823b32741eebb6465568654e8d1bcd4354 (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/e596ea9912cfde653e3048e64d3a821328975...
commit e596ea9912cfde653e3048e64d3a821328975f14 Author: Cyril Hrubis metan@ucw.cz Date: Fri May 17 23:11:26 2013 +0200
core: GP_Convert: Make it more readable.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t index 7a7397e..72c974b 100644 --- a/include/core/GP_Convert.gen.h.t +++ b/include/core/GP_Convert.gen.h.t @@ -34,16 +34,16 @@ %% set M = out.chans['M'] %% set Y = out.chans['Y'] %% set K = out.chans['K'] -%% set max_bits = max(R[2], G[2], B[2]) -%% set max_val = 2 ** max_bits - 1 - GP_Pixel _R = GP_SCALE_VAL_{{ R[2] }}_{{ max_bits }}(GP_GET_BITS({{ R[1] }}+o1, {{ R[2] }}, p1)); - GP_Pixel _G = GP_SCALE_VAL_{{ G[2] }}_{{ max_bits }}(GP_GET_BITS({{ G[1] }}+o1, {{ G[2] }}, p1)); - GP_Pixel _B = GP_SCALE_VAL_{{ B[2] }}_{{ max_bits }}(GP_GET_BITS({{ B[1] }}+o1, {{ B[2] }}, p1)); +%% set max_size = max(R.size, G.size, B.size) +%% set max_val = 2 ** max_size - 1 + GP_Pixel _R = GP_SCALE_VAL_{{ R.size }}_{{ max_size }}(GP_GET_BITS({{ R.off }}+o1, {{ R.size }}, p1)); + GP_Pixel _G = GP_SCALE_VAL_{{ G.size }}_{{ max_size }}(GP_GET_BITS({{ G.off }}+o1, {{ G.size }}, p1)); + GP_Pixel _B = GP_SCALE_VAL_{{ B.size }}_{{ max_size }}(GP_GET_BITS({{ B.off }}+o1, {{ B.size }}, p1)); GP_Pixel _K = GP_MAX3(_R, _G, _B); - GP_SET_BITS({{ C[1] }}+o2, {{ C[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ C[2] }}((_K - _R))); - GP_SET_BITS({{ M[1] }}+o2, {{ M[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ M[2] }}((_K - _G))); - GP_SET_BITS({{ Y[1] }}+o2, {{ Y[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ Y[2] }}((_K - _B))); - GP_SET_BITS({{ K[1] }}+o2, {{ K[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ K[2] }}({{ max_val }} - _K)); + GP_SET_BITS({{ C.off }}+o2, {{ C.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ C.size }}((_K - _R))); + GP_SET_BITS({{ M.off }}+o2, {{ M.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ M.size }}((_K - _G))); + GP_SET_BITS({{ Y.off }}+o2, {{ Y.si ze }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ Y.size }}((_K - _B))); + GP_SET_BITS({{ K.off }}+o2, {{ K.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ K.size }}({{ max_val }} - _K)); %% endmacro
%% macro GP_Pixel_TYPE_TO_TYPE(pt1, pt2) @@ -60,23 +60,23 @@ {# case 1: just copy a channel -#} %% if c2[0] in pt1.chans.keys() %% set c1 = pt1.chans[c2[0]] - /* {{ c2[0] }}:={{ c1[0] }} */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2,- GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1))); + /* {{ c2[0] }}:={{ c1[0] }} */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,+ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1))); {# case 2: set A to full opacity (not present in source) -#} %% elif c2[0]=='A' - /* A:={{ hex(c2[2]) }} */GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, {{ hex(2 ** c2[2] - 1) }}); + /* A:={{ c2.C_max }} */GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, {{ c2.C_max }}); {# case 3: calculate V as average of RGB -#} %% elif c2[0]=='V' and pt1.is_rgb() - /* V:=RGB_avg */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, ( + /* V:=RGB_avg */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, ( %% for c1 in [pt1.chans['R'], pt1.chans['G'], pt1.chans['B']] - /* {{c1[0]}} */ GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1)) + + /* {{ c1.name }} */ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1)) + %% endfor 0)/3); {# case 4: set each RGB to V -#} %% elif c2[0] in 'RGB' and pt1.is_gray() %% set c1 = pt1.chans['V'] - /* {{ c2[0] }}:=V */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2,- GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1))); + /* {{ c2[0] }}:=V */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,+ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1))); {# case 5: CMYK to RGB -#} %% elif c2[0] in 'RGB' and pt1.is_cmyk() %% set K = pt1.chans['K'] @@ -88,10 +88,10 @@ %% else %% set V = pt1.chans['Y'] %% endif - GP_SET_BITS({{ c2[1] }}+o2, {{ c2[2] }}, p2,- GP_SCALE_VAL_{{ K[2] + V[2] }}_{{ c2[2] }}(- (({{ 2 ** K[2] - 1 }} - GP_GET_BITS({{ K[1] }}+o1, {{ K[2] }}, p1)) * - ({{ 2 ** V[2] - 1 }} - GP_GET_BITS({{ V[1] }}+o1, {{ V[2] }}, p1))))); + GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,+ GP_SCALE_VAL_{{ K.size + V.size }}_{{ c2.size }}(+ (({{ K.C_max }} - GP_GET_BITS({{ K.off }}+o1, {{ K.size }}, p1)) * + ({{ V.C_max }} - GP_GET_BITS({{ V.off }}+o1, {{ V.size }}, p1))))); {# case 7: invalid mapping -#} %% else {{ error('Channel conversion ' + pt1.name + ' to ' + pt2.name + ' not supported.') }}
http://repo.or.cz/w/gfxprim.git/commit/c21eede58f5a634eb89685bfe3b4cc689a21c...
commit c21eede58f5a634eb89685bfe3b4cc689a21cbcc Author: Cyril Hrubis metan@ucw.cz Date: Fri May 17 20:18:43 2013 +0200
tests: core: New test for pixel conversions.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t index 6f445e2..84159f1 100644 --- a/tests/core/Convert.gen.c.t +++ b/tests/core/Convert.gen.c.t @@ -37,15 +37,15 @@ static GP_Pixel get_black(GP_PixelType pixel_type) { switch (pixel_type) { %% for pt in pixeltypes - case GP_PIXEL_{{ pt.name }}: + case {{ pt.C_enum }}: %% if pt.is_cmyk() %% set K = pt.chans['K'] /* Black in CMYK is full K rest zero */ - return {{ hex((2 ** K[2] - 1) * (2 ** K[1]))}}; + return {{ K.C_mask }}; %% elif pt.is_alpha() %% set A = pt.chans['A'] /* Black with Alpha channel is full A rest zero */ - return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}}; + return {{ A.C_mask }}; %% else return 0; %% endif @@ -57,43 +57,86 @@ static GP_Pixel get_black(GP_PixelType pixel_type) }
/* + * Returns white color for particular pixel type. + */ +static GP_Pixel get_white(GP_PixelType pixel_type) +{ + switch (pixel_type) { +%% for pt in pixeltypes + case {{ pt.C_enum }}: +%% if pt.is_cmyk() + /* White in CMYK is zero */ + return 0x0; +%% 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'] + /* White in RGBA */ + return {{ A.C_mask }} | {{ R.C_mask }} | {{ G.C_mask }} | {{ B.C_mask }}; +%% else + /* Plain old RGB */ + return {{ R.C_mask }} | {{ G.C_mask }} | {{ B.C_mask }}; +%% endif +%% elif pt.is_gray() +%% set V = pt.chans['V'] +%% if pt.is_alpha() +%% set A = pt.chans['A'] + /* Grayscale with Alpha */ + return {{ V.C_mask }} | {{ A.C_mask }}; +%% else + /* Grayscale */ + return {{ V.C_mask }}; +%% 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) { switch (pixel_type) { %% for pt in pixeltypes - case GP_PIXEL_{{ pt.name }}: + case {{ pt.C_enum }}: %% if pt.is_cmyk() %% set M = pt.chans['M'] %% set Y = pt.chans['Y'] /* Red in CMYK is full M and Y rest zero */ - return {{ hex((2 ** M[2] - 1) * (2 ** M[1]))}} - | {{ hex((2 ** Y[2] - 1) * (2 ** Y[1]))}}; + return {{ M.C_mask }} | {{ Y.C_mask }}; %% elif pt.is_rgb() %% set R = pt.chans['R'] %% if pt.is_alpha() %% set A = pt.chans['A'] /* Red with Alpha channel is full Alpha and R rest zero */ - return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}} - | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}}; + return {{ A.C_mask }} | {{ R.C_mask }}; %% else /* Plain old RGB */ - return {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}}; + return {{ R.C_mask }}; %% endif %% elif pt.is_gray() %% set V = pt.chans['V'] %% if pt.is_alpha() %% set A = pt.chans['A'] /* Grayscale with Alpha channel is full Alpha + 1/3 Gray */ - return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}}; - | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}}; + return ({{ hex(V.max // 3)}}{{ V.C_shift }}) | {{ A.C_mask }}; %% else /* Grayscale is 1/3 Gray */ - return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}}; + return {{ hex(V.max // 3) }}{{ V.C_shift }}; %% endif %% else - tst_msg("Unsupported conversion to %s", GP_PixelTypeName(pixel_type)); + tst_msg("FIXME: Unsupported conversion to %s", + GP_PixelTypeName(pixel_type)); exit(TST_INTERR); %% endif %% endfor @@ -110,6 +153,8 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi GP_Pixel in = get_{{ test_name }}(GP_PIXEL_{{ in_name }}); GP_Pixel out_exp = get_{{ test_name }}(GP_PIXEL_{{ out_name }});
+ tst_msg("{{ in_name }} %08x -> {{ out_name }} %08x", in, out_exp); + GP_Pixel_{{ in_name }}_TO_{{ out_name }}(in, out);
if (out_exp != out) { @@ -125,12 +170,22 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi %% macro gen_converts() %% for pt1 in pixeltypes %% if not pt1.is_unknown() and not pt1.is_palette() -%% for pt2 in pixeltypes -%% if pt2.name in ['RGB888', 'RGBA8888'] -{{ gen_convert_and_check('black', pt2.name, pt1.name) }} -{{ gen_convert_and_check('red', pt2.name, pt1.name) }} -%% endif -%% endfor +%% if pt1.name not in ['RGB888', 'RGBA8888'] +{{ 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) }} +{{ 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) }} +%% if not pt1.is_gray() +{{ gen_convert_and_check('red', pt1.name, 'RGB888') }} +{{ gen_convert_and_check('red', pt1.name, 'RGBA8888') }} +%% endif +{{ gen_convert_and_check('red', 'RGB888', pt1.name) }} +{{ gen_convert_and_check('red', 'RGBA8888', pt1.name) }} +%% endif %% endif %% endfor %% endmacro @@ -147,17 +202,24 @@ const struct tst_suite tst_suite = { .tests = { %% for pt1 in pixeltypes %% if not pt1.is_unknown() and not pt1.is_palette() -%% for pt2 in pixeltypes -%% if pt2.name in ['RGB888', 'RGBA8888'] -{{ gen_suite_entry('black', pt2.name, pt1.name) }} -{{ gen_suite_entry('red', pt2.name, pt1.name) }} +%% if pt1.name not in ['RGB888', 'RGBA8888'] +{{ 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) }} +{{ 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) }} +%% if not pt1.is_gray() +{{ gen_suite_entry('red', pt1.name, 'RGB888') }} +{{ gen_suite_entry('red', pt1.name, 'RGBA8888') }} %% endif -%% endfor +{{ gen_suite_entry('red', 'RGB888', pt1.name) }} +{{ gen_suite_entry('red', 'RGBA8888', pt1.name) }} +%% endif %% endif %% endfor - -{{ gen_suite_entry('red', 'RGB888', 'CMYK8888') }} - {.name = NULL} } }; diff --git a/tests/core/Makefile b/tests/core/Makefile index 2fb3c86..2c0d363 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 BlitConv.gen.c +GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c Convert.gen.c BlitConv.gen.c
-APPS=WritePixel.gen Pixel Context GetPutPixel.gen BlitConv.gen +APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen
include ../tests.mk
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt index 432bef9..45702bb 100644 --- a/tests/core/test_list.txt +++ b/tests/core/test_list.txt @@ -3,4 +3,5 @@ WritePixel.gen Context Pixel GetPutPixel.gen +Convert.gen BlitConv.gen
http://repo.or.cz/w/gfxprim.git/commit/86959990865d791b8c411c58db7a0aec37b74...
commit 86959990865d791b8c411c58db7a0aec37b7425d Author: Cyril Hrubis metan@ucw.cz Date: Fri May 17 19:50:35 2013 +0200
gp_codegen: pixeltype.py: Edhance channel list members.
Previously the channel list (and dict) members were simple triplets.
This commit creates ChannelList object derived from list and adds a few convinience member values.
* c.name returns channel name (same as c[0])
* c.off returns channel offset (same as c[1])
* c.size returns channel size in bits (same as c[2])
* c.C_shift returns string with C shift (i.e. " << 8" if off=8)
* c.max returns maximal channel value as int (i.e. 2 ^ len - 1)
* c.C_max returns maximal channel value as hex string
* c.mask returns channel mask as as int
* c.C_mask returns C mask as a string (i.e. "0xff00 for len=8 and off=8)
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/pylib/gp_codegen/pixeltype.py b/pylib/gp_codegen/pixeltype.py index eaac404..9e89ddc 100644 --- a/pylib/gp_codegen/pixeltype.py +++ b/pylib/gp_codegen/pixeltype.py @@ -2,11 +2,34 @@ # gfxprim.pixeltype - Module with PixelType descrition class # # 2011 - Tomas Gavenciak gavento@ucw.cz +# 2013 Cyril Hrubis metan@ucw.cz #
import re from .pixelsize import PixelSize
+class PixelChannel(list): + def __init__(self, triplet): + (name, offset, size) = triplet + # Create the list -> backward compatibility with triplets + self.append(name) + self.append(offset) + self.append(size) + # Add some convinience variables + self.name = name + self.off = offset + self.size = size + # Shift ready to used in C + self.C_shift = " << " + hex(offset) + # Maximal channel value as an integer + self.max = 2 ** size - 1 + # Maximal value as a C string + self.C_max = hex(self.max) + # Chanel bitmask as int + self.mask = self.max * (2 ** offset) + # Channel bitmas as hex string + self.C_mask = hex(self.mask) + class PixelType(object): """Representation of one GP_PixelType"""
@@ -20,14 +43,21 @@ class PixelType(object): """ assert re.match('A[A-Za-z][A-Za-z0-9_]*Z', name) self.name = name - self.chanslist = chanslist + # Create channel list with convinience variables + new_chanslist = [] + for i in chanslist: + new_chanslist.append(PixelChannel(i)) + self.chanslist = new_chanslist self.chans = dict() # { chan_name: (offset, size) } self.pixelsize = pixelsize + # C enum as defined in GP_Pixel.gen.h + self.C_enum = "GP_PIXEL_" + self.name +
# Verify channel bits for overlaps # also builds a bit-map of the PixelType self.bits = ['x'] * pixelsize.size - for c in chanslist: + for c in new_chanslist: assert c[0] not in self.chans.keys() self.chans[c[0]] = c for i in range(c[1], c[1] + c[2]): diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t new file mode 100644 index 0000000..6f445e2 --- /dev/null +++ b/tests/core/Convert.gen.c.t @@ -0,0 +1,165 @@ +/***************************************************************************** + * 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_Convert.h> + +#include "tst_test.h" + +/* + * Returns black color for particular pixel type. + */ +static GP_Pixel get_black(GP_PixelType pixel_type) +{ + switch (pixel_type) { +%% for pt in pixeltypes + case GP_PIXEL_{{ pt.name }}: +%% if pt.is_cmyk() +%% set K = pt.chans['K'] + /* Black in CMYK is full K rest zero */ + return {{ hex((2 ** K[2] - 1) * (2 ** K[1]))}}; +%% elif pt.is_alpha() +%% set A = pt.chans['A'] + /* Black with Alpha channel is full A rest zero */ + return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}}; +%% else + return 0; +%% 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) +{ + switch (pixel_type) { +%% for pt in pixeltypes + case GP_PIXEL_{{ pt.name }}: +%% if pt.is_cmyk() +%% set M = pt.chans['M'] +%% set Y = pt.chans['Y'] + /* Red in CMYK is full M and Y rest zero */ + return {{ hex((2 ** M[2] - 1) * (2 ** M[1]))}} + | {{ hex((2 ** Y[2] - 1) * (2 ** Y[1]))}}; +%% elif pt.is_rgb() +%% set R = pt.chans['R'] +%% if pt.is_alpha() +%% set A = pt.chans['A'] + /* Red with Alpha channel is full Alpha and R rest zero */ + return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}} + | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}}; +%% else + /* Plain old RGB */ + return {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}}; +%% endif +%% elif pt.is_gray() +%% set V = pt.chans['V'] +%% if pt.is_alpha() +%% set A = pt.chans['A'] + /* Grayscale with Alpha channel is full Alpha + 1/3 Gray */ + return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}}; + | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}}; +%% else + /* Grayscale is 1/3 Gray */ + return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}}; +%% endif +%% else + tst_msg("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); + } +} + +%% macro gen_convert_and_check(test_name, in_name, out_name) +static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(void) +{ + GP_Pixel out = 0; + GP_Pixel in = get_{{ test_name }}(GP_PIXEL_{{ in_name }}); + GP_Pixel out_exp = get_{{ test_name }}(GP_PIXEL_{{ out_name }}); + + GP_Pixel_{{ in_name }}_TO_{{ out_name }}(in, out); + + if (out_exp != out) { + tst_msg("Pixels are different have %08x, expected %08x", + out, out_exp); + return TST_FAILED; + } + + return TST_SUCCESS; +} +%% endmacro + +%% macro gen_converts() +%% for pt1 in pixeltypes +%% if not pt1.is_unknown() and not pt1.is_palette() +%% for pt2 in pixeltypes +%% if pt2.name in ['RGB888', 'RGBA8888'] +{{ gen_convert_and_check('black', pt2.name, pt1.name) }} +{{ gen_convert_and_check('red', pt2.name, pt1.name) }} +%% endif +%% endfor +%% endif +%% endfor +%% endmacro + +{{ gen_converts() }} + +%% macro gen_suite_entry(name, from, to) + {.name = "Convert {{ name }} {{ from }} -> {{ to }}", + .tst_fn = convert_and_check_{{ name }}_{{ from }}_to_{{ to }}}, +%% endmacro + +const struct tst_suite tst_suite = { + .suite_name = "Pixel Conversions Testsuite", + .tests = { +%% for pt1 in pixeltypes +%% if not pt1.is_unknown() and not pt1.is_palette() +%% for pt2 in pixeltypes +%% if pt2.name in ['RGB888', 'RGBA8888'] +{{ gen_suite_entry('black', pt2.name, pt1.name) }} +{{ gen_suite_entry('red', pt2.name, pt1.name) }} +%% endif +%% endfor +%% endif +%% endfor + +{{ gen_suite_entry('red', 'RGB888', 'CMYK8888') }} + + {.name = NULL} + } +}; + +%% endblock body
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Convert.gen.h.t | 40 ++++---- pylib/gp_codegen/pixeltype.py | 34 ++++++- tests/core/Convert.gen.c.t | 227 +++++++++++++++++++++++++++++++++++++++ tests/core/Makefile | 4 +- tests/core/test_list.txt | 1 + 5 files changed, 282 insertions(+), 24 deletions(-) create mode 100644 tests/core/Convert.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.