@@ -811,6 +811,96 @@ int render_testBlitBlend(void *arg)
811811 return TEST_COMPLETED ;
812812}
813813
814+ static Uint32 read_surface_pixel32 (SDL_Surface * surface , int x , int y ) {
815+ Uint32 result ;
816+
817+ if (x >= surface -> w || y >= surface -> h ) {
818+ SDLTest_AssertCheck (x < surface -> w , "x (%d) < surface->w (%d)" , x , surface -> w );
819+ SDLTest_AssertCheck (y < surface -> h , "y (%d) < surface->h (%d)" , y , surface -> h );
820+ result = 0xdeadbabe ;
821+ } else {
822+ SDL_memcpy (& result , (Uint8 * )surface -> pixels + surface -> pitch * y + surface -> format -> BytesPerPixel * x , sizeof (Uint32 ));
823+ }
824+ return result ;
825+ }
826+
827+ static int render_testRGBSurfaceNoAlpha (void * arg )
828+ {
829+ SDL_Surface * surface ;
830+ SDL_Renderer * software_renderer ;
831+ SDL_Surface * surface2 ;
832+ SDL_Texture * texture2 ;
833+ int result ;
834+ SDL_Rect dest_rect ;
835+ SDL_Point point ;
836+ Uint32 pixel ;
837+
838+ SDLTest_AssertPass ("About to call SDL_CreateRGBSurface(0, 128, 128, 32, 0xff0000, 0xff00, 0xff, 0)" );
839+ surface = SDL_CreateRGBSurface (0 , 128 , 128 , 32 , 0xff0000 , 0xff00 , 0xff , 0 );
840+ SDLTest_AssertCheck (surface != NULL , "Returned surface must be not NULL" );
841+
842+ SDLTest_AssertCheck (surface -> format -> BitsPerPixel == 32 , "surface->format->BitsPerPixel should be 32, actual value is %d" , surface -> format -> BitsPerPixel );
843+ SDLTest_AssertCheck (surface -> format -> BytesPerPixel == 4 , "surface->format->BytesPerPixels should be 4, actual value is %d" , surface -> format -> BytesPerPixel );
844+
845+ SDLTest_AssertPass ("About to call SDL_CreateSoftwareRenderer(surface)" );
846+ software_renderer = SDL_CreateSoftwareRenderer (surface );
847+ SDLTest_AssertCheck (software_renderer != NULL , "Returned renderer must be not NULL" );
848+
849+ SDLTest_AssertPass ("About to call SDL_CreateRGBSurface(0, 16, 16, 32, 0xff0000, 0xff00, 0xff, 0)" );
850+ surface2 = SDL_CreateRGBSurface (0 , 16 , 16 , 32 , 0xff0000 , 0xff00 , 0xff , 0 );
851+ SDLTest_AssertCheck (surface2 != NULL , "Returned surface must be not NULL" );
852+
853+ SDLTest_AssertPass ("About to call SDL_FillRect(surface2, NULL, 0)" );
854+ result = SDL_FillRect (surface2 , NULL , SDL_MapRGB (surface2 -> format , 0 , 0 , 0 ));
855+ SDLTest_AssertCheck (result == 0 , "Result should be 0, actual value is %d" , result );
856+
857+ SDLTest_AssertPass ("About to call SDL_CreateTextureFromSurface(software_renderer, surface2)" );
858+ texture2 = SDL_CreateTextureFromSurface (software_renderer , surface2 );
859+ SDLTest_AssertCheck (texture2 != NULL , "Returned texture is not NULL" );
860+
861+ SDLTest_AssertPass ("About to call SDL_SetRenderDrawColor(renderer, 0xaa, 0xbb, 0xcc, 0x0)" );
862+ result = SDL_SetRenderDrawColor (software_renderer , 0xaa , 0xbb , 0xcc , 0x0 );
863+
864+ SDLTest_AssertPass ("About to call SDL_RenderClear(renderer)" );
865+ result = SDL_RenderClear (software_renderer );
866+ SDLTest_AssertCheck (result == 0 , "Result should be 0, actual value is %d" , result );
867+
868+ SDLTest_AssertPass ("About to call SDL_SetRenderDrawColor(renderer, 0x0, 0x0, 0x0, 0x0)" );
869+ result = SDL_SetRenderDrawColor (software_renderer , 0x0 , 0x0 , 0x0 , 0x0 );
870+ SDLTest_AssertCheck (result == 0 , "Result should be 0, actual value is %d" , result );
871+
872+ dest_rect .x = 32 ;
873+ dest_rect .y = 32 ;
874+ dest_rect .w = surface2 -> w ;
875+ dest_rect .h = surface2 -> h ;
876+ point .x = 0 ;
877+ point .y = 0 ;
878+ SDLTest_AssertPass ("About to call SDL_RenderCopy(software_renderer, texture, NULL, &{%d, %d, %d, %d})" ,
879+ dest_rect .x , dest_rect .h , dest_rect .w , dest_rect .h );
880+ result = SDL_RenderCopyEx (software_renderer , texture2 , NULL , & dest_rect , 180 , & point , SDL_FLIP_NONE );
881+ SDLTest_AssertCheck (result == 0 , "Result should be 0, actual value is %d" , result );
882+
883+ SDLTest_AssertPass ("About to call SDL_RenderPresent(software_renderer)" );
884+ SDL_RenderPresent (software_renderer );
885+
886+ pixel = read_surface_pixel32 (surface , 0 , 0 );
887+ SDLTest_AssertCheck (pixel == 0xAABBCCu , "Pixel at (0, 0) should be 0x%08x, actual value is 0x%08" SDL_PRIx32 , 0xAABBCCu , pixel );
888+ pixel = read_surface_pixel32 (surface , 15 , 15 );
889+ SDLTest_AssertCheck (pixel == 0xAABBCCu , "Pixel at (15, 15) should be 0x%08x, actual value is 0x%08" SDL_PRIx32 , 0xAABBCCu , pixel );
890+ pixel = read_surface_pixel32 (surface , 16 , 16 );
891+ SDLTest_AssertCheck (pixel == 0xFF000000u , "Pixel at (16, 16) should be 0x%08x, actual value is 0x%08" SDL_PRIx32 , 0xFF000000u , pixel );
892+ pixel = read_surface_pixel32 (surface , 31 , 31 );
893+ SDLTest_AssertCheck (pixel == 0xFF000000u , "Pixel at (31, 31) should be 0x%08x, actual value is 0x%08" SDL_PRIx32 , 0xFF000000u , pixel );
894+ pixel = read_surface_pixel32 (surface , 32 , 32 );
895+ SDLTest_AssertCheck (pixel == 0xAABBCCu , "Pixel at (32, 32) should be 0x%08x, actual value is 0x%08" SDL_PRIx32 , 0xAABBCCu , pixel );
896+
897+ SDL_DestroyTexture (texture2 );
898+ SDL_FreeSurface (surface2 );
899+ SDL_DestroyRenderer (software_renderer );
900+ SDL_FreeSurface (surface );
901+ return TEST_COMPLETED ;
902+ }
903+
814904/**
815905 * @brief Tests setting and getting texture scale mode.
816906 *
@@ -1205,9 +1295,13 @@ static const SDLTest_TestCaseReference renderTest8 = {
12051295 (SDLTest_TestCaseFp )render_testGetSetTextureScaleMode , "render_testGetSetTextureScaleMode" , "Tests setting/getting texture scale mode" , TEST_ENABLED
12061296};
12071297
1298+ static const SDLTest_TestCaseReference renderTest9 = {
1299+ (SDLTest_TestCaseFp )render_testRGBSurfaceNoAlpha , "render_testRGBSurfaceNoAlpha" , "Tests RGB surface with no alpha using software renderer" , TEST_ENABLED
1300+ };
1301+
12081302/* Sequence of Render test cases */
12091303static const SDLTest_TestCaseReference * renderTests [] = {
1210- & renderTest1 , & renderTest2 , & renderTest3 , & renderTest4 , & renderTest5 , & renderTest6 , & renderTest7 , & renderTest8 , NULL
1304+ & renderTest1 , & renderTest2 , & renderTest3 , & renderTest4 , & renderTest5 , & renderTest6 , & renderTest7 , & renderTest8 , & renderTest9 , NULL
12111305};
12121306
12131307/* Render test suite (global) */
0 commit comments