Commit 02d897e8 authored by Sam Lantinga's avatar Sam Lantinga

We want to be strict on software renderer tests and opaque tests, but give a...

We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404218
parent e957ccc2
......@@ -16,7 +16,7 @@
/**
* @brief Compares a surface and a surface image for equality.
*/
int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img )
int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img, int allowable_error )
{
int ret;
int i,j;
......@@ -62,8 +62,8 @@ int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img )
dist += (B-pd[2])*(B-pd[2]);
dist += (A-pd[3])*(A-pd[3]);
}
/* Allow up to sqrt(32) difference in blending accuracy */
if (dist > 64) {
/* Allow some difference in blending accuracy */
if (dist > allowable_error) {
/*printf("pixel %d,%d varies by %d\n", i, j, dist);*/
++ret;
}
......
......@@ -25,6 +25,8 @@ typedef struct SurfaceImage_s {
const unsigned char pixel_data[];
} SurfaceImage_t;
#define ALLOWABLE_ERROR_OPAQUE 0
#define ALLOWABLE_ERROR_BLENDED 64
/**
* @brief Compares a surface and a surface image for equality.
......@@ -33,7 +35,7 @@ typedef struct SurfaceImage_s {
* @param img Image to compare against.
* @return 0 if they are the same, -1 on error and positive if different.
*/
int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img );
int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img, int allowable_error );
#endif /* COMMON_H */
......
......@@ -29,7 +29,7 @@
/*
* Prototypes.
*/
static int render_compare( const char *msg, const SurfaceImage_t *s );
static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error );
static int render_isSupported( int code );
static int render_hasDrawColor (void);
static int render_hasBlendModes (void);
......@@ -53,7 +53,7 @@ static int render_testBlitBlend (void);
* @param s Image to compare against.
* @return 0 on success.
*/
static int render_compare( const char *msg, const SurfaceImage_t *s )
static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error )
{
(void) msg;
(void) s;
......@@ -73,7 +73,7 @@ static int render_compare( const char *msg, const SurfaceImage_t *s )
return 1;
/* Compare surface. */
ret = surface_compare( testsur, s );
ret = surface_compare( testsur, s, allowable_error );
if (SDL_ATassert( msg, ret==0 ))
return 1;
......@@ -445,7 +445,7 @@ static int render_testPrimitives (void)
return -1;
/* See if it's the same. */
if (render_compare( "Primitives output not the same.", &img_primitives ))
if (render_compare( "Primitives output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE ))
return -1;
return 0;
......@@ -562,7 +562,7 @@ static int render_testPrimitivesBlend (void)
}
/* See if it's the same. */
if (render_compare( "Blended primitives output not the same.", &img_blend ))
if (render_compare( "Blended primitives output not the same.", &img_blend, ALLOWABLE_ERROR_BLENDED ))
return -1;
return 0;
......@@ -614,7 +614,7 @@ static int render_testBlit (void)
SDL_DestroyTexture( tface );
/* See if it's the same. */
if (render_compare( "Blit output not the same.", &img_blit ))
if (render_compare( "Blit output not the same.", &img_blit, ALLOWABLE_ERROR_OPAQUE ))
return -1;
return 0;
......@@ -672,7 +672,7 @@ static int render_testBlitColour (void)
/* See if it's the same. */
if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).",
&img_blitColour ))
&img_blitColour, ALLOWABLE_ERROR_OPAQUE ))
return -1;
return 0;
......@@ -734,7 +734,7 @@ static int render_testBlitAlpha (void)
/* See if it's the same. */
if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).",
&img_blitAlpha ))
&img_blitAlpha, ALLOWABLE_ERROR_BLENDED ))
return -1;
return 0;
......@@ -825,35 +825,35 @@ static int render_testBlitBlend (void)
return -1;
/* See if it's the same. */
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).",
&img_blendNone ))
&img_blendNone, ALLOWABLE_ERROR_OPAQUE ))
return -1;
/* Test Mask. */
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK ))
return -1;
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MASK).",
&img_blendMask ))
&img_blendMask, ALLOWABLE_ERROR_OPAQUE ))
return -1;
/* Test Blend. */
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ))
return -1;
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).",
&img_blendBlend ))
&img_blendBlend, ALLOWABLE_ERROR_BLENDED ))
return -1;
/* Test Add. */
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD ))
return -1;
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).",
&img_blendAdd ))
&img_blendAdd, ALLOWABLE_ERROR_BLENDED ))
return -1;
/* Test Mod. */
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD ))
return -1;
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
&img_blendMod ))
&img_blendMod, ALLOWABLE_ERROR_BLENDED ))
return -1;
/* Clear surface. */
......@@ -898,7 +898,7 @@ static int render_testBlitBlend (void)
/* Check to see if matches. */
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).",
&img_blendAll ))
&img_blendAll, ALLOWABLE_ERROR_BLENDED ))
return -1;
return 0;
......
......@@ -69,7 +69,7 @@ static void surface_testLoad( SDL_Surface *testsur )
/* See if it's the same. */
if (SDL_ATassert( "Primitives output not the same.",
surface_compare( rface, &img_face)==0 ))
surface_compare( rface, &img_face, 0 )==0 ))
return;
/* Clean up. */
......@@ -159,7 +159,7 @@ static void surface_testPrimitives( SDL_Surface *testsur )
/* See if it's the same. */
if (SDL_ATassert( "Primitives output not the same.",
surface_compare( testsur, &img_primitives )==0 ))
surface_compare( testsur, &img_primitives, 0 )==0 ))
return;
SDL_ATend();
......@@ -241,7 +241,7 @@ static void surface_testPrimitivesBlend( SDL_Surface *testsur )
/* See if it's the same. */
if (SDL_ATassert( "Primitives output not the same.",
surface_compare( testsur, &img_blend )==0 ))
surface_compare( testsur, &img_blend, 0 )==0 ))
return;
SDL_ATend();
......@@ -304,7 +304,7 @@ static void surface_testBlit( SDL_Surface *testsur )
/* See if it's the same. */
if (SDL_ATassert( "Blitting output not the same (normal blit).",
surface_compare( testsur, &img_blit )==0 ))
surface_compare( testsur, &img_blit, 0 )==0 ))
return;
/* Clear surface. */
......@@ -332,7 +332,7 @@ static void surface_testBlit( SDL_Surface *testsur )
/* See if it's the same. */
if (SDL_ATassert( "Blitting output not the same (using SDL_SetSurfaceColorMod).",
surface_compare( testsur, &img_blitColour )==0 ))
surface_compare( testsur, &img_blitColour, 0 )==0 ))
return;
/* Clear surface. */
......@@ -365,7 +365,7 @@ static void surface_testBlit( SDL_Surface *testsur )
/* See if it's the same. */
if (SDL_ATassert( "Blitting output not the same (using SDL_SetSurfaceAlphaMod).",
surface_compare( testsur, &img_blitAlpha )==0 ))
surface_compare( testsur, &img_blitAlpha, 0 )==0 ))
return;
/* Clean up. */
......@@ -473,35 +473,35 @@ static void surface_testBlitBlend( SDL_Surface *testsur )
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE ))
return;
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_NONE).",
surface_compare( testsur, &img_blendNone )==0 ))
surface_compare( testsur, &img_blendNone, 0 )==0 ))
return;
/* Test Mask. */
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MASK ))
return;
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MASK).",
surface_compare( testsur, &img_blendMask )==0 ))
surface_compare( testsur, &img_blendMask, 0 )==0 ))
return;
/* Test Blend. */
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND ))
return;
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_BLEND).",
surface_compare( testsur, &img_blendBlend )==0 ))
surface_compare( testsur, &img_blendBlend, 0 )==0 ))
return;
/* Test Add. */
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD ))
return;
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_ADD).",
surface_compare( testsur, &img_blendAdd )==0 ))
surface_compare( testsur, &img_blendAdd, 0 )==0 ))
return;
/* Test Mod. */
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD ))
return;
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MOD).",
surface_compare( testsur, &img_blendMod )==0 ))
surface_compare( testsur, &img_blendMod, 0 )==0 ))
return;
/* Clear surface. */
......@@ -545,7 +545,7 @@ static void surface_testBlitBlend( SDL_Surface *testsur )
/* Check to see if matches. */
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLEND_*).",
surface_compare( testsur, &img_blendAll )==0 ))
surface_compare( testsur, &img_blendAll, 0 )==0 ))
return;
/* Clean up. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment