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

Pixelarray SDL3 #3309

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

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
Comment on lines +31 to +42
#define PXM_GET_PIXELVALS(_sR, _sG, _sB, _sA, px, fmt, palette, ppa) \
PG_GetRGBA(px, fmt, palette, &(_sR), &(_sG), &(_sB), &(_sA)); \
if (!ppa) { \
_sA = 255; \
}

#define PXM_GET_PIXELVALS_1(sr, sg, sb, sa, _src, _palette) \
sr = _palette->colors[*((Uint8 *)(_src))].r; \
sg = _palette->colors[*((Uint8 *)(_src))].g; \
sb = _palette->colors[*((Uint8 *)(_src))].b; \
sa = 255;

Copy link
Member Author

Choose a reason for hiding this comment

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

Once surface.h is ported over (where the non PXM_ variants of these macros live), these should be removed and everyone should use the one consistent set.

@@ -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?

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.

2 participants