Skip to content

Pixelarray SDL3 #3309

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 2 commits into from
Feb 19, 2025
Merged

Pixelarray SDL3 #3309

merged 2 commits into from
Feb 19, 2025

Conversation

Starbuck5
Copy link
Member

Today I ported a few modules and worked on a few others.

I first did everything with explicit SDL2 vs SDL3 code to observe patterns, then I made a few new compatibility macros to match what I saw.

This PR is those macros + the pixelarray module.

@Starbuck5 Starbuck5 added PixelArray pygame.PixelArray sdl3 labels Jan 26, 2025
@Starbuck5 Starbuck5 requested a review from a team as a code owner January 26, 2025 09:31
@@ -828,13 +859,12 @@ _compare(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
return 0;
}

new_format = surf->format;
Copy link
Member Author

Choose a reason for hiding this comment

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

This function goes from 3 pixel formats to 2. new_format == format as the code was written previously.

Should it actually be a format derived from new_surf instead of surf? Was the previous implementation a typo?

I'm not fully sure, but this translates it as was written.

@Starbuck5 Starbuck5 marked this pull request as draft January 26, 2025 09:55
@Starbuck5 Starbuck5 force-pushed the pixelarray-sdl3 branch 2 times, most recently from 644a2ec to 4696146 Compare January 26, 2025 20:50
@Starbuck5 Starbuck5 marked this pull request as ready for review January 26, 2025 21:02
@Starbuck5 Starbuck5 marked this pull request as draft January 26, 2025 22:13
@Starbuck5 Starbuck5 marked this pull request as ready for review January 27, 2025 02:38
@@ -1021,20 +1029,23 @@ _array_assign_array(pgPixelArrayObject *array, Py_ssize_t low, Py_ssize_t high,
}
break;
case 3: {
// Note:
// Why is the 24 bit case pixelformat aware but none of the rest are?
// - Starbuck, jan. 2025
Copy link
Member

Choose a reason for hiding this comment

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

How are the rest of the paths not pixelformat aware? I think they are assuming that source and destination pixelformats are same and therefore directly copying over the data. But I didn't find this check enforced in the code anywhere on a quick search?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just mean they don't take into account the pixelformat. As you say, it looks like they just assume the source and destination are the same. Going through the code we have a lot of pixel stuff in pygame-ce and lots of it has little suspicious items like that.

Copy link
Member

Choose a reason for hiding this comment

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

oh well, guess that can be addressed in future PRs, it shouldn't block this one

@Starbuck5
Copy link
Member Author

Rebased so it uses latest SDL2/SDL3 updates. (has it on the branch, so you don't need to swap dep versions between main and this).

Copy link
Member

@damusss damusss left a comment

Choose a reason for hiding this comment

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

Pretty understandable, and LGTM from what I can understand. Thanks for making it compile :) 👍

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. 🎉

IG this PR touches on some confusing code, but overall everything make sense so I am approving.

@ankith26 ankith26 added this to the 2.5.4 milestone Feb 19, 2025
@ankith26 ankith26 merged commit b0f35bc into pygame-community:main Feb 19, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PixelArray pygame.PixelArray sdl3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants