[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Re: Fullscreen Performance
Pete Shinners wrote:
> second, your platforms are currently all drawn with "tiled"
> images. every time the platform is drawn, it does a lot of
> fancy wok in tiled_blit(). at minimum, compute this data
> once per platform (the offset and boundary used for each
> blit in the tile).
> better, but more memory intensive would
> be to render the platform out in its entirety to an
> offscreen Surface.
Actually, I am already doing this. I didn't tell this immediatly
because I forgot it (I've had a 3-months-pause in Brian development).
The code to do so is in usersprites.SimpleWall.setimage():
http://cvs.sourceforge.net/viewcvs.py/pybrian/brian/usersprites.py?annotate=1.29#71
74 def setimage(self):
75 image = pygame.Surface(self.outersize)
76 image.set_colorkey((1,1,1))
77 image.fill((1,1,1))
78 ## pygame.draw.rect(image, (255, 0, 0), image.get_rect(), 25)
79 ## pygame.draw.rect(image, (100, 0, 0), image.get_rect(), 5)
80 util.multiblit(image, DataServer.image.wall)
81 self._image = image
The difference between tiled_blit and multiblit: tiled_blit blits one Surface
repeatedly to a destination surface, multiblit blits an instance of
DataServer.ImageServer to a surface: the corners have different images than
the centre, so it is not simply tiled, it is more complex.
There may be another optimization in tiled_blit, because tiling can be
done faster than blitting one image a hundred times: first doubling it
in a temporary new surface than can be blitted 50 times is faster, or
2 times doubles blitting 25 times, etc. This is also an optimizationproblem.
I now have a half-solution of this, where I double it a few times, but
in the wrong place of my code...
The other optimization hints are very useful, however.
Gerrit.
--
161. If a man bring chattels into his father-in-law's house and pay the
"purchase price," if then his friend slander him, and his father-in-law
say to the young husband: "You shall not marry my daughter," the he shall
give back to him undiminished all that he had brought with him; but his
wife shall not be married to the friend.
-- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Kom in verzet tegen dit kabinet:
http://www.sp.nl/