Revert "testautomation: don't validate alpha values on XRGB formats"

This reverts commit 759e01bd64.

It's better to return the expected format from SDL_RenderReadPixels() than skip alpha testing.
This commit is contained in:
Sam Lantinga 2025-01-20 11:40:04 -08:00
parent dcadd23ba1
commit 9b454a762c
2 changed files with 17 additions and 8 deletions

View file

@ -5006,8 +5006,22 @@ SDL_Surface *SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
SDL_PropertiesID props = SDL_GetSurfaceProperties(surface); SDL_PropertiesID props = SDL_GetSurfaceProperties(surface);
if (renderer->target) { if (renderer->target) {
SDL_SetFloatProperty(props, SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT, renderer->target->SDR_white_point); SDL_Texture *target = renderer->target;
SDL_SetFloatProperty(props, SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT, renderer->target->HDR_headroom); SDL_Texture *parent = SDL_GetPointerProperty(SDL_GetTextureProperties(target), SDL_PROP_TEXTURE_PARENT_POINTER, NULL);
SDL_PixelFormat expected_format = (parent ? parent->format : target->format);
SDL_SetFloatProperty(props, SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT, target->SDR_white_point);
SDL_SetFloatProperty(props, SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT, target->HDR_headroom);
// Set the expected surface format
if ((surface->format == SDL_PIXELFORMAT_ARGB8888 && expected_format == SDL_PIXELFORMAT_XRGB8888) ||
(surface->format == SDL_PIXELFORMAT_RGBA8888 && expected_format == SDL_PIXELFORMAT_RGBX8888) ||
(surface->format == SDL_PIXELFORMAT_ABGR8888 && expected_format == SDL_PIXELFORMAT_XBGR8888) ||
(surface->format == SDL_PIXELFORMAT_BGRA8888 && expected_format == SDL_PIXELFORMAT_BGRX8888)) {
printf("changing format\n");
surface->format = expected_format;
surface->fmt = SDL_GetPixelFormatDetails(expected_format);
}
} else { } else {
SDL_SetFloatProperty(props, SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT, renderer->SDR_white_point); SDL_SetFloatProperty(props, SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT, renderer->SDR_white_point);
SDL_SetFloatProperty(props, SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT, renderer->HDR_headroom); SDL_SetFloatProperty(props, SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT, renderer->HDR_headroom);

View file

@ -897,12 +897,7 @@ static void testBlendModeOperation(TestRenderOperation op, int mode, SDL_PixelFo
deltaR = SDL_abs((int)actualR - expectedR); deltaR = SDL_abs((int)actualR - expectedR);
deltaG = SDL_abs((int)actualG - expectedG); deltaG = SDL_abs((int)actualG - expectedG);
deltaB = SDL_abs((int)actualB - expectedB); deltaB = SDL_abs((int)actualB - expectedB);
if (SDL_ISPIXELFORMAT_ALPHA(dst_format)) { deltaA = SDL_abs((int)actualA - expectedA);
deltaA = SDL_abs((int)actualA - expectedA);
} else {
// The alpha channel is ignored in non-alpha formats, so don't validate it
deltaA = 0;
}
SDLTest_AssertCheck( SDLTest_AssertCheck(
deltaR <= MAXIMUM_ERROR && deltaR <= MAXIMUM_ERROR &&
deltaG <= MAXIMUM_ERROR && deltaG <= MAXIMUM_ERROR &&