-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Move transform towards compiling w/ SDL3 #3314
base: main
Are you sure you want to change the base?
Conversation
src_c/transform.c
Outdated
PG_GetRGBA(color, fmt, src_palette, &Cr, &Cg, &Cb, &Ca); | ||
const Uint16 color16 = | ||
(Uint16)PG_MapRGBA(newsurf_format, newsurf_palette, Cr, Cg, Cb, Ca); | ||
|
||
for (y = 0; y < src->h; y++) { | ||
for (x = 0; x < src->w; x++) { | ||
SDL_GetRGBA((Uint32)*src_row, fmt, &r, &g, &b, &a); | ||
PG_GetRGBA((Uint32)*src_row, fmt, src_palette, &r, &g, &b, &a); | ||
|
||
if (a) { | ||
if (keep_alpha) | ||
*dst_row = (Uint16)SDL_MapRGBA(fmt, Cr, Cg, Cb, a); | ||
*dst_row = (Uint16)PG_MapRGBA( | ||
newsurf_format, newsurf_palette, Cr, Cg, Cb, a); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Now marked outdated because of a formatting change)
So previously the color16=
and *dst_row = (Uint16)SDL_MapRGBA
lines here used the fmt
variable, which represents the format of the surface "src".
However, these values are being mapped to "newsurf", not "src". So why is it written like this?
Well, the format enums are checked earlier, so the author of this code probably thought it made no difference.
However I can think of a case where passing in a destination surface with a custom palette into this would be different.
So I've changed the behavior here very slightly to be more correct, by mapping colors using the data of the surface being mapped to (newsurf). I don't think anyone will notice, I feel like this a very weird edge case, and this is a very new function as well. Regardless, if this change complicates this PR too much I can pull it out into a different PR or drop it.
@@ -2605,7 +2660,7 @@ modify_hsl(SDL_Surface *surf, SDL_Surface *dst, float h, float s, float l) | |||
} | |||
|
|||
HSL_to_RGB(s_h, s_s, s_l, &r, &g, &b); | |||
pixel = SDL_MapRGBA(fmt, r, g, b, a); | |||
pixel = PG_MapRGBA(dst_format, dst_palette, r, g, b, a); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a similar situation here. Previously, it was using fmt, which represents the other surface, not the surface being written to.
5812d7e
to
4e24774
Compare
#3310 but for transform.