Skip to content
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

Fix issue #2446: rotozoom keeps the colorkey flag. #2491

Merged
merged 16 commits into from
Oct 28, 2023

Conversation

igordsm
Copy link
Contributor

@igordsm igordsm commented Oct 2, 2023

Issue #2446 reported that using rotozoom looses the colorkey information and provided code to reproduce the issue. We modified rotozoomSurface to copy colorkey from src to rz_dst and added a test to test/transform_test.py.

Closes #2446

Before:
image

After:

image

Co-authored-by: Joras <[email protected]>
Co-authored-by: Antonio <[email protected]>
Co-authored-by: João <[email protected]>
Co-authored-by: Caio <[email protected]>
Co-authored-by: Cícero <[email protected]>
Co-authored-by: Natália <[email protected]>
@igordsm igordsm requested a review from a team as a code owner October 2, 2023 11:59
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.

Hello, thanks for contributing to pygame-ce! 🎉 🍰

This seems like a nice fix, but we have CI failing on lint errors. To fix that run setup.py format and commit resulting changes (make sure you have the appropriate tools like black/clang-format installed)

@ankith26 ankith26 added transform pygame.transform bugfix PR that fixes bug labels Oct 2, 2023
src_c/transform.c Outdated Show resolved Hide resolved
src_c/transform.c Outdated Show resolved Hide resolved
src_c/transform.c Outdated Show resolved Hide resolved
Copy link
Member

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

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

Just added a note here about an RLE thing that likely needs fixing in general across the whole of transform.c before we add another version of it in here.

We probably also need to make some tests for it based on the first post in #1668 just to check if it still is, or isn't a problem, as SDL has likely changed since this issue was first posted.

src_c/rotozoom.c Show resolved Hide resolved
@MyreMylar
Copy link
Member

This will also need to merge in the latest main branch to pick up the grub-efi fix.

@igordsm
Copy link
Contributor Author

igordsm commented Oct 23, 2023

I'll get back to this in a few days

src_c/rotozoom.c Outdated Show resolved Hide resolved
src_c/rotozoom.c Outdated Show resolved Hide resolved
Copy link
Member

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

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

LGTM. Can confirm it fixes the issue and works with RLE and non-RLE colorkey surfaces. Thank you for the contribution!

👍 🎉

src_c/_pygame.h Outdated Show resolved Hide resolved
src_c/_pygame.h Outdated Show resolved Hide resolved
function was added in 2.0.14 - min SDL version currently 2.0.9
@MyreMylar
Copy link
Member

I realised while investigating the failing test that the function now known as SDL_SurfaceHasRLE that was renamed for SDL 3, was also only added to SDL 2 in version 2.0.14 so we are still 5 patch versions behind in our lowest supported SDL to use it. notably our wheels are ahead of this version so that's why I wasn't seeing this error locally.

I've just added a patch commit to vendor this function in for the case where SDL is less that 2.0.14. Not the most elegant solution (if it eventually works), but it should hold up OK as the function itself is super basic and we can delete it eventually when our bottom end catches up with our current main target.

src_c/_pygame.h Outdated Show resolved Hide resolved
src_c/_pygame.h Outdated Show resolved Hide resolved
src_c/_pygame.h Outdated Show resolved Hide resolved
src_c/_pygame.h Outdated Show resolved Hide resolved
src_c/_pygame.h Outdated Show resolved Hide resolved
@MyreMylar
Copy link
Member

Getting that to compile via Github web version interactions required a few compromises... I'm planning to do another PR on the topic of Surface RLE flags for the whole transform module once this gets merged, so I can almost certainly clean this up a bit in that PR.

src_c/_pygame.h Show resolved Hide resolved
src_c/_pygame.h Show resolved Hide resolved
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 🎉

@ankith26 ankith26 added this to the 2.4.0 milestone Oct 28, 2023
@ankith26
Copy link
Member

Noticed the original commit has many co-authors, so thank you all! Unless anyone minds, I'd like to squash-and-merge this PR but I will leave the co-author tags intact.

@MyreMylar
Copy link
Member

MyreMylar commented Oct 28, 2023 via email

@ankith26 ankith26 merged commit 56f30c3 into pygame-community:main Oct 28, 2023
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR that fixes bug transform pygame.transform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pygame.transform.rotozoom loses all surface flags
3 participants