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, generate has been updated via b7f10b82d579dfb7878335336b0d016f5343f793 (commit) via 132422504ff084746df93675292ee937a946d105 (commit) via 617420b08642f72170638b2f543022c61600e96c (commit) via efa0c0660b9db3601452b32864d0ef114a72e0ce (commit) via b5426313d22d110cc0d9f26d273c5e19c5632687 (commit) via abbcc7e4e20f3d131b2c7fe46895089d2980dc94 (commit) via 092a846fd82550f4435b5396a7e48e789afdd0bc (commit) via 402eaabcf521cf1e6e0643b2d140e4b9dcf3f10a (commit) via d1f7f07b180f153f0eb40e54230537e8495871e9 (commit) via e22c5773aab5f5b5681f9f2d606ebd9eeb4fea7b (commit) via 70a840f2dde4591281025f8acb0374004d8d0e44 (commit) via fe2f2b950ec689827669756925914f61a9f584ab (commit) via 85a6fffce341ae7b993b80fefecb97c1619636e4 (commit) via ebd807bf4a3a9c1f916dff933c16536c4ef2261c (commit) via d01f20fa8ffaa7959891751f12ef3195a7cfbde7 (commit) via 2139339c8854d942378361854f6e1f7c5781b9b1 (commit) via 777062b642ebcecb14a3a8944ff4afd25d145eb7 (commit) via 6d267ad031a775ffb3e7e73a5357a7600e7b96f0 (commit) via 50e68bdcafa2e379597a3c454343c4f3b2c7db73 (commit) via e8872dfaab48d1f16b749fbd0ea698a6b7ce86ae (commit) via d7551ce7958fc44a3a9e070258d3c8a45a23f755 (commit) via 413daca73ab16f53c9fd81410c261bc7628d2e11 (commit) from abf38d0ef10e4cd84391950b1595cfc60dcf3181 (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/b7f10b82d579dfb7878335336b0d016f5343f...
commit b7f10b82d579dfb7878335336b0d016f5343f793 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 01:01:58 2011 +0200
Add test OBJs to CLEAN in tests.mk
diff --git a/tests.mk b/tests.mk index 846e4f9..e4cf3bb 100644 --- a/tests.mk +++ b/tests.mk @@ -26,7 +26,7 @@ ${TESTSUITE_GEN}: $(filter-out ${TESTSUITE_GEN},${GENSOURCES}) ${GENHEADERS} TESTSUITE_SRCS=$(wildcard *.test.c) ${GENSOURCES} ${GENHEADERS} ${GP_TESTLIB_SRCS} INCLUDE+=../tests/common TESTSUITE_OBJS=$(patsubst %.c,%.o,$(TESTSUITE_SRCS)) -CLEAN+=${TESTSUITE} +CLEAN+=${TESTSUITE} ${TESTSUITE_OBJS} TESTS+=${TESTSUITE}
${TESTSUITE}: ${TESTSUITE_OBJS}
http://repo.or.cz/w/gfxprim.git/commit/132422504ff084746df93675292ee937a946d...
commit 132422504ff084746df93675292ee937a946d105 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 00:58:10 2011 +0200
Fix naive blit typo
diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c index 76c7a2c..251272d 100644 --- a/libs/core/GP_Blit.c +++ b/libs/core/GP_Blit.c @@ -23,6 +23,7 @@ #include "GP_Pixel.h" #include "GP_GetPutPixel.h" #include "GP_Context.h" +#include "GP_Convert.h" #include "GP_Blit.h"
/* @@ -69,7 +70,7 @@ void GP_Blit_Naive(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_Size w, GP for (int j = 0; j < h; j++) { GP_Pixel p = GP_GetPixel(c1, x1 + i, y1 + j); if (c1->pixel_type != c2->pixel_type) - p = GP_GP_ConvertContextPixel(p, c1, c2); + p = GP_ConvertContextPixel(p, c1, c2); GP_PutPixel(c2, x2 + i, y2 + j, p); } }
http://repo.or.cz/w/gfxprim.git/commit/617420b08642f72170638b2f543022c61600e...
commit 617420b08642f72170638b2f543022c61600e96c Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 00:57:24 2011 +0200
Improve and extend GP_Convert gen. tests
diff --git a/pylib/gfxprim/generators/core/make_GP_Convert.py b/pylib/gfxprim/generators/core/make_GP_Convert.py index 41637ca..dfd23dd 100644 --- a/pylib/gfxprim/generators/core/make_GP_Convert.py +++ b/pylib/gfxprim/generators/core/make_GP_Convert.py @@ -76,8 +76,26 @@ def core_GP_Convert_gen_h(c): '{n' ' GP_Pixel p1 = GP_RandomColor(GP_PIXEL_{{ t.name }});n' ' GP_Pixel p2 = GP_ConvertPixel(p1, GP_PIXEL_{{ t.name }}, GP_PIXEL_RGBA8888);n' - ' GP_Pixel p3 = GP_ConvertPixel(p1, GP_PIXEL_RGBA8888, GP_PIXEL_{{ t.name }});n' - ' fail_unless(GP_EqualColors(p1, GP_PIXEL_{{ t.name }}, p3, GP_PIXEL_{{ t.name }}));n' - ' fail_unless(GP_EqualColors(p1, GP_PIXEL_{{ t.name }}, p2, GP_PIXEL_{{ t.name }}));n' - '}nn' - 'GP_ENDTESTn', t=t) + ' GP_Pixel p3 = GP_ConvertPixel(p2, GP_PIXEL_RGBA8888, GP_PIXEL_{{ t.name }});n' + ' GP_CHECK_EqualColors(p1, GP_PIXEL_{{ t.name }}, p3, GP_PIXEL_{{ t.name }});n' + ' GP_CHECK_EqualColors(p1, GP_PIXEL_{{ t.name }}, p2, GP_PIXEL_RGBA8888);n' + '}n' + 'GP_ENDTESTnn', t=t) + c.rbody( + 'GP_TEST(WhiteStaysWhite_via_{{ t.name }}, "loop_start=0, loop_end=4")n' + '{n' + ' GP_Pixel p1 = GP_RGBToPixel(255, 255, 255, GP_PIXEL_RGB888);n' + ' GP_Pixel p2 = GP_RGB888ToPixel(p1, GP_PIXEL_{{ t.name }});n' + ' GP_Pixel p3 = GP_PixelToRGB888(p2, GP_PIXEL_{{ t.name }});n' + ' GP_CHECK_EqualColors(p1, GP_PIXEL_RGB888, p3, GP_PIXEL_RGB888);n' + '}n' + 'GP_ENDTESTnn', t=t) + c.rbody( + 'GP_TEST(BlackStaysBlack_via_{{ t.name }}, "loop_start=0, loop_end=4")n' + '{n' + ' GP_Pixel p1 = GP_RGBToPixel(0, 0, 0, GP_PIXEL_RGB888);n' + ' GP_Pixel p2 = GP_RGB888ToPixel(p1, GP_PIXEL_{{ t.name }});n' + ' GP_Pixel p3 = GP_PixelToRGB888(p2, GP_PIXEL_{{ t.name }});n' + ' GP_CHECK_EqualColors(p1, GP_PIXEL_RGB888, p3, GP_PIXEL_RGB888);n' + '}n' + 'GP_ENDTESTnn', t=t)
http://repo.or.cz/w/gfxprim.git/commit/efa0c0660b9db3601452b32864d0ef114a72e...
commit efa0c0660b9db3601452b32864d0ef114a72e0ce Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 00:56:55 2011 +0200
Bix fix in pixel value scaling
DUH
diff --git a/pylib/gfxprim/generators/core/make_GP_Convert.py b/pylib/gfxprim/generators/core/make_GP_Convert.py index 249763d..41637ca 100644 --- a/pylib/gfxprim/generators/core/make_GP_Convert.py +++ b/pylib/gfxprim/generators/core/make_GP_Convert.py @@ -26,11 +26,11 @@ def core_GP_Pixel_Scale_gen(h):
"{% for s1 in range(1,9) %}{% for s2 in range(1,9) %}" "{% if s2>s1 %}" - "#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) ((val) * {{ multcoef(s1, s2) }})n" + "#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) (((val) * {{ multcoef(s1, s2) }}) >> {{ (-s2) % s1 }})n" "{% else %}" "#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) ((val) >> {{ s1 - s2 }})n" "{% endif %}" - "{% endfor %}{% endfor %}", multcoef = lambda s1,s2: hex(sum([1<<i*s1 for i in range(s2/s1)])) + "{% endfor %}{% endfor %}", multcoef = lambda s1,s2: hex(sum([1<<(i*s1) for i in range((s2+s1-1)/s1)])) )
http://repo.or.cz/w/gfxprim.git/commit/b5426313d22d110cc0d9f26d273c5e19c5632...
commit b5426313d22d110cc0d9f26d273c5e19c5632687 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 00:56:17 2011 +0200
Minor header inclusion
diff --git a/include/core/GP_Convert.h b/include/core/GP_Convert.h index aeb5acf..6dd9d61 100644 --- a/include/core/GP_Convert.h +++ b/include/core/GP_Convert.h @@ -25,6 +25,7 @@
#include "GP_Common.h" #include "GP_Context.h" +#include "GP_Pixel.h"
/* Generated headers */ #include "GP_Convert.gen.h"
http://repo.or.cz/w/gfxprim.git/commit/abbcc7e4e20f3d131b2c7fe46895089d2980d...
commit abbcc7e4e20f3d131b2c7fe46895089d2980dc94 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 00:55:33 2011 +0200
Added hand-made smoke tests for GP_Convert
diff --git a/tests/core/GP_Convert.test.c b/tests/core/GP_Convert.test.c new file mode 100644 index 0000000..3f80a3a --- /dev/null +++ b/tests/core/GP_Convert.test.c @@ -0,0 +1,27 @@ +/* + * 2011 - Tomas Gavenciak gavento@ucw.cz + */ + +#include "GP_Tests.h" +#include "GP_Convert.h" +#include "GP_TestingCore.h" + +GP_SUITE(GP_Convert) + +GP_TEST(BasicPixelConversions) +{ + GP_Pixel p1, p2; + p1 = GP_RGBAToPixel(255, 255, 255, 255, GP_PIXEL_RGBA8888); + fail_unless(p1 == 0xffffffff); + p1 = GP_RGBAToPixel(0, 0, 0, 0, GP_PIXEL_RGBA8888); + fail_unless(p1 == 0x0); + p1 = GP_RGBToPixel(0x12, 0x34, 0x56, GP_PIXEL_RGB888); + fail_unless(p1 == 0x563412); + GP_CHECK_EqualColors(p1, GP_PIXEL_RGB888, p1, GP_PIXEL_RGB888); + + p1 = GP_RGB888ToPixel(GP_RGBToPixel(0x12, 0x34, 0x56, GP_PIXEL_RGB888), GP_PIXEL_V4); + p2 = GP_RGBAToPixel(0x12, 0x34, 0x56, 0x78, GP_PIXEL_V2); + GP_CHECK_EqualColors(p1, GP_PIXEL_V4, p2, GP_PIXEL_V2); +} +GP_ENDTEST +
http://repo.or.cz/w/gfxprim.git/commit/092a846fd82550f4435b5396a7e48e789afdd...
commit 092a846fd82550f4435b5396a7e48e789afdd0bc Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 00:54:19 2011 +0200
Extended pixel equality in tests, fixed GP_CHECK_EqualColors
but still TODO find better definition of color equality
diff --git a/tests/common/GP_TestingCore.c b/tests/common/GP_TestingCore.c index afa2754..501a66a 100644 --- a/tests/common/GP_TestingCore.c +++ b/tests/common/GP_TestingCore.c @@ -43,11 +43,27 @@ void GP_RandomizeRect(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, GP GP_PutPixel(context, i + x, j + y, GP_RandomColor(context->pixel_type)); }
+/* TODO: Proper equality definition (currently almost ad-hoc */ int GP_EqualColors(GP_Pixel p1, GP_PixelType t1, GP_Pixel p2, GP_PixelType t2) { - GP_Pixel col1 = GP_PixelToRGBA8888(p1, t1); - GP_Pixel col2 = GP_PixelToRGBA8888(p2, t2); - return (col1 & 0xffffffff) == (col2 & 0xffffffff); + int size1 = GP_PixelTypes[t1].size; + int size2 = GP_PixelTypes[t2].size; + + // Same type + if (t1 == t2) + return GP_GET_BITS(0, size1, p1) == GP_GET_BITS(0, size1, p2); + + // t1 -> RGBA8888 -> t2 + GP_Pixel conv1 = GP_RGBA8888ToPixel(GP_PixelToRGBA8888(p1, t1), t2); + if (GP_GET_BITS(0, size2, conv1) == GP_GET_BITS(0, size2, p2)) + return 1; + + // t2 -> RGBA8888 -> t1 + GP_Pixel conv2 = GP_RGBA8888ToPixel(GP_PixelToRGBA8888(p2, t2), t1); + if (GP_GET_BITS(0, size1, conv2) == GP_GET_BITS(0, size1, p1)) + return 1; + + return 0; }
int GP_EqualRects(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_Size w, GP_Size h, diff --git a/tests/common/GP_TestingCore.h b/tests/common/GP_TestingCore.h index 0e4b726..31d2d1f 100644 --- a/tests/common/GP_TestingCore.h +++ b/tests/common/GP_TestingCore.h @@ -52,8 +52,8 @@ int GP_EqualColors(GP_Pixel p1, GP_PixelType t1, GP_Pixel p2, GP_PixelType t2); char b1[256], b2[256]; GP_PixelSNPrint(b1, 256, p1, t1); GP_PixelSNPrint(b2, 256, p2, t2); - GP_CHECK("Pixel colors %s and %s are not the same color.", b1, b2); - } while (0); + GP_ABORT("Pixels %s and %s are not the same color.", b1, b2); + } } while (0);
/* * Compare two rectangles in two contexts. Return 1 on equal.
http://repo.or.cz/w/gfxprim.git/commit/402eaabcf521cf1e6e0643b2d140e4b9dcf3f...
commit 402eaabcf521cf1e6e0643b2d140e4b9dcf3f10a Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 00:52:01 2011 +0200
Added GP_PixelSNPrint (similar to snprintf())
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h index ec78c04..7250179 100644 --- a/include/core/GP_Pixel.h +++ b/include/core/GP_Pixel.h @@ -34,6 +34,7 @@ #include "GP_Color.h" #include "GP_Common.h" #include "GP_RetCode.h" +#include "GP_FnPerBpp.h"
struct GP_Context;
@@ -136,4 +137,23 @@ static inline uint32_t GP_PixelSize(GP_PixelType type) return GP_PixelTypes[type].size; }
+/* + * Print a human-readable representation of a pixel value to a string. + * Arguments as for snprintf(). + */ +static inline void GP_PixelSNPrint(char *buf, size_t len, GP_Pixel pixel, GP_PixelType type) +{ + GP_FN_PER_PIXELTYPE(GP_PixelSNPrint, type, buf, len, pixel); +} + +/* + * "printf" out a human-readable representation of pixel value. + */ +static inline void GP_PixelPrint(GP_Pixel pixel, GP_PixelType type) +{ + char buf[256]; + GP_PixelSNPrint(buf, 256, pixel, type); + printf("%s", buf); +} + #endif /* GP_PIXEL_H */ diff --git a/pylib/gfxprim/generators/core/gen_pixeltype.py b/pylib/gfxprim/generators/core/gen_pixeltype.py index f6aa886..680a476 100644 --- a/pylib/gfxprim/generators/core/gen_pixeltype.py +++ b/pylib/gfxprim/generators/core/gen_pixeltype.py @@ -63,15 +63,15 @@ def gen_GP_PixelTypes(header, code): '};n', sorted_pts=sorted_pts, len=len)
def gen_print(ptype, header, code): - "Generate a GP_Pixel_Print_<TYPE> function (source and header)" + "Generate a GP_PixelSNPrint_<TYPE> function (source and header)" header.rbody( - "/* print formatted value of pixel type {{ f.name }} */n" - "void GP_PixelPrint_{{ f.name }}(GP_Pixel p);n", f=ptype) + "/* snprintf a human readable value of pixel type {{ f.name }} */n" + "void GP_PixelSNPrint_{{ f.name }}(char *buf, size_t len, GP_Pixel p);n", f=ptype) code.rbody( - "/* print formatted value of pixel type {{f.name}} */n" - "void GP_PixelPrint_{{ f.name }}(GP_Pixel p)n" + "/* snprintf a human readable value of pixel type {{f.name}} */n" + "void GP_PixelSNPrint_{{ f.name }}(char *buf, size_t len, GP_Pixel p)n" "{n" - ' printf("<{{ f.name }} %0{{ (f.size+3)//4 }}x{% for c in f.chanslist %} {{ c[0] }}=%d{% endfor %}>",n' + ' snprintf(buf, len, "<{{ f.name }} 0x%0{{ (f.size+3)//4 }}x{% for c in f.chanslist %} {{ c[0] }}=%d{% endfor %}>",n' " GP_GET_BITS(0, {{ f.size }}, p)" "{% for c in f.chanslist %}" ",n GP_GET_BITS({{ c[1] }}, {{ c[2] }}, p)"
http://repo.or.cz/w/gfxprim.git/commit/d1f7f07b180f153f0eb40e54230537e849587...
commit d1f7f07b180f153f0eb40e54230537e8495871e9 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 00:26:58 2011 +0200
Added debugging macros GP_GET_BITS_DBG and GP_SET_BITS_DBG
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h index 48a1167..cda1967 100644 --- a/include/core/GP_Common.h +++ b/include/core/GP_Common.h @@ -141,6 +141,12 @@ #define GP_GET_BITS(offset, count, val) ( ( (val)>>(offset) ) & ( ((((typeof(val))1)<<(count)) - 1) ) )
/* + * Debugging version, evaluates args twice. + */ +#define GP_GET_BITS_DBG(offset, count, val) ( printf("GET_BITS(%d, %d, 0x%x)=%d", offset, count, val, + GP_GET_BITS(offset, count, val)), GP_GET_BITS(offset, count, val)) + +/* * Set count bits of dest at ofset to val (shifted by offset) * * Does not check val for overflow @@ -160,6 +166,14 @@ GP_SET_BITS_OR(offset, dest, val); } while (0)
+/* + * Debugging version, evaluates args twice. + */ +#define GP_SET_BITS_DBG(offset, count, dest, val) do { + GP_SET_BITS(offset, count, dest, val); + printf("SET_BITS(%d, %d, p, %d)n", offset, count, val); + } while (0) +
/* Determines the sign of the integer value; it is +1 if value is positive, * -1 if negative, and 0 if it is zero.
http://repo.or.cz/w/gfxprim.git/commit/e22c5773aab5f5b5681f9f2d606ebd9eeb4fe...
commit e22c5773aab5f5b5681f9f2d606ebd9eeb4fea7b Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Jun 13 00:25:50 2011 +0200
Added GP_CHECK_EqualColors macro
diff --git a/tests/common/GP_TestingCore.h b/tests/common/GP_TestingCore.h index 23ea12a..0e4b726 100644 --- a/tests/common/GP_TestingCore.h +++ b/tests/common/GP_TestingCore.h @@ -45,6 +45,17 @@ void GP_RandomizeRect(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, GP int GP_EqualColors(GP_Pixel p1, GP_PixelType t1, GP_Pixel p2, GP_PixelType t2);
/* + * Macro version with GP_CHECK + */ +#define GP_CHECK_EqualColors(p1, t1, p2, t2) do { + if (!GP_EqualColors(p1, t1, p2, t2)) { + char b1[256], b2[256]; + GP_PixelSNPrint(b1, 256, p1, t1); + GP_PixelSNPrint(b2, 256, p2, t2); + GP_CHECK("Pixel colors %s and %s are not the same color.", b1, b2); + } while (0); + +/* * Compare two rectangles in two contexts. Return 1 on equal. * The colors are cmpared by first converting them to RGBA8888. * Somewhat inefficient.
http://repo.or.cz/w/gfxprim.git/commit/70a840f2dde4591281025f8acb0374004d8d0...
commit 70a840f2dde4591281025f8acb0374004d8d0e44 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 22:46:52 2011 +0200
Added GP_FN_(RET_)PER_PIXELTYPE switch-branching generation
diff --git a/pylib/gfxprim/generators/core/make_GP_Pixel.py b/pylib/gfxprim/generators/core/make_GP_Pixel.py index 05cc28e..fd5b16c 100644 --- a/pylib/gfxprim/generators/core/make_GP_Pixel.py +++ b/pylib/gfxprim/generators/core/make_GP_Pixel.py @@ -41,6 +41,19 @@ def core_GP_Pixel_gen(h, c): gen_get_pixel_addr(t, h, c) gen_create(t, h, c)
+ ## FnPerPixelType and FnRetPerPixelType + for r in ['', 'return ']: + h.rbody( + 'n/* Macro for branching on PixelType (similar to GP_FnPerBpp macros) */n' + '#define GP_FN_{% if r %}RET_{% endif %}PER_PIXELTYPE(FN_NAME, type, ...) ' + ' switch (type) { ' + '{% for t in types %}{% if t.number != 0 %}' + ' case GP_PIXEL_{{ t.name }}: ' + ' {{ r }}FN_NAME##_{{ t.name }}(__VA_ARGS__); ' + ' break; ' + '{% endif %}{% endfor %}' + ' default: GP_ABORT("Invalid PixelType %d", type); ' + ' }nn', types=pixeltypes.values(), r=r)
@generator(CHeaderGenerator(name = 'GP_GetPutPixel.gen.h'), descr = 'Access pixel bytes, Get and PutPixelnDo not include directly, use GP_Pixel.h',
http://repo.or.cz/w/gfxprim.git/commit/fe2f2b950ec689827669756925914f61a9f58...
commit fe2f2b950ec689827669756925914f61a9f584ab Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 22:37:10 2011 +0200
Rename some helpers in FnPerBpp (colision with planned code)
diff --git a/include/core/GP_FnPerBpp.h b/include/core/GP_FnPerBpp.h index bc76178..79361b0 100644 --- a/include/core/GP_FnPerBpp.h +++ b/include/core/GP_FnPerBpp.h @@ -44,13 +44,13 @@ /* * Branch on GP_Context argument. */ -#define GP_FN_PER_CONTEXT(FN_NAME, context, ...) +#define GP_FN_PER_BPP_CONTEXT(FN_NAME, context, ...) GP_FN_PER_BPP(FN_NAME, (context)->bpp, (context)->bit_endian, __VA_ARGS__)
/* * Branch on GP_PixelType argument. */ -#define GP_FN_PER_PIXELTYPE(FN_NAME, type, ...) +#define GP_FN_PER_BPP_PIXELTYPE(FN_NAME, type, ...) GP_FN_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__)
/* @@ -102,13 +102,13 @@ /* * Branch on GP_Context argument. */ -#define GP_FN_RET_PER_CONTEXT(FN_NAME, context, ...) +#define GP_FN_RET_PER_BPP_CONTEXT(FN_NAME, context, ...) GP_FN_RET_PER_BPP(FN_NAME, (context)->bpp, (context)->bit_endian, __VA_ARGS__)
/* * Branch on GP_PixelType argument. */ -#define GP_FN_RET_PER_PIXELTYPE(FN_NAME, type, ...) +#define GP_FN_RET_PER_BPP_PIXELTYPE(FN_NAME, type, ...) GP_FN_RET_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__)
/*
http://repo.or.cz/w/gfxprim.git/commit/85a6fffce341ae7b993b80fefecb97c161963...
commit 85a6fffce341ae7b993b80fefecb97c1619636e4 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 22:31:39 2011 +0200
Rename GP_Pixel_Print_* to GP_PixelPrint_*
diff --git a/pylib/gfxprim/generators/core/gen_pixeltype.py b/pylib/gfxprim/generators/core/gen_pixeltype.py index ba25a20..f6aa886 100644 --- a/pylib/gfxprim/generators/core/gen_pixeltype.py +++ b/pylib/gfxprim/generators/core/gen_pixeltype.py @@ -66,10 +66,10 @@ def gen_print(ptype, header, code): "Generate a GP_Pixel_Print_<TYPE> function (source and header)" header.rbody( "/* print formatted value of pixel type {{ f.name }} */n" - "void GP_Pixel_Print_{{ f.name }}(GP_Pixel p);n", f=ptype) + "void GP_PixelPrint_{{ f.name }}(GP_Pixel p);n", f=ptype) code.rbody( "/* print formatted value of pixel type {{f.name}} */n" - "void GP_Pixel_Print_{{ f.name }}(GP_Pixel p)n" + "void GP_PixelPrint_{{ f.name }}(GP_Pixel p)n" "{n" ' printf("<{{ f.name }} %0{{ (f.size+3)//4 }}x{% for c in f.chanslist %} {{ c[0] }}=%d{% endfor %}>",n' " GP_GET_BITS(0, {{ f.size }}, p)"
http://repo.or.cz/w/gfxprim.git/commit/ebd807bf4a3a9c1f916dff933c16536c4ef22...
commit ebd807bf4a3a9c1f916dff933c16536c4ef2261c Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 22:30:41 2011 +0200
Added helpers and documentation to FnPerBpp
diff --git a/include/core/GP_FnPerBpp.h b/include/core/GP_FnPerBpp.h index ed2356d..bc76178 100644 --- a/include/core/GP_FnPerBpp.h +++ b/include/core/GP_FnPerBpp.h @@ -24,17 +24,44 @@ *****************************************************************************/
/* - * Macro that generates a switch-case block that calls various variants - * of the specified function depending on the bit depth of the context. + * Macros that generate a switch-case block that calls various variants + * of the specified function depending on the bit depth (bpp). + * + * For function name y and x bpp, the function called will be + * y_xBPP, resp y_xBPP_LE (or _BE; the bit-endian) for x<8. + * + * The functions branch either on bpp and bit_endian, type of given + * GP_Context or given GP_PixelType. + * * Extra arguments are arguments to be passed to the function. - * Returns GP_ENOIMPL if the bit depth is unknown. + * Note that if the function takes the context/type/bpp as an argument, + * you still need to provide it in __VA_ARGS__ + * + * The GP_FN_PER_* variants ignore the return value of the called function. + * The GP_FN_RET_PER_* variants "return"s the value returned by the function. + */ + +/* + * Branch on GP_Context argument. + */ +#define GP_FN_PER_CONTEXT(FN_NAME, context, ...) + GP_FN_PER_BPP(FN_NAME, (context)->bpp, (context)->bit_endian, __VA_ARGS__) + +/* + * Branch on GP_PixelType argument. + */ +#define GP_FN_PER_PIXELTYPE(FN_NAME, type, ...) + GP_FN_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__) + +/* + * Branch on bpp and bit_endian. */ #define GP_FN_PER_BPP(FN_NAME, bpp, bit_endian, ...) switch (bpp) { case 1: {- if (bit_endian==GP_BIT_ENDIAN_LE)+ if (bit_endian == GP_BIT_ENDIAN_LE) FN_NAME##_1BPP_LE(__VA_ARGS__); else FN_NAME##_1BPP_BE(__VA_ARGS__);@@ -42,7 +69,7 @@ break; case 2: {- if (bit_endian==GP_BIT_ENDIAN_LE)+ if (bit_endian == GP_BIT_ENDIAN_LE) FN_NAME##_2BPP_LE(__VA_ARGS__); else FN_NAME##_2BPP_BE(__VA_ARGS__);@@ -50,7 +77,7 @@ break; case 4: {- if (bit_endian==GP_BIT_ENDIAN_LE)+ if (bit_endian == GP_BIT_ENDIAN_LE) FN_NAME##_4BPP_LE(__VA_ARGS__); else FN_NAME##_4BPP_BE(__VA_ARGS__);@@ -72,26 +99,41 @@ break; } +/* + * Branch on GP_Context argument. + */ +#define GP_FN_RET_PER_CONTEXT(FN_NAME, context, ...) + GP_FN_RET_PER_BPP(FN_NAME, (context)->bpp, (context)->bit_endian, __VA_ARGS__) + +/* + * Branch on GP_PixelType argument. + */ +#define GP_FN_RET_PER_PIXELTYPE(FN_NAME, type, ...) + GP_FN_RET_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__) + +/* + * Branch on bpp and bit_endian. + */ #define GP_FN_RET_PER_BPP(FN_NAME, bpp, bit_endian, ...) switch (bpp) { case 1: {- if (bit_endian==GP_BIT_ENDIAN_LE)+ if (bit_endian == GP_BIT_ENDIAN_LE) return FN_NAME##_1BPP_LE(__VA_ARGS__); else return FN_NAME##_1BPP_BE(__VA_ARGS__); } case 2: {- if (bit_endian==GP_BIT_ENDIAN_LE)+ if (bit_endian == GP_BIT_ENDIAN_LE) return FN_NAME##_2BPP_LE(__VA_ARGS__); else return FN_NAME##_2BPP_BE(__VA_ARGS__); } case 4: {- if (bit_endian==GP_BIT_ENDIAN_LE)+ if (bit_endian == GP_BIT_ENDIAN_LE) return FN_NAME##_4BPP_LE(__VA_ARGS__); else return FN_NAME##_4BPP_BE(__VA_ARGS__); http://repo.or.cz/w/gfxprim.git/commit/d01f20fa8ffaa7959891751f12ef3195a7cfb...
commit d01f20fa8ffaa7959891751f12ef3195a7cfbde7 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 22:00:52 2011 +0200
Added generated test for GP_Convert
Failing so far
diff --git a/pylib/gfxprim/generators/core/make_GP_Convert.py b/pylib/gfxprim/generators/core/make_GP_Convert.py index 633f6cc..249763d 100644 --- a/pylib/gfxprim/generators/core/make_GP_Convert.py +++ b/pylib/gfxprim/generators/core/make_GP_Convert.py @@ -12,6 +12,7 @@ from gfxprim.generators.generator import * from gfxprim.generators.pixeltype import * from gfxprim.generators.core.gen_convert import *
+ @generator(CHeaderGenerator(name = 'GP_Convert_Scale.gen.h'), descr = 'Fast value scaling macros', authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) @@ -32,6 +33,7 @@ def core_GP_Pixel_Scale_gen(h): "{% endfor %}{% endfor %}", multcoef = lambda s1,s2: hex(sum([1<<i*s1 for i in range(s2/s1)])) )
+ @generator(CHeaderGenerator(name = 'GP_Convert.gen.h'), CSourceGenerator(name = 'GP_Convert.gen.c'), descr = 'Convert PixelType values macros and functions', @@ -58,11 +60,24 @@ def core_GP_Convert_gen_h(h, c): gen_convert_to(pixeltypes['RGBA8888'], pixeltypes['V2'], h, c) gen_convert_to(pixeltypes['VA12'], pixeltypes['RGBA8888'], h, c)
+ @generator(CSourceGenerator(name = 'GP_Convert.test.gen.c'), descr = 'GP_Convert tests', authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) def core_GP_Convert_gen_h(c): c.rhead('#include "GP_Tests.h"n') - c.rhead('#include "GP_Convert.h"nn') + c.rhead('#include "GP_Convert.h"n') + c.rhead('#include "GP_TestingCore.h"nn') c.rhead('GP_SUITE(GP_Convert)nn') - c.rbody('GP_TEST(triv)n{}nGP_ENDTESTn') + for t in pixeltypes.values(): + if not t.is_palette() and t.number != 0: + c.rbody( + 'GP_TEST(GP_ConvertPixel_for_{{ t.name }}, "loop_start=0, loop_end=4")n' + '{n' + ' GP_Pixel p1 = GP_RandomColor(GP_PIXEL_{{ t.name }});n' + ' GP_Pixel p2 = GP_ConvertPixel(p1, GP_PIXEL_{{ t.name }}, GP_PIXEL_RGBA8888);n' + ' GP_Pixel p3 = GP_ConvertPixel(p1, GP_PIXEL_RGBA8888, GP_PIXEL_{{ t.name }});n' + ' fail_unless(GP_EqualColors(p1, GP_PIXEL_{{ t.name }}, p3, GP_PIXEL_{{ t.name }}));n' + ' fail_unless(GP_EqualColors(p1, GP_PIXEL_{{ t.name }}, p2, GP_PIXEL_{{ t.name }}));n' + '}nn' + 'GP_ENDTESTn', t=t)
http://repo.or.cz/w/gfxprim.git/commit/2139339c8854d942378361854f6e1f7c5781b...
commit 2139339c8854d942378361854f6e1f7c5781b9b1 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 21:57:08 2011 +0200
Fix a bug (arg. order)
diff --git a/include/core/GP_Convert.h b/include/core/GP_Convert.h index dff93e6..aeb5acf 100644 --- a/include/core/GP_Convert.h +++ b/include/core/GP_Convert.h @@ -96,7 +96,7 @@ static inline GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g, uint8_t b, ui */ static inline GP_Pixel GP_ConvertPixel(GP_Pixel pixel, GP_PixelType from, GP_PixelType to) { - return GP_RGBA8888ToPixel(GP_PixelToRGBA8888(from, pixel), to); + return GP_RGBA8888ToPixel(GP_PixelToRGBA8888(pixel, from), to); }
/*
http://repo.or.cz/w/gfxprim.git/commit/777062b642ebcecb14a3a8944ff4afd25d145...
commit 777062b642ebcecb14a3a8944ff4afd25d145eb7 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 21:54:24 2011 +0200
Add random gen initialization to testing, move testing files
diff --git a/tests.mk b/tests.mk index 2dc8df3..846e4f9 100644 --- a/tests.mk +++ b/tests.mk @@ -14,7 +14,7 @@ endif
ifdef TESTSUITE # a bit crude way to link with test minilibrary -GP_TESTLIB_SRCS=${TOPDIR}/tests/common/GP_Tests.c +GP_TESTLIB_SRCS=$(wildcard ${TOPDIR}/tests/common/*.c) CSOURCES+=${GP_TESTLIB_SRCS}
# generated suite creation code diff --git a/libs/core/GP_TestingCore.c b/tests/common/GP_TestingCore.c similarity index 100% rename from libs/core/GP_TestingCore.c rename to tests/common/GP_TestingCore.c diff --git a/include/core/GP_TestingCore.h b/tests/common/GP_TestingCore.h similarity index 100% rename from include/core/GP_TestingCore.h rename to tests/common/GP_TestingCore.h diff --git a/libs/core/GP_TestingRandom.c b/tests/common/GP_TestingRandom.c similarity index 100% rename from libs/core/GP_TestingRandom.c rename to tests/common/GP_TestingRandom.c diff --git a/include/core/GP_TestingRandom.h b/tests/common/GP_TestingRandom.h similarity index 95% rename from include/core/GP_TestingRandom.h rename to tests/common/GP_TestingRandom.h index 9f897f8..9f267fb 100644 --- a/include/core/GP_TestingRandom.h +++ b/tests/common/GP_TestingRandom.h @@ -28,8 +28,10 @@ * on random() called in the tested routines or other tests. */
-#ifndef CORE_GP_TESTING_RANDOM_H -#define CORE_GP_TESTING_RANDOM_H +#ifndef GP_TESTING_RANDOM_H +#define GP_TESTING_RANDOM_H + +#include <stdint.h>
/* * Return next random value from the testing random generator @@ -44,4 +46,4 @@ long int GP_TestingRandom(void); */ void GP_InitTestingRandom(const char *text, uint64_t seed);
-#endif /* CORE_GP_TESTING_RANDOM_H */ +#endif /* GP_TESTING_RANDOM_H */ diff --git a/tests/common/GP_Tests.h b/tests/common/GP_Tests.h index d24b5f6..72c83bb 100644 --- a/tests/common/GP_Tests.h +++ b/tests/common/GP_Tests.h @@ -41,6 +41,7 @@ */
#include <check.h> +#include "GP_TestingRandom.h"
/* * Helper macro to allow auto-generation of test-cases and suites. @@ -62,9 +63,9 @@ * Parameters name, fname, line are used internally, do not use them */
-#define GP_TEST(name, ...) static void name(int);- void GP_TEST_##name(int i) {name(i);} - START_TEST(name) +#define GP_TEST(name, ...) static void name(int); void GP_TEST_##name(int i) {+ GP_InitTestingRandom( #name, i); name(i); } + START_TEST(name)
#define GP_ENDTEST END_TEST
http://repo.or.cz/w/gfxprim.git/commit/6d267ad031a775ffb3e7e73a5357a7600e7b9...
commit 6d267ad031a775ffb3e7e73a5357a7600e7b96f0 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 20:57:50 2011 +0200
Fixed "make clean" in tests/core
diff --git a/tests/core/Makefile b/tests/core/Makefile index 2d11c70..c03633a 100644 --- a/tests/core/Makefile +++ b/tests/core/Makefile @@ -5,7 +5,6 @@ TESTSUITE=core_suite LDLIBS+=-lGP -L$(TOPDIR)/build/ -lcheck GENSOURCES+=GP_Convert.test.gen.c
-include $(TOPDIR)/include.mk include $(TOPDIR)/tests.mk - +include $(TOPDIR)/include.mk
http://repo.or.cz/w/gfxprim.git/commit/50e68bdcafa2e379597a3c454343c4f3b2c7d...
commit 50e68bdcafa2e379597a3c454343c4f3b2c7db73 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 20:56:32 2011 +0200
Support for generating tests source files + demo
Added support to tests.mk and make_collected_tests.py Demo in make_GP_Convert.py
diff --git a/pylib/gfxprim/generators/core/make_GP_Convert.py b/pylib/gfxprim/generators/core/make_GP_Convert.py index 291b383..633f6cc 100644 --- a/pylib/gfxprim/generators/core/make_GP_Convert.py +++ b/pylib/gfxprim/generators/core/make_GP_Convert.py @@ -57,3 +57,12 @@ def core_GP_Convert_gen_h(h, c): gen_convert_to(pixeltypes['RGB565'], pixeltypes['RGBA8888'], h, c) gen_convert_to(pixeltypes['RGBA8888'], pixeltypes['V2'], h, c) gen_convert_to(pixeltypes['VA12'], pixeltypes['RGBA8888'], h, c) + +@generator(CSourceGenerator(name = 'GP_Convert.test.gen.c'), + descr = 'GP_Convert tests', + authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) +def core_GP_Convert_gen_h(c): + c.rhead('#include "GP_Tests.h"n') + c.rhead('#include "GP_Convert.h"nn') + c.rhead('GP_SUITE(GP_Convert)nn') + c.rbody('GP_TEST(triv)n{}nGP_ENDTESTn') diff --git a/pylib/gfxprim/generators/make_collected_tests.py b/pylib/gfxprim/generators/make_collected_tests.py index ca117ec..d690dac 100644 --- a/pylib/gfxprim/generators/make_collected_tests.py +++ b/pylib/gfxprim/generators/make_collected_tests.py @@ -27,7 +27,7 @@ def msg(prefix, msg_s, fname=None, line=None): s += '] ' sys.stderr.write(s + msg_s + 'n')
-testfile_pattern = '*.test.c' +testfile_patterns = ['*.test.c', '*.test.gen.c']
suites = {} # {"suitename":["testname":{test_parameters}]}
@@ -39,8 +39,9 @@ test_re = re.compile("A\s*GP_TEST((.*))\s*Z") 'from .test.c files', authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) def tests_collected_tests(c): - fnames = glob.fnmatch.filter(os.listdir(c.fdir or '.'), testfile_pattern) - print fnames + fnames = [] + for pat in testfile_patterns: + fnames += glob.fnmatch.filter(os.listdir(c.fdir or '.'), pat) for fn in fnames: dirfn = os.path.join(c.fdir, fn) with open(dirfn, 'rt') as f: diff --git a/tests.mk b/tests.mk index 5dbcc80..2dc8df3 100644 --- a/tests.mk +++ b/tests.mk @@ -21,7 +21,9 @@ CSOURCES+=${GP_TESTLIB_SRCS} TESTSUITE_GEN=collected_tests.gen.c # also fixed in the code generator GENSOURCES+=${TESTSUITE_GEN}
-TESTSUITE_SRCS=$(wildcard *.test.c) ${TESTSUITE_GEN} ${GP_TESTLIB_SRCS} +${TESTSUITE_GEN}: $(filter-out ${TESTSUITE_GEN},${GENSOURCES}) ${GENHEADERS} + +TESTSUITE_SRCS=$(wildcard *.test.c) ${GENSOURCES} ${GENHEADERS} ${GP_TESTLIB_SRCS} INCLUDE+=../tests/common TESTSUITE_OBJS=$(patsubst %.c,%.o,$(TESTSUITE_SRCS)) CLEAN+=${TESTSUITE} diff --git a/tests/core/Makefile b/tests/core/Makefile index 929a30c..2d11c70 100644 --- a/tests/core/Makefile +++ b/tests/core/Makefile @@ -1,8 +1,9 @@ TOPDIR=../..
LIBNAME=core -TESTSUITE=core +TESTSUITE=core_suite LDLIBS+=-lGP -L$(TOPDIR)/build/ -lcheck +GENSOURCES+=GP_Convert.test.gen.c
include $(TOPDIR)/include.mk include $(TOPDIR)/tests.mk
http://repo.or.cz/w/gfxprim.git/commit/e8872dfaab48d1f16b749fbd0ea698a6b7ce8...
commit e8872dfaab48d1f16b749fbd0ea698a6b7ce86ae Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 20:43:41 2011 +0200
Added helper routines for testing parts of core
* Color (pixel) randomization and comparation * Context randomization and comparation
diff --git a/include/core/GP_TestingCore.h b/include/core/GP_TestingCore.h new file mode 100644 index 0000000..23ea12a --- /dev/null +++ b/include/core/GP_TestingCore.h @@ -0,0 +1,55 @@ +/***************************************************************************** + * 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) 2011 Tomas Gavenciak gavento@ucw.cz * + * * + *****************************************************************************/ + +#ifndef CORE_GP_TESTINGCORE_H +#define CORE_GP_TESTINGCORE_H + +#include "GP_Context.h" +#include "GP_Pixel.h" + +/* + * Return pixel value of random color of given type. + * Uses GP_TestingRandom and is not really efficient. + */ +GP_Pixel GP_RandomColor(GP_PixelType type); + +/* + * Set color of pixels in given bitap rectangle to random values. + * Uses GP_TestingRandom and is not really efficient. + */ +void GP_RandomizeRect(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h); + +/* + * Return true if the two colors are equal after conversion to RGBA8888. + * Not very efficient. + */ +int GP_EqualColors(GP_Pixel p1, GP_PixelType t1, GP_Pixel p2, GP_PixelType t2); + +/* + * Compare two rectangles in two contexts. Return 1 on equal. + * The colors are cmpared by first converting them to RGBA8888. + * Somewhat inefficient. + */ +int GP_EqualRects(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_Size w, GP_Size h, + const GP_Context *c2, GP_Coord x2, GP_Coord y2); + +#endif /* CORE_GP_TESTINGCORE_H */ diff --git a/libs/core/GP_TestingCore.c b/libs/core/GP_TestingCore.c new file mode 100644 index 0000000..afa2754 --- /dev/null +++ b/libs/core/GP_TestingCore.c @@ -0,0 +1,65 @@ +/***************************************************************************** + * 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) 2011 Tomas Gavenciak gavento@ucw.cz * + * * + *****************************************************************************/ + +#include "GP_Common.h" +#include "GP_Convert.h" +#include "GP_GetPutPixel.h" +#include "GP_TestingCore.h" +#include "GP_TestingRandom.h" + +/* + * TODO: Use a different version for palette types. + */ +GP_Pixel GP_RandomColor(GP_PixelType type) +{ + return GP_RGBAToPixel(GP_TestingRandom() % 256, GP_TestingRandom() % 256, + GP_TestingRandom() % 256, GP_TestingRandom() % 256, type); +} + +void GP_RandomizeRect(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h) +{ + GP_CHECK(context); + for (GP_Size i = 0; i < w; i++) + for (GP_Size j = 0; j < h; j++) + GP_PutPixel(context, i + x, j + y, GP_RandomColor(context->pixel_type)); +} + +int GP_EqualColors(GP_Pixel p1, GP_PixelType t1, GP_Pixel p2, GP_PixelType t2) +{ + GP_Pixel col1 = GP_PixelToRGBA8888(p1, t1); + GP_Pixel col2 = GP_PixelToRGBA8888(p2, t2); + return (col1 & 0xffffffff) == (col2 & 0xffffffff); +} + +int GP_EqualRects(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_Size w, GP_Size h, + const GP_Context *c2, GP_Coord x2, GP_Coord y2) +{ + GP_CHECK(c1); + GP_CHECK(c2); + for (GP_Size i = 0; i < w; i++) + for (GP_Size j = 0; j < h; j++) { + if (!GP_EqualColors(GP_GetPixel(c1, x1 + i, y1 + j), c1->pixel_type, + GP_GetPixel(c2, x2 + i, y2 + j), c2->pixel_type)) + return 0; + } + return 1; +}
http://repo.or.cz/w/gfxprim.git/commit/d7551ce7958fc44a3a9e070258d3c8a45a23f...
commit d7551ce7958fc44a3a9e070258d3c8a45a23f755 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 20:42:53 2011 +0200
Add separate pseudorandom generator for testing inputs
diff --git a/include/core/GP_TestingRandom.h b/include/core/GP_TestingRandom.h new file mode 100644 index 0000000..9f897f8 --- /dev/null +++ b/include/core/GP_TestingRandom.h @@ -0,0 +1,47 @@ +/***************************************************************************** + * 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) 2011 Tomas Gavenciak gavento@ucw.cz * + * * + *****************************************************************************/ + +/* + * These routines use a pseudorandom generator with internal state. + * Use this only to provide tests with pseudo-random inputs. + * The seed is initialized with the test name, so the random numbers + * (and therefore inputs) are the same for a test, and do not depend + * on random() called in the tested routines or other tests. + */ + +#ifndef CORE_GP_TESTING_RANDOM_H +#define CORE_GP_TESTING_RANDOM_H + +/* + * Return next random value from the testing random generator + */ +long int GP_TestingRandom(void); + +/* + * Initialize the random generator to a seed computed from the given string + * and the given seed value. Needs to be called at least once. + * + * The string may be for example the name of the test, the seed the number of test iteration. + */ +void GP_InitTestingRandom(const char *text, uint64_t seed); + +#endif /* CORE_GP_TESTING_RANDOM_H */ diff --git a/libs/core/GP_TestingRandom.c b/libs/core/GP_TestingRandom.c new file mode 100644 index 0000000..17281a9 --- /dev/null +++ b/libs/core/GP_TestingRandom.c @@ -0,0 +1,58 @@ +/***************************************************************************** + * 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) 2011 Tomas Gavenciak gavento@ucw.cz * + * * + *****************************************************************************/ + +#include <stdlib.h> + +#include "GP_Common.h" +#include "GP_TestingRandom.h" + +/* + * State array for testing random generator + * + * The idea is to have a seperate random generator for generating + * random inputs for tests in case tested algorithms also use + * the random generator. Change in the tested algorithm must not + * change the input data generated for this or other part of the test. + * + * Take care when changing the values - unrelated test might start + * exhibiting a bug, some tests may rely on the exact result. + */ +#define GP_RandomStateSize 256 +static char GP_RandomTestingState[GP_RandomStateSize]; +static struct random_data GP_RandomTestingData; + +long int GP_TestingRandom(void) +{ + int32_t r; + GP_ASSERT(random_r(&GP_RandomTestingData, &r) == 0); + return r; +} + +void GP_InitTestingRandom(const char *text, uint64_t seed) +{ + const char *p = text; + for (; (p) && (*p); p++) + seed = ((seed * 327) + *p) % 0x7B391D50A10A3LL; // TODO replace with large primes + GP_ASSERT(initstate_r(seed, GP_RandomTestingState, GP_RandomStateSize, + &GP_RandomTestingData) == 0); +} +
http://repo.or.cz/w/gfxprim.git/commit/413daca73ab16f53c9fd81410c261bc7628d2...
commit 413daca73ab16f53c9fd81410c261bc7628d2e11 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Jun 12 20:40:02 2011 +0200
Make context arg of GetPixel const
diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h index 102bf9a..7151a36 100644 --- a/include/core/GP_GetPutPixel.h +++ b/include/core/GP_GetPutPixel.h @@ -36,7 +36,7 @@ * GetPixel with context transformations and clipping. * Returns 0 for clipped pixels or pixels outside bitmap. */ -GP_Pixel GP_GetPixel(GP_Context *context, int x, int y); +GP_Pixel GP_GetPixel(const GP_Context *context, int x, int y);
/* * Version of GetPixel without transformations nor border checking. diff --git a/libs/core/GP_GetPutPixel.c b/libs/core/GP_GetPutPixel.c index fe37216..9cac910 100644 --- a/libs/core/GP_GetPutPixel.c +++ b/libs/core/GP_GetPutPixel.c @@ -23,7 +23,7 @@ #include "GP_GetPutPixel.h" #include "GP_Transform.h"
-GP_Pixel GP_GetPixel(GP_Context *context, int x, int y) +GP_Pixel GP_GetPixel(const GP_Context *context, int x, int y) { GP_TRANSFORM_POINT(context, x, y); if (GP_PIXEL_IS_CLIPPED(context, x, y))
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Common.h | 14 +++ include/core/GP_Convert.h | 3 +- include/core/GP_FnPerBpp.h | 60 ++++++++++++-- include/core/GP_GetPutPixel.h | 2 +- include/core/GP_Pixel.h | 20 +++++ libs/core/GP_Blit.c | 3 +- libs/core/GP_GetPutPixel.c | 2 +- pylib/gfxprim/generators/core/gen_pixeltype.py | 12 ++-- pylib/gfxprim/generators/core/make_GP_Convert.py | 46 ++++++++++- pylib/gfxprim/generators/core/make_GP_Pixel.py | 13 +++ pylib/gfxprim/generators/make_collected_tests.py | 7 +- tests.mk | 8 +- .../GP_Blit.c => tests/common/GP_TestingCore.c | 86 +++++++++++--------- .../common/GP_TestingCore.h | 53 ++++++------ .../common/GP_TestingRandom.c | 57 ++++++------- .../GP_Blit.h => tests/common/GP_TestingRandom.h | 41 +++++----- tests/common/GP_Tests.h | 7 +- tests/core/GP_Convert.test.c | 27 ++++++ tests/core/Makefile | 6 +- 19 files changed, 316 insertions(+), 151 deletions(-) copy libs/core/GP_Blit.c => tests/common/GP_TestingCore.c (50%) copy include/core/GP_GetPutPixel.h => tests/common/GP_TestingCore.h (58%) copy include/core/GP_GetPutPixel.h => tests/common/GP_TestingRandom.c (60%) copy include/core/GP_Blit.h => tests/common/GP_TestingRandom.h (66%) create mode 100644 tests/core/GP_Convert.test.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.