Esempio n. 1
0
File: gl.py Progetto: lxnt/fgtestbed
 def hflip(self):
     pitch = self._surf._pitch
     pixels = ctypes.cast(self._surf._pixels, ctypes.c_void_p).value
     h = self._surf._h
     tmp_ba = bytearray(pitch*h)
     tmp = bar2voidp(tmp_ba).value
     sdlsurface.lock_surface(self._surf)
     ctypes.memmove(tmp, pixels, pitch*h)
     for y in range(self._surf._h):
         src = tmp + pitch * ( h - y - 1)
         dst = pixels + pitch * y
         ctypes.memmove(dst, src, pitch)
     sdlsurface.unlock_surface(self._surf)
Esempio n. 2
0
 def test_lock_unlock_MUSTLOCK_surface(self):
     colormods = ((0, 0, 0),
                  (32, 64, 128),
                  (10, 20, 30),
                  (1, 2, 4),
                  (255, 255, 255),
                  (128, 128, 128),
                  (127, 127, 127),
                  )
     for fmt in pixels.ALL_PIXELFORMATS:
         if pixels.SDL_ISPIXELFORMAT_FOURCC(fmt):
             continue
         bpp, rmask, gmask, bmask, amask = \
             pixels.pixelformat_enum_to_masks(fmt)
         sf = surface.create_rgb_surface(10, 10, bpp, rmask, gmask, bmask,
                                         amask)
         # TODO: locking seems to be only necessary for RLE surfaces...
         if surface.SDL_MUSTLOCK(sf):
             self.assertFalse(sf.locked)
             surface.lock_surface(sf)
             self.assertTrue(sf.locked)
             surface.lock_surface(sf)
             self.assertTrue(sf.locked)
             surface.lock_surface(sf)
             self.assertTrue(sf.locked)
             surface.unlock_surface(sf)
             self.assertTrue(sf.locked)
             surface.unlock_surface(sf)
             self.assertTrue(sf.locked)
             surface.unlock_surface(sf)
             self.assertFalse(sf.locked)
         surface.free_surface(sf)
Esempio n. 3
0
 def __del__(self):
     if self._surface is not None:
         if sdlsurface.SDL_MUSTLOCK(self._surface):
             sdlsurface.unlock_surface(self._surface)