pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
849 stars 140 forks source link

Always call HasColorKey before GetColorKey #2844

Closed Starbuck5 closed 4 months ago

Starbuck5 commented 4 months ago

SDL sets an error if GetColorKey is called on a surface that doesn't have colorkey, which is much more expensive performance-wise in the newest SDL versions. Therefore, let's call SDL_HasColorKey first to avoid the error setting cost.

Successor to #2835 Closes #2821

itzpr3d4t0r commented 4 months ago

I suppose this closes #2516 as well since the performance gain over 2.4.1 matches what I observed there. Apparently this regression allowed us to find a long-standing performance gap.

oddbookworm commented 4 months ago

I suppose this closes #2516 as well since the performance gain over 2.4.1 matches what I observed there. Apparently this regression allowed us to find a long-standing performance gap.

I would like to keep that issue open until we have a prerelease that has had time to be tested on actual projects But, I won't really fight closing it

oddbookworm commented 4 months ago

Gonna see if @bigwhoopgames can test a dev wheel from this pull and make sure that the performance regression is gone

itzpr3d4t0r commented 4 months ago

I made one here: https://discord.com/channels/772505616680878080/772505616680878083/1237761275795345552