[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Faster blitting



Going through the pygame source, I've noticed that the surface blit method does a considerable amount of checking to make sure surfaces share pixel format, clipping, etc, and will even convert surfaces before blitting. Its really useful because it hides complexity and generally works as expected, but seems to incur overhead. I'm wondering if there could be another blit method, one that is "unsafe"....call it "fast_blit".

The fast_blit method would with the barest minimum of checking before calling the sdl blitting functions. This would obviously cause graphical errors if the pixel formats differ, clipping bounds not honored, etc, BUT this would improve speed significantly and would be free of side-effects for seasoned programmers. As long as it is documented that this can cause glitches if you don't use it properly, then I don't see a problem with implementing it.

This would be extremely useful for slow targets, such as the raspberry pi. The programmer could enforce pixel formats and clipping bounds for a group of surfaces, rather than individual. This would remove lots of overhead as each surface is checked when blitting.

I would tackle this and submit a PR, but I am not a C programmer. I hope somebody could step up and implement this.