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 0841a375e21de5071687413607915ed4d5b191bf (commit) via 33cdab55c6d7fb13d5845b5fdf7174f493e74160 (commit) via 84dbd5eb640c75933117e24785a84ddd40bc299d (commit) via db0a648c957c21c98c32dd06bce2dafd47f4a784 (commit) via 4c6265fad1a9d6d32947d34af9e258a3fec7a539 (commit) via 63aa717a239d4a15d17754d101beefe051862d23 (commit) from 631cb441b16c00328d2659334528d341d582fad6 (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/0841a375e21de5071687413607915ed4d5b19...
commit 0841a375e21de5071687413607915ed4d5b191bf Merge: 33cdab5 631cb44 Author: Tomas Gavenciak gavento@ucw.cz Date: Tue Jan 1 14:54:51 2013 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/33cdab55c6d7fb13d5845b5fdf7174f493e74...
commit 33cdab55c6d7fb13d5845b5fdf7174f493e74160 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Dec 31 19:15:11 2012 +0100
core: pylib: Added more tests, discovered bugs in core
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index 9417990..3889c87 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -113,6 +113,16 @@ def test_str_repr(t): assert t.name in repr(c)
@alltypes() +def test_blit_with_offset_and_rotation(t): + "Blit with various shifts and rotation" + c1 = ContextRand(19, 17, t) + for r in range(4): + for i in [0,1,2]: + c2 = Context(51-i, 25+i, t) + c1.Blit(2+i, 3+i, c2, 1+i, 4-i, w=2+3*i, h=13-i) + c1.RotateCW() + +@alltypes() def test_blit_vs_convert_to_RGB888(t): if 'P' in t.name: raise SkipTest("Palette conversions are TODO") @@ -122,10 +132,66 @@ def test_blit_vs_convert_to_RGB888(t): c2b = c.Convert(core.C.PIXEL_RGB888) assert c2a == c2b
-#'Blit', -# 'Copy', +@alltypes() +def test_copy(t): + c = ContextRand(19, 43, t) + c2 = c.Copy(True) + assert c == c2 + +@alltypes() +def test_rotate(t): + c = ContextRand(42, 47, t) + c2 = c.Copy(True) + assert c == c2 + c2.RotateCCW() + assert c != c2 + c.RotateCCW() + assert c == c2 + c2.RotateCCW() + assert c != c2 + c2.RotateCCW() + assert c != c2 + c2.RotateCCW() + assert c != c2 + c.RotateCW() + assert c == c2 + +@alltypes() +def test_subcontext(t): + c = ContextRand(43, 51, t) + c2a = c.SubContext(5, 7, 10, 9) + c2b = c.SubContext(5, 7, 10, 9) + assert c2a == c2b + +@alltypes() +def test_subcontext_vs_blit(t): + c = ContextRand(31, 21, t) + c2a = c.SubContext(5, 7, 15, 9) + c2b = Context(15, 9, t) + c.Blit(5, 7, c2b, 0, 0, w=15, h=9) + assert c2a == c2b + +@alltypes() +def test_blits_by_rect(t): + c = ContextRand(17, 13, t, seed=765) + c2a = ContextRand(16, 15, t) + c2b = ContextRand(16, 15, t) + c2c = ContextRand(16, 15, t) + assert c2a == c2b + assert c2a == c2c + assert c != c2a + + c.Blit(3, 4, c2a, 5, 2, w=4, h=5) + assert c2a != c2c + c.Blit(3, 4, c2b, 5, 2, w=4, h=5) + assert c2b != c2c + c.Blit(3, 4, c2c, 5, 2, w=4, h=5) + + assert c2a == c2b + assert c2a == c2c + + # 'RGBAToPixel', # 'RGBToPixel', # 'Resize', -# 'SubContext',
http://repo.or.cz/w/gfxprim.git/commit/84dbd5eb640c75933117e24785a84ddd40bc2...
commit 84dbd5eb640c75933117e24785a84ddd40bc299d Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Dec 31 18:36:53 2012 +0100
core: pylib: (pseudo)randomize contexts in tests
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index 09cbf03..9417990 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -2,6 +2,10 @@ # TODO: separate (nose plugin?)
from unittest import SkipTest +from gfxprim import core +from gfxprim.core import Context +from random import Random +
def alltypes(_filter=None): def decorate(f): @@ -13,11 +17,21 @@ def alltypes(_filter=None): 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
-### The actual tests +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): + c.PutPixel(x, y, r.randint(0, (1 << c.bpp) - 1))
-from gfxprim import core -from gfxprim.core import Context +### The actual tests
def test_basic_types_exist(): assert core.C.PIXEL_RGB888 > 0 @@ -49,7 +63,7 @@ def test_context_convert_from_RGB888(t): "Conversion from RGB888" if 'P' in t.name: raise SkipTest("Palette conversion are TODO") - c = Context(17, 19, core.C.PIXEL_RGB888) + c = ContextRand(17, 19, core.C.PIXEL_RGB888) # both by number and the pixeltype c2 = c.Convert(t) assert c2.pixel_type == t.type @@ -61,26 +75,28 @@ def test_convert_to_RGB888(t): "Conversion to RGB888" if 'P' in t.name: raise SkipTest("Palette conversion are TODO") - c = Context(1, 1, t) + c = ContextRand(11, 12, t) c2 = c.Convert(core.C.PIXEL_RGB888) assert c2.pixel_type == core.C.PIXEL_RGB888
@alltypes() -def test_equality_same_type(t): - "Basics of equality" - c1 = Context(2, 1, t) - assert c1 == c1 - c2 = Context(1, 2, t) +def test_equality(t): + "Equality" + c1a = ContextRand(2, 11, t, seed=123) + c1b = ContextRand(2, 11, t, seed=123) + assert c1a == c1a + assert c1a == c1b + c2 = ContextRand(2, 11, t, seed=456) assert c2 == c2 - assert c1 != c2 - assert c2 != c1 + assert c1a != c2 + assert c2 != c1a
@alltypes() def test_get_put_pixel(t): "Get/Put pixel consistent" def f(x,y): return (x + 3 ** y) % (1 << t.size) - c = Context(45, 37, t) + c = ContextRand(45, 37, t) for x in range(c.w): for y in range(c.h): c.PutPixel(x, y, f(x, y)) @@ -89,17 +105,6 @@ def test_get_put_pixel(t): assert c.GetPixel(x, y) == f(x, y)
@alltypes() -def test_equality_data(t): - "Equality of data" - c1 = Context(1, 1, t) - c1.PutPixel(0, 0, 1) - c2 = Context(1, 1, t) - c2.PutPixel(0, 0, 1) - assert c1 == c2 - c2.PutPixel(0, 0, 0) - assert c1 != c2 - -@alltypes() def test_str_repr(t): c = Context(42, 43, t) assert "42x43" in str(c) @@ -111,7 +116,7 @@ def test_str_repr(t): def test_blit_vs_convert_to_RGB888(t): if 'P' in t.name: raise SkipTest("Palette conversions are TODO") - c = Context(42, 43, t) + 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) @@ -122,7 +127,5 @@ def test_blit_vs_convert_to_RGB888(t): # 'RGBAToPixel', # 'RGBToPixel', # 'Resize', -# 'RotateCCW', -# 'RotateCW', # 'SubContext',
http://repo.or.cz/w/gfxprim.git/commit/db0a648c957c21c98c32dd06bce2dafd47f4a...
commit db0a648c957c21c98c32dd06bce2dafd47f4a784 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Dec 31 18:01:58 2012 +0100
core: pylib: Convert, Blit fix and tests
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index ddfaaa2..fdf3017 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -134,7 +134,7 @@ def _init(module): h = max(0, sy2 - sy) if ty2 is not None: h = max(0, ty2 - ty) - return c_core.GP_BlitXYWH_Clipped(self, sx, sy, target, tx, ty, w, h) + return c_core.GP_BlitXYWH_Clipped(self, sx, sy, w, h, target, tx, ty)
# Color conversions
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index 5c9ba2e..09cbf03 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -48,7 +48,7 @@ def test_check_attributes(t): def test_context_convert_from_RGB888(t): "Conversion from RGB888" if 'P' in t.name: - raise SkipTest("Palette conversion os TODO") + raise SkipTest("Palette conversion are TODO") c = Context(17, 19, core.C.PIXEL_RGB888) # both by number and the pixeltype c2 = c.Convert(t) @@ -60,7 +60,7 @@ def test_context_convert_from_RGB888(t): def test_convert_to_RGB888(t): "Conversion to RGB888" if 'P' in t.name: - raise SkipTest("Palette conversion os TODO") + raise SkipTest("Palette conversion are TODO") c = Context(1, 1, t) c2 = c.Convert(core.C.PIXEL_RGB888) assert c2.pixel_type == core.C.PIXEL_RGB888 @@ -76,6 +76,19 @@ def test_equality_same_type(t): assert c2 != c1
@alltypes() +def test_get_put_pixel(t): + "Get/Put pixel consistent" + def f(x,y): + return (x + 3 ** y) % (1 << t.size) + c = Context(45, 37, t) + for x in range(c.w): + for y in range(c.h): + c.PutPixel(x, y, f(x, y)) + for x in range(c.w): + for y in range(c.h): + assert c.GetPixel(x, y) == f(x, y) + +@alltypes() def test_equality_data(t): "Equality of data" c1 = Context(1, 1, t) @@ -93,3 +106,23 @@ def test_str_repr(t): assert "42x43" in repr(c) assert t.name in str(c) assert t.name in repr(c) + +@alltypes() +def test_blit_vs_convert_to_RGB888(t): + if 'P' in t.name: + raise SkipTest("Palette conversions are TODO") + c = Context(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) + assert c2a == c2b + +#'Blit', +# 'Copy', +# 'RGBAToPixel', +# 'RGBToPixel', +# 'Resize', +# 'RotateCCW', +# 'RotateCW', +# 'SubContext', +
http://repo.or.cz/w/gfxprim.git/commit/4c6265fad1a9d6d32947d34af9e258a3fec7a...
commit 4c6265fad1a9d6d32947d34af9e258a3fec7a539 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon Dec 31 17:42:32 2012 +0100
core: pylib: Improve str and repr (and tests)
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index 8f24919..ddfaaa2 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -45,8 +45,8 @@ def _init(module): @extend(_context, name='__str__') @extend(_context, name='__repr__') def context_str(self): - return "<Context %dx%d, %dbpp, GP_Context %sowned, %s parent>" % ( - self.w, self.h, self.bpp, + return "<Context %dx%d %s (%dbpp), GP_Context %sowned, %s parent>" % ( + self.w, self.h, module['PixelTypes'][self.pixel_type].name, self.bpp, "" if self.thisown else "not ", "with" if self.parent else "no")
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index d718390..5c9ba2e 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -1,5 +1,3 @@ -"core.Context" - ### Helper imports and decorators # TODO: separate (nose plugin?)
@@ -88,5 +86,10 @@ def test_equality_data(t): c2.PutPixel(0, 0, 0) assert c1 != c2
-#@alltypes() -#def test_equality_data(t): +@alltypes() +def test_str_repr(t): + c = Context(42, 43, t) + assert "42x43" in str(c) + assert "42x43" in repr(c) + assert t.name in str(c) + assert t.name in repr(c)
http://repo.or.cz/w/gfxprim.git/commit/63aa717a239d4a15d17754d101beefe051862...
commit 63aa717a239d4a15d17754d101beefe051862d23 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Dec 30 22:28:18 2012 +0100
core: pylib: Create Contex.__init__ (remove Context.Create)
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index 1b082f5..8f24919 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -59,7 +59,7 @@ def _init(module): raise TypeError("Can only compare two Contexts.") return bool(c_core.GP_ContextEqual(self, other))
- # Creation + # Constructor
def pixeltype_no(pixeltype): "Return pixel type number from the number or a PixelType instance" @@ -69,14 +69,16 @@ def _init(module): return pixeltype.type raise TypeError("Not a PixelType instance or number: %r", pixeltype)
- @extend(_context, name='Create') - @staticmethod - def Create(w, h, pixeltype): + extend(_context, name='__swig_init__')(_context.__init__) + + @extend(_context, name='__init__') + def ContextCreate(self, w, h, pixeltype): "Allocate a new w*h bitmap of given type." # Add "parent" attribute, pointing to a wrapper of the actual parent or None - c = c_core.GP_ContextAlloc(w, h, pixeltype_no(pixeltype)) - c.parent = None - return c + _context.__swig_init__(self, w, h, pixeltype_no(pixeltype)) + self.parent = None + + # New instance methods
@extend(_context) def SubContext(self, x, y, w, h): @@ -98,6 +100,7 @@ def _init(module): return c_core.GP_ContextConvertAlloc(self, pixeltype_no(target_type))
# Manipulation + extend_direct(_context, "PutPixel", c_core.GP_PutPixel, "Set a pixel value encoded according to context PixelType. Clipped.")
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i index 89c0301..b7725eb 100644 --- a/pylib/gfxprim/core/core.i +++ b/pylib/gfxprim/core/core.i @@ -85,14 +85,12 @@ and self.thisown.") GP_Context; $self->w, $self->h, $self->bpp, $self->free_pixels); GP_ContextFree($self); } - /* - PyObject *_hacky_hacky_pixels_buffer() { - GP_DEBUG(0, "Evil and dangerous _hacky_hacky_pixels_buffer() used!"); - return PyBuffer_FromMemory($self->pixels, $self->bytes_per_row * $self->h); + GP_Context(GP_Coord w, GP_Coord h, GP_PixelType typeno) { + return GP_ContextAlloc(w, h, typeno); } - */ };
+ /* Error handling */ ERROR_ON_NONZERO(GP_ContextResize); ERROR_ON_NULL(GP_ContextAlloc); diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index f1703a5..d718390 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -29,17 +29,17 @@ def test_basic_types_exist(): @alltypes() def test_create_by_pixeltype(t): "Allocate Context by pixeltype" - c = Context.Create(13, 15, t.type) + c = Context(13, 15, t.type)
@alltypes() def test_create_by_number(t): "Allocation by pixeltype number" - c = Context.Create(3, 5, t) + c = Context(3, 5, t)
@alltypes() def test_check_attributes(t): "Context attributes" - c = Context.Create(13, 15, t.type) + c = Context(13, 15, t.type) assert c.w == 13 assert c.h == 15 assert c._bit_endian == t.bit_endian @@ -51,7 +51,7 @@ def test_context_convert_from_RGB888(t): "Conversion from RGB888" if 'P' in t.name: raise SkipTest("Palette conversion os TODO") - c = Context.Create(17, 19, core.C.PIXEL_RGB888) + c = Context(17, 19, core.C.PIXEL_RGB888) # both by number and the pixeltype c2 = c.Convert(t) assert c2.pixel_type == t.type @@ -63,16 +63,16 @@ def test_convert_to_RGB888(t): "Conversion to RGB888" if 'P' in t.name: raise SkipTest("Palette conversion os TODO") - c = Context.Create(1, 1, t) + c = Context(1, 1, t) c2 = c.Convert(core.C.PIXEL_RGB888) assert c2.pixel_type == core.C.PIXEL_RGB888
@alltypes() def test_equality_same_type(t): "Basics of equality" - c1 = Context.Create(2, 1, t) + c1 = Context(2, 1, t) assert c1 == c1 - c2 = Context.Create(1, 2, t) + c2 = Context(1, 2, t) assert c2 == c2 assert c1 != c2 assert c2 != c1 @@ -80,11 +80,13 @@ def test_equality_same_type(t): @alltypes() def test_equality_data(t): "Equality of data" - c1 = Context.Create(1, 1, t) + c1 = Context(1, 1, t) c1.PutPixel(0, 0, 1) - c2 = Context.Create(1, 1, t) + c2 = Context(1, 1, t) c2.PutPixel(0, 0, 1) assert c1 == c2 c2.PutPixel(0, 0, 0) assert c1 != c2
+#@alltypes() +#def test_equality_data(t):
-----------------------------------------------------------------------
Summary of changes: pylib/gfxprim/core/__init__.py | 23 +++--- pylib/gfxprim/core/core.i | 8 +- tests/pylib/test_core.py | 163 +++++++++++++++++++++++++++++++++------- 3 files changed, 151 insertions(+), 43 deletions(-)
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.