Skip to content

Always call HasColorKey before GetColorKey #2844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2024

Conversation

Starbuck5
Copy link
Member

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

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.
@Starbuck5 Starbuck5 added this to the 2.5.0 milestone May 8, 2024
@Starbuck5 Starbuck5 requested a review from a team as a code owner May 8, 2024 06:43
@Starbuck5 Starbuck5 added the Performance Related to the speed or resource usage of the project label May 8, 2024
Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR 😎

Copy link
Member

@itzpr3d4t0r itzpr3d4t0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@itzpr3d4t0r
Copy link
Member

itzpr3d4t0r commented May 8, 2024

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
Copy link
Member

oddbookworm commented May 8, 2024

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
Copy link
Member

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

@itzpr3d4t0r
Copy link
Member

@itzpr3d4t0r itzpr3d4t0r merged commit a68f741 into pygame-community:main May 8, 2024
39 checks passed
@Starbuck5 Starbuck5 deleted the surface-colorkey branch May 9, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Related to the speed or resource usage of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pygame.Surface.fblits slower in 2.5.0.dev2 vs 2.4.1
4 participants