-
-
Notifications
You must be signed in to change notification settings - Fork 217
[Part 3] SDL3: surface+pixelarray+font+draw: runtime fixes #3578
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,9 +77,17 @@ | |
|
|
||
| #define PG_CreateSurface SDL_CreateSurface | ||
| #define PG_CreateSurfaceFrom SDL_CreateSurfaceFrom | ||
| #define PG_ConvertSurface SDL_ConvertSurface | ||
| #define PG_ConvertSurfaceFormat SDL_ConvertSurface | ||
|
|
||
| /* Convert surface using palette and format of dst */ | ||
| static inline SDL_Surface * | ||
| PG_ConvertSurface(SDL_Surface *surface, SDL_Surface *dst) | ||
| { | ||
| return SDL_ConvertSurfaceAndColorspace(surface, dst->format, | ||
| SDL_GetSurfacePalette(dst), | ||
| SDL_GetSurfaceColorspace(dst), 0); | ||
| } | ||
|
|
||
| #define PG_PixelFormatEnum SDL_PixelFormat | ||
|
|
||
| #define PG_SurfaceHasRLE SDL_SurfaceHasRLE | ||
|
|
@@ -144,11 +152,23 @@ PG_SURF_BitsPerPixel(SDL_Surface *surf) | |
|
|
||
| #define PG_PixelFormat const SDL_PixelFormatDetails | ||
|
|
||
| static inline SDL_Palette * | ||
| PG_GetSurfacePalette(SDL_Surface *surf) | ||
| { | ||
| SDL_Palette *ret = SDL_GetSurfacePalette(surf); | ||
| if (!ret && SDL_ISPIXELFORMAT_INDEXED(surf->format)) { | ||
| /* Palette doesn't exist but is expected, so create it. | ||
| * SDL will associate the newly created palette with the surface */ | ||
| ret = SDL_CreateSurfacePalette(surf); | ||
| } | ||
|
Comment on lines
+159
to
+163
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is how we should be doing this. If our surfaces are missing palettes we deal with that when the surface is not created, not randomly at any point as a side effect of a getter function. And/or make the consumers okay with index formats without palettes, since that's a thing in SDL3 and therefore we will want to support it anyway.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this being part of the getter makes sense considering that the getter is responsible for returning a palette, and we must ensure it doesn't return |
||
| return ret; | ||
| } | ||
|
|
||
| static inline bool | ||
| PG_GetSurfaceDetails(SDL_Surface *surf, PG_PixelFormat **format_p, | ||
| SDL_Palette **palette_p) | ||
| { | ||
| *palette_p = SDL_GetSurfacePalette(surf); | ||
| *palette_p = PG_GetSurfacePalette(surf); | ||
| *format_p = SDL_GetPixelFormatDetails(surf->format); | ||
| return *format_p != NULL; | ||
| } | ||
|
|
@@ -159,7 +179,6 @@ PG_GetSurfaceFormat(SDL_Surface *surf) | |
| return SDL_GetPixelFormatDetails(surf->format); | ||
| } | ||
|
|
||
| #define PG_GetSurfacePalette SDL_GetSurfacePalette | ||
| #define PG_SetPaletteColors SDL_SetPaletteColors | ||
| #define PG_SetSurfacePalette SDL_SetSurfacePalette | ||
| #define PG_SetSurfaceColorKey SDL_SetSurfaceColorKey | ||
|
|
@@ -215,10 +234,15 @@ PG_GetSurfaceFormat(SDL_Surface *surf) | |
| SDL_CreateRGBSurfaceWithFormat(0, width, height, 0, format) | ||
| #define PG_CreateSurfaceFrom(width, height, format, pixels, pitch) \ | ||
| SDL_CreateRGBSurfaceWithFormatFrom(pixels, width, height, 0, pitch, format) | ||
| #define PG_ConvertSurface(src, fmt) SDL_ConvertSurface(src, fmt, 0) | ||
| #define PG_ConvertSurfaceFormat(src, pixel_format) \ | ||
| SDL_ConvertSurfaceFormat(src, pixel_format, 0) | ||
|
|
||
| static inline SDL_Surface * | ||
| PG_ConvertSurface(SDL_Surface *surface, SDL_Surface *dst) | ||
| { | ||
| return SDL_ConvertSurface(surface, dst->format, 0); | ||
| } | ||
|
|
||
| #define PG_PixelFormatEnum SDL_PixelFormatEnum | ||
|
|
||
| #define PG_SoftStretchNearest(src, srcrect, dst, dstrect) \ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.