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 3934f00a09db3fc608a39c15889d0788565b7e36 (commit) via 2a92e4b5c47d96fca358453efcaddb66a4b4007c (commit) via fcd6ceb84774d065882cfe87b2e64e179ff0e53d (commit) via c4649a19ae46dff6f9e1fbdd002b6c23d95f25e0 (commit) via da9b47d3f6e7b68b41aebfebe7627db7ddc75595 (commit) from f8e9982dea3d60b4db125a4b6aeb56b661f9fe43 (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/3934f00a09db3fc608a39c15889d0788565b7...
commit 3934f00a09db3fc608a39c15889d0788565b7e36 Merge: 2a92e4b f8e9982 Author: Tomas Gavenciak gavento@ucw.cz Date: Wed Jan 2 00:55:43 2013 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/2a92e4b5c47d96fca358453efcaddb66a4b40...
commit 2a92e4b5c47d96fca358453efcaddb66a4b4007c Author: Tomas Gavenciak gavento@ucw.cz Date: Wed Jan 2 00:54:57 2013 +0100
core: pylib: Minor test improvements
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index 58f3bba..aad219e 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -1,3 +1,5 @@ +"core.Context tests" + from unittest import SkipTest from testutils import *
@@ -5,6 +7,7 @@ from gfxprim import core from gfxprim.core import Context
def test_basic_types_exist(): + "There are the basic pixel types" assert core.C.PIXEL_RGB888 > 0 assert core.C.PIXEL_RGBA8888 > 0 assert core.C.PIXEL_G8 > 0 @@ -77,6 +80,7 @@ def test_get_put_pixel(t):
@alltypes() def test_str_repr(t): + "Context __str__ and __repr__ work" c = Context(42, 43, t) assert "42x43" in str(c) assert "42x43" in repr(c) @@ -95,22 +99,25 @@ def test_blit_with_offset_and_rotation(t):
@alltypes() def test_blit_vs_convert_to_RGB888(t): + "Compare Blit vs Convert" if 'P' in t.name: raise SkipTest("Palette conversions are TODO") - c = ContextRand(42, 43, t) - c2a = Context(c.w, c.h, core.C.PIXEL_RGB888) + c = ContextRand(42, 43, t, seed=0) + c2a = ContextRand(c.w, c.h, core.C.PIXEL_RGB888, seed=42) c2b = c.Convert(core.C.PIXEL_RGB888) c.Blit(0, 0, c2a, 0, 0, w=c.w, h=c.h) assert c2a == c2b
@alltypes() def test_copy(t): + "Copying works" c = ContextRand(19, 43, t) c2 = c.Copy(True) assert c == c2
@alltypes() def test_rotate(t): + "Rotations work (and LLL=R)" c = ContextRand(42, 47, t) c2 = c.Copy(True) assert c == c2 @@ -129,13 +136,17 @@ def test_rotate(t):
@alltypes() def test_subcontext(t): - c = ContextRand(43, 51, t) - c2a = c.SubContext(5, 7, 10, 9) - c2b = c.SubContext(5, 7, 10, 9) + "Subcontext is sensible" + c1a = ContextRand(43, 51, t) + c1b = ContextRand(43, 51, t) + assert c1a == c1b + c2a = c1a.SubContext(5, 7, 10, 9) + c2b = c1b.SubContext(5, 7, 10, 9) assert c2a == c2b
@alltypes() def test_subcontext_vs_blit(t): + "Compare Subcontext and Blit of a rectangle" c = ContextRand(31, 21, t) c2a = c.SubContext(5, 7, 15, 9) c2b = Context(15, 9, t) @@ -144,6 +155,7 @@ def test_subcontext_vs_blit(t):
@alltypes() def test_blits_by_rect(t): + "Blit defined by XYXY, XYX2Y2 and XYWH" c = ContextRand(17, 13, t, seed=765) c2a = ContextRand(16, 15, t) c2b = ContextRand(16, 15, t)
http://repo.or.cz/w/gfxprim.git/commit/fcd6ceb84774d065882cfe87b2e64e179ff0e...
commit fcd6ceb84774d065882cfe87b2e64e179ff0e53d Author: Tomas Gavenciak gavento@ucw.cz Date: Wed Jan 2 00:45:12 2013 +0100
test: pylib: Split off test utils, improve @alltypes
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index fb58340..58f3bba 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -1,39 +1,8 @@ -### Helper imports and decorators -# TODO: separate (nose plugin?) - from unittest import SkipTest +from testutils import * + from gfxprim import core from gfxprim.core import Context -from random import Random - - -def alltypes(_filter=None): - def decorate(f): - def gen(): - for t in core.PixelTypes[1:]: - if (_filter is None) or _filter(t): - yield f, t - gen.__name__ = f.__name__ - return gen - return decorate - -def ContextRand(w, h, t, seed=None): - "Return new Context(w, h, t) filled with RandomizeContext(c, seed)" - c = Context(w, h, t) - RandomizeContext(c, seed) - return c - -def RandomizeContext(c, seed=None): - if seed is None: - seed = c.w + (2 ** c.h) * c.pixel_type - r = Random(seed) - for x in range(c.w): - for y in range(c.h): - p = r.randint(0, (1 << c.bpp) - 1) - c.PutPixel(x, y, p) - assert c.GetPixel(x, y) == p - -### The actual tests
def test_basic_types_exist(): assert core.C.PIXEL_RGB888 > 0 diff --git a/tests/pylib/testutils.py b/tests/pylib/testutils.py new file mode 100644 index 0000000..4edb403 --- /dev/null +++ b/tests/pylib/testutils.py @@ -0,0 +1,60 @@ +### Helper imports and decorators + +from random import Random + +from gfxprim import core + +__all__ = ["alltypes", "RandomizeContext", "ContextRand"] + + +def alltypes_generator(_filter=None): + def decorate(f): + def gen(): + for t in core.PixelTypes[1:]: + if (_filter is None) or _filter(t): + yield f, t + gen.__name__ = f.__name__ + return gen + return decorate + + +def alltypes_new_functions(_filter=None): + def decorate(f): + for t in core.PixelTypes[1:]: + if (_filter is None) or _filter(t): + nf = lambda: f(t) + nf.__name__ = f.__name__ + "_" + t.name + nf.__doc__ = "%s<%s:%s>"% ( + f.__doc__ + " " if f.__doc__ else "", + __name__, nf.__name__) + globals()[nf.__name__] = nf + return None + return decorate + + +# Switch to alltypes_new_functions by default +alltypes = alltypes_new_functions + +### core.Context helpers + +def ContextRand(w, h, t, seed=None): + "Return new Context(w, h, t) filled with RandomizeContext(c, seed)" + c = core.Context(w, h, t) + RandomizeContext(c, seed) + return c + +def RandomizeContext(c, seed=None): + """Fill Context with pseudorandom data. + + The default seed is computed from size and type number. + """ + + if seed is None: + seed = c.w + (1 << c.h) * c.pixel_type + r = Random(seed) + for x in range(c.w): + for y in range(c.h): + p = r.randint(0, (1 << c.bpp) - 1) + c.PutPixel(x, y, p) + assert c.GetPixel(x, y) == p +
http://repo.or.cz/w/gfxprim.git/commit/c4649a19ae46dff6f9e1fbdd002b6c23d95f2...
commit c4649a19ae46dff6f9e1fbdd002b6c23d95f25e0 Author: Tomas Gavenciak gavento@ucw.cz Date: Wed Jan 2 00:31:14 2013 +0100
core: pylib: Minor modifications to blit tests
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index 3889c87..fb58340 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -29,7 +29,9 @@ def RandomizeContext(c, seed=None): r = Random(seed) for x in range(c.w): for y in range(c.h): - c.PutPixel(x, y, r.randint(0, (1 << c.bpp) - 1)) + p = r.randint(0, (1 << c.bpp) - 1) + c.PutPixel(x, y, p) + assert c.GetPixel(x, y) == p
### The actual tests
@@ -59,7 +61,7 @@ def test_check_attributes(t): assert c._free_pixels
@alltypes() -def test_context_convert_from_RGB888(t): +def test_convert_from_RGB888(t): "Conversion from RGB888" if 'P' in t.name: raise SkipTest("Palette conversion are TODO") @@ -128,8 +130,8 @@ def test_blit_vs_convert_to_RGB888(t): raise SkipTest("Palette conversions are TODO") c = ContextRand(42, 43, t) c2a = Context(c.w, c.h, core.C.PIXEL_RGB888) - c.Blit(0, 0, c2a, 0, 0, w=c.w, h=c.h) c2b = c.Convert(core.C.PIXEL_RGB888) + c.Blit(0, 0, c2a, 0, 0, w=c.w, h=c.h) assert c2a == c2b
@alltypes()
http://repo.or.cz/w/gfxprim.git/commit/da9b47d3f6e7b68b41aebfebe7627db7ddc75...
commit da9b47d3f6e7b68b41aebfebe7627db7ddc75595 Author: Tomas Gavenciak gavento@ucw.cz Date: Wed Jan 2 00:24:02 2013 +0100
core: Remove a buggy special case in blitXYXY_Raw_xBPP
diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t index 0c482af..ccb924a 100644 --- a/libs/core/GP_Blit.gen.c.t +++ b/libs/core/GP_Blit.gen.c.t @@ -27,9 +27,9 @@ static void blitXYXY_Naive_Raw(const GP_Context *src, for (x = x0; x <= x1; x++) { GP_Pixel p = GP_GetPixel_Raw(src, x, y);
- if (src->pixel_type != dst->pixel_type) + if (src->pixel_type != dst->pixel_type) p = GP_ConvertContextPixel(p, src, dst); - + GP_PutPixel_Raw(dst, x2 + (x - x0), y2 + (y - y0), p); }
@@ -44,19 +44,8 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Context *dst, GP_Coord x2, GP_Coord y2) { - /* Special case - copy whole line-block with one memcpy() */ - if ((x0 == 0) && (x2 == 0) && (x1 == (GP_Coord)src->w - 1) && - (src->w == dst->w) && - (src->bytes_per_row == dst->bytes_per_row)) { - - memcpy(dst->pixels + dst->bytes_per_row * y2, - src->pixels + src->bytes_per_row * y0, - src->bytes_per_row * y1); - return; - } - %% if not ps.needs_bit_endian() - /* General case - memcpy() each horizontal line */ + /* memcpy() each horizontal line */ GP_Coord y;
for (y = 0; y <= (y1 - y0); y++) @@ -81,7 +70,7 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src, uint8_t *p2 = (uint8_t *) GP_PIXEL_ADDR_{{ ps.suffix }}(dst, x2, y2); uint8_t *end_p1 = (uint8_t *) GP_PIXEL_ADDR_{{ ps.suffix }}(src, x1, y0); uint8_t *end_p2 = (uint8_t *) GP_PIXEL_ADDR_{{ ps.suffix }}(dst, x2, y2); - + GP_Coord i;
for (i = 0; i < (y1 - y0 + 1); i++) {
-----------------------------------------------------------------------
Summary of changes: libs/core/GP_Blit.gen.c.t | 19 +++----------- tests/pylib/test_core.py | 57 +++++++++++++++--------------------------- tests/pylib/testutils.py | 60 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 52 deletions(-) create mode 100644 tests/pylib/testutils.py
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.