From 7f1feee02ab88770238219ee5e8c3c0bf81c6e4b Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 21 Mar 2022 10:20:04 +0100 Subject: [PATCH] Fixed bug #2426 - SDL_RenderReadPixels result is unspecified and fails testautomation Call SDL_RenderPresent after calling SDL_RenderReadPixels. From "include/SDL_render.h": "If you're using this on the main rendering target, it should be called after rendering and before SDL_RenderPresent()." --- test/testautomation_render.c | 59 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/test/testautomation_render.c b/test/testautomation_render.c index 42fc54dee..0117334a2 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -187,14 +187,14 @@ int render_testPrimitives (void *arg) ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); - - /* Make current */ - SDL_RenderPresent(renderer); - + /* See if it's the same. */ referenceSurface = SDLTest_ImagePrimitives(); _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); + /* Make current */ + SDL_RenderPresent(renderer); + /* Clean up. */ SDL_FreeSurface(referenceSurface); referenceSurface = NULL; @@ -335,13 +335,13 @@ int render_testPrimitivesBlend (void *arg) SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2); SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount3); - /* Make current */ - SDL_RenderPresent(renderer); - /* See if it's the same. */ referenceSurface = SDLTest_ImagePrimitivesBlend(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); + /* Make current */ + SDL_RenderPresent(renderer); + /* Clean up. */ SDL_FreeSurface(referenceSurface); referenceSurface = NULL; @@ -404,13 +404,13 @@ render_testBlit(void *arg) } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount1); - /* Make current */ - SDL_RenderPresent(renderer); - /* See if it's the same */ referenceSurface = SDLTest_ImageBlit(); _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); + /* Make current */ + SDL_RenderPresent(renderer); + /* Clean up. */ SDL_DestroyTexture( tface ); SDL_FreeSurface(referenceSurface); @@ -478,13 +478,13 @@ render_testBlitColor (void *arg) SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2); - /* Make current */ - SDL_RenderPresent(renderer); - /* See if it's the same. */ referenceSurface = SDLTest_ImageBlitColor(); _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); + /* Make current */ + SDL_RenderPresent(renderer); + /* Clean up. */ SDL_DestroyTexture( tface ); SDL_FreeSurface(referenceSurface); @@ -555,13 +555,13 @@ render_testBlitAlpha (void *arg) SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2); - /* Make current */ - SDL_RenderPresent(renderer); - /* See if it's the same. */ referenceSurface = SDLTest_ImageBlitAlpha(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); + /* Make current */ + SDL_RenderPresent(renderer); + /* Clean up. */ SDL_DestroyTexture( tface ); SDL_FreeSurface(referenceSurface); @@ -674,9 +674,10 @@ render_testBlitBlend (void *arg) _testBlitBlendMode( tface, SDL_BLENDMODE_NONE ); referenceSurface = SDLTest_ImageBlitBlendNone(); - /* Make current and compare */ - SDL_RenderPresent(renderer); + /* Compare, then Present */ _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); + SDL_RenderPresent(renderer); + SDL_FreeSurface(referenceSurface); referenceSurface = NULL; @@ -684,9 +685,10 @@ render_testBlitBlend (void *arg) _testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ); referenceSurface = SDLTest_ImageBlitBlend(); - /* Make current and compare */ - SDL_RenderPresent(renderer); + /* Compare, then Present */ _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); + SDL_RenderPresent(renderer); + SDL_FreeSurface(referenceSurface); referenceSurface = NULL; @@ -694,9 +696,10 @@ render_testBlitBlend (void *arg) _testBlitBlendMode( tface, SDL_BLENDMODE_ADD ); referenceSurface = SDLTest_ImageBlitBlendAdd(); - /* Make current and compare */ - SDL_RenderPresent(renderer); + /* Compare, then Present */ _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); + SDL_RenderPresent(renderer); + SDL_FreeSurface(referenceSurface); referenceSurface = NULL; @@ -704,9 +707,10 @@ render_testBlitBlend (void *arg) _testBlitBlendMode( tface, SDL_BLENDMODE_MOD); referenceSurface = SDLTest_ImageBlitBlendMod(); - /* Make current and compare */ - SDL_RenderPresent(renderer); + /* Compare, then Present */ _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); + SDL_RenderPresent(renderer); + SDL_FreeSurface(referenceSurface); referenceSurface = NULL; @@ -753,12 +757,13 @@ render_testBlitBlend (void *arg) /* Clean up. */ SDL_DestroyTexture( tface ); - /* Make current */ - SDL_RenderPresent(renderer); - /* Check to see if final image matches. */ referenceSurface = SDLTest_ImageBlitBlendAll(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); + + /* Make current */ + SDL_RenderPresent(renderer); + SDL_FreeSurface(referenceSurface); referenceSurface = NULL;