mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-03 06:09:20 +00:00
Unified the software renderer creation path
Previously there were two different paths for renderer creation, and the HDR metadata initialization was missing when creating a software renderer for a surface. Now all the cases are handled in a single path, so regardless of whether you create a software renderer by name, a software renderer for a surface, or fall back to a software renderer, you'll get the correct initialization in all cases. Fixes https://github.com/libsdl-org/SDL/issues/9221
This commit is contained in:
@@ -1116,7 +1116,7 @@ static void SW_SelectBestFormats(SDL_Renderer *renderer, SDL_PixelFormatEnum for
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface)
|
||||
SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
SW_RenderData *data;
|
||||
@@ -1168,12 +1168,19 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface)
|
||||
|
||||
SW_SelectBestFormats(renderer, surface->format->format);
|
||||
|
||||
SDL_SetupRendererColorspace(renderer, create_props);
|
||||
|
||||
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB) {
|
||||
SDL_SetError("Unsupported output colorspace");
|
||||
SW_DestroyRenderer(renderer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
const char *hint;
|
||||
SDL_Surface *surface;
|
||||
SDL_bool no_hint_set;
|
||||
@@ -1205,20 +1212,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, SDL_PropertiesID crea
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = SW_CreateRendererForSurface(surface);
|
||||
if (!renderer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_SetupRendererColorspace(renderer, create_props);
|
||||
|
||||
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB) {
|
||||
SDL_SetError("Unsupported output colorspace");
|
||||
SW_DestroyRenderer(renderer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return renderer;
|
||||
return SW_CreateRendererForSurface(surface, create_props);
|
||||
}
|
||||
|
||||
SDL_RenderDriver SW_RenderDriver = {
|
||||
|
||||
@@ -22,6 +22,6 @@
|
||||
#ifndef SDL_render_sw_c_h_
|
||||
#define SDL_render_sw_c_h_
|
||||
|
||||
extern SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface);
|
||||
extern SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface, SDL_PropertiesID create_props);
|
||||
|
||||
#endif /* SDL_render_sw_c_h_ */
|
||||
|
||||
Reference in New Issue
Block a user