comparison test/automated/render/render.c @ 3477:2c07bb579922

We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 21 Nov 2009 07:59:19 +0000
parents da53c4046c65
children c32c53fca10d
comparison
equal deleted inserted replaced
3476:ab99313951cd 3477:2c07bb579922
27 27
28 28
29 /* 29 /*
30 * Prototypes. 30 * Prototypes.
31 */ 31 */
32 static int render_compare( const char *msg, const SurfaceImage_t *s ); 32 static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error );
33 static int render_isSupported( int code ); 33 static int render_isSupported( int code );
34 static int render_hasDrawColor (void); 34 static int render_hasDrawColor (void);
35 static int render_hasBlendModes (void); 35 static int render_hasBlendModes (void);
36 static int render_hasTexColor (void); 36 static int render_hasTexColor (void);
37 static int render_hasTexAlpha (void); 37 static int render_hasTexAlpha (void);
51 * 51 *
52 * @param msg Message on failure. 52 * @param msg Message on failure.
53 * @param s Image to compare against. 53 * @param s Image to compare against.
54 * @return 0 on success. 54 * @return 0 on success.
55 */ 55 */
56 static int render_compare( const char *msg, const SurfaceImage_t *s ) 56 static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error )
57 { 57 {
58 (void) msg; 58 (void) msg;
59 (void) s; 59 (void) s;
60 int ret; 60 int ret;
61 Uint8 pix[4*80*60]; 61 Uint8 pix[4*80*60];
71 RMASK, GMASK, BMASK, AMASK); 71 RMASK, GMASK, BMASK, AMASK);
72 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL )) 72 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL ))
73 return 1; 73 return 1;
74 74
75 /* Compare surface. */ 75 /* Compare surface. */
76 ret = surface_compare( testsur, s ); 76 ret = surface_compare( testsur, s, allowable_error );
77 if (SDL_ATassert( msg, ret==0 )) 77 if (SDL_ATassert( msg, ret==0 ))
78 return 1; 78 return 1;
79 79
80 /* Clean up. */ 80 /* Clean up. */
81 SDL_FreeSurface( testsur ); 81 SDL_FreeSurface( testsur );
443 ret = SDL_RenderLine( 79, 59, 50, 30 ); 443 ret = SDL_RenderLine( 79, 59, 50, 30 );
444 if (SDL_ATassert( "SDL_RenderLine", ret == 0)) 444 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
445 return -1; 445 return -1;
446 446
447 /* See if it's the same. */ 447 /* See if it's the same. */
448 if (render_compare( "Primitives output not the same.", &img_primitives )) 448 if (render_compare( "Primitives output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE ))
449 return -1; 449 return -1;
450 450
451 return 0; 451 return 0;
452 } 452 }
453 453
560 return -1; 560 return -1;
561 } 561 }
562 } 562 }
563 563
564 /* See if it's the same. */ 564 /* See if it's the same. */
565 if (render_compare( "Blended primitives output not the same.", &img_blend )) 565 if (render_compare( "Blended primitives output not the same.", &img_blend, ALLOWABLE_ERROR_BLENDED ))
566 return -1; 566 return -1;
567 567
568 return 0; 568 return 0;
569 } 569 }
570 570
612 612
613 /* Clean up. */ 613 /* Clean up. */
614 SDL_DestroyTexture( tface ); 614 SDL_DestroyTexture( tface );
615 615
616 /* See if it's the same. */ 616 /* See if it's the same. */
617 if (render_compare( "Blit output not the same.", &img_blit )) 617 if (render_compare( "Blit output not the same.", &img_blit, ALLOWABLE_ERROR_OPAQUE ))
618 return -1; 618 return -1;
619 619
620 return 0; 620 return 0;
621 } 621 }
622 622
670 /* Clean up. */ 670 /* Clean up. */
671 SDL_DestroyTexture( tface ); 671 SDL_DestroyTexture( tface );
672 672
673 /* See if it's the same. */ 673 /* See if it's the same. */
674 if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).", 674 if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).",
675 &img_blitColour )) 675 &img_blitColour, ALLOWABLE_ERROR_OPAQUE ))
676 return -1; 676 return -1;
677 677
678 return 0; 678 return 0;
679 } 679 }
680 680
732 /* Clean up. */ 732 /* Clean up. */
733 SDL_DestroyTexture( tface ); 733 SDL_DestroyTexture( tface );
734 734
735 /* See if it's the same. */ 735 /* See if it's the same. */
736 if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).", 736 if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).",
737 &img_blitAlpha )) 737 &img_blitAlpha, ALLOWABLE_ERROR_BLENDED ))
738 return -1; 738 return -1;
739 739
740 return 0; 740 return 0;
741 } 741 }
742 742
823 /* Test None. */ 823 /* Test None. */
824 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_NONE )) 824 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_NONE ))
825 return -1; 825 return -1;
826 /* See if it's the same. */ 826 /* See if it's the same. */
827 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).", 827 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).",
828 &img_blendNone )) 828 &img_blendNone, ALLOWABLE_ERROR_OPAQUE ))
829 return -1; 829 return -1;
830 830
831 /* Test Mask. */ 831 /* Test Mask. */
832 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK )) 832 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK ))
833 return -1; 833 return -1;
834 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MASK).", 834 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MASK).",
835 &img_blendMask )) 835 &img_blendMask, ALLOWABLE_ERROR_OPAQUE ))
836 return -1; 836 return -1;
837 837
838 /* Test Blend. */ 838 /* Test Blend. */
839 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND )) 839 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ))
840 return -1; 840 return -1;
841 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).", 841 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).",
842 &img_blendBlend )) 842 &img_blendBlend, ALLOWABLE_ERROR_BLENDED ))
843 return -1; 843 return -1;
844 844
845 /* Test Add. */ 845 /* Test Add. */
846 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD )) 846 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD ))
847 return -1; 847 return -1;
848 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).", 848 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).",
849 &img_blendAdd )) 849 &img_blendAdd, ALLOWABLE_ERROR_BLENDED ))
850 return -1; 850 return -1;
851 851
852 /* Test Mod. */ 852 /* Test Mod. */
853 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD )) 853 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD ))
854 return -1; 854 return -1;
855 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).", 855 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
856 &img_blendMod )) 856 &img_blendMod, ALLOWABLE_ERROR_BLENDED ))
857 return -1; 857 return -1;
858 858
859 /* Clear surface. */ 859 /* Clear surface. */
860 if (render_clearScreen()) 860 if (render_clearScreen())
861 return -1; 861 return -1;
896 /* Clean up. */ 896 /* Clean up. */
897 SDL_DestroyTexture( tface ); 897 SDL_DestroyTexture( tface );
898 898
899 /* Check to see if matches. */ 899 /* Check to see if matches. */
900 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).", 900 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).",
901 &img_blendAll )) 901 &img_blendAll, ALLOWABLE_ERROR_BLENDED ))
902 return -1; 902 return -1;
903 903
904 return 0; 904 return 0;
905 } 905 }
906 906