[pypy-commit] lang-gameboy default: (jlincke, timfel) Add a test for blitting surface from pixelbuffer

timfel noreply at buildbot.pypy.org
Thu Mar 21 16:25:04 CET 2013


Author: Tim Felgentreff <timfelgentreff at gmail.com>
Branch: 
Changeset: r6:c419533d2000
Date: 2013-03-15 17:57 +0100
http://bitbucket.org/pypy/lang-gameboy/changeset/c419533d2000/

Log:	(jlincke, timfel) Add a test for blitting surface from pixelbuffer

diff --git a/rsdl/test/test_video.py b/rsdl/test/test_video.py
--- a/rsdl/test/test_video.py
+++ b/rsdl/test/test_video.py
@@ -236,6 +236,35 @@
         RSDL.FreeSurface(surface)
         self.check("Half Red/Orange rectangle(150px * 50px) at the top left, 10 pixels from the border")
 
+
+    def test_blit_pxrect(self):
+        max  = 150 * 50
+        surfacepx = lltype.malloc(rffi.VOIDP.TO, max * 4, flavor='raw')
+        pos = 0
+        for i in xrange(max):
+            surfacepx[pos]     = chr(int(float(i) / max * 255))
+            surfacepx[pos + 1] = chr(int(float(i) / max * 255))
+            surfacepx[pos + 2] = chr(int(float(i) / max * 255))
+            surfacepx[pos + 3] = chr(255)
+            pos += 4
+
+        pitch = 4 * 150 # 4 byte per line * width
+        surface = RSDL.CreateRGBSurfaceFrom(surfacepx, 150, 50, 32, pitch,
+                                            r_uint(0x000000FF),
+                                            r_uint(0x0000FF00),
+                                            r_uint(0x00FF0000),
+                                            r_uint(0xFF000000))
+
+        dstrect = RSDL_helper.mallocrect(0, 0, 150, 50)
+        try:
+            RSDL.BlitSurface(surface, lltype.nullptr(RSDL.Rect), self.screen, dstrect)
+            RSDL.Flip(self.screen)
+        finally:
+            lltype.free(dstrect, flavor='raw')
+        RSDL.FreeSurface(surface)
+        lltype.free(surfacepx, flavor='raw')
+        self.check("Gradient from black to white rectangle(150px * 50px) at the top left")
+
     def teardown_method(self, meth):
         RSDL.Quit()
 


More information about the pypy-commit mailing list