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
This commit is contained in:
parent
e957ccc22a
commit
02d897e864
4 changed files with 32 additions and 30 deletions
|
@ -16,7 +16,7 @@
|
||||||
/**
|
/**
|
||||||
* @brief Compares a surface and a surface image for equality.
|
* @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 ret;
|
||||||
int i,j;
|
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 += (B-pd[2])*(B-pd[2]);
|
||||||
dist += (A-pd[3])*(A-pd[3]);
|
dist += (A-pd[3])*(A-pd[3]);
|
||||||
}
|
}
|
||||||
/* Allow up to sqrt(32) difference in blending accuracy */
|
/* Allow some difference in blending accuracy */
|
||||||
if (dist > 64) {
|
if (dist > allowable_error) {
|
||||||
/*printf("pixel %d,%d varies by %d\n", i, j, dist);*/
|
/*printf("pixel %d,%d varies by %d\n", i, j, dist);*/
|
||||||
++ret;
|
++ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ typedef struct SurfaceImage_s {
|
||||||
const unsigned char pixel_data[];
|
const unsigned char pixel_data[];
|
||||||
} SurfaceImage_t;
|
} SurfaceImage_t;
|
||||||
|
|
||||||
|
#define ALLOWABLE_ERROR_OPAQUE 0
|
||||||
|
#define ALLOWABLE_ERROR_BLENDED 64
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compares a surface and a surface image for equality.
|
* @brief Compares a surface and a surface image for equality.
|
||||||
|
@ -33,7 +35,7 @@ typedef struct SurfaceImage_s {
|
||||||
* @param img Image to compare against.
|
* @param img Image to compare against.
|
||||||
* @return 0 if they are the same, -1 on error and positive if different.
|
* @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 */
|
#endif /* COMMON_H */
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
/*
|
/*
|
||||||
* Prototypes.
|
* 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_isSupported( int code );
|
||||||
static int render_hasDrawColor (void);
|
static int render_hasDrawColor (void);
|
||||||
static int render_hasBlendModes (void);
|
static int render_hasBlendModes (void);
|
||||||
|
@ -53,7 +53,7 @@ static int render_testBlitBlend (void);
|
||||||
* @param s Image to compare against.
|
* @param s Image to compare against.
|
||||||
* @return 0 on success.
|
* @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) msg;
|
||||||
(void) s;
|
(void) s;
|
||||||
|
@ -73,7 +73,7 @@ static int render_compare( const char *msg, const SurfaceImage_t *s )
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* Compare surface. */
|
/* Compare surface. */
|
||||||
ret = surface_compare( testsur, s );
|
ret = surface_compare( testsur, s, allowable_error );
|
||||||
if (SDL_ATassert( msg, ret==0 ))
|
if (SDL_ATassert( msg, ret==0 ))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ static int render_testPrimitives (void)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* 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 -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -562,7 +562,7 @@ static int render_testPrimitivesBlend (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* 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 -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -614,7 +614,7 @@ static int render_testBlit (void)
|
||||||
SDL_DestroyTexture( tface );
|
SDL_DestroyTexture( tface );
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* 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 -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -672,7 +672,7 @@ static int render_testBlitColour (void)
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* See if it's the same. */
|
||||||
if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).",
|
if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).",
|
||||||
&img_blitColour ))
|
&img_blitColour, ALLOWABLE_ERROR_OPAQUE ))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -734,7 +734,7 @@ static int render_testBlitAlpha (void)
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* See if it's the same. */
|
||||||
if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).",
|
if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).",
|
||||||
&img_blitAlpha ))
|
&img_blitAlpha, ALLOWABLE_ERROR_BLENDED ))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -825,35 +825,35 @@ static int render_testBlitBlend (void)
|
||||||
return -1;
|
return -1;
|
||||||
/* See if it's the same. */
|
/* See if it's the same. */
|
||||||
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).",
|
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).",
|
||||||
&img_blendNone ))
|
&img_blendNone, ALLOWABLE_ERROR_OPAQUE ))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Test Mask. */
|
/* Test Mask. */
|
||||||
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK ))
|
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK ))
|
||||||
return -1;
|
return -1;
|
||||||
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MASK).",
|
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MASK).",
|
||||||
&img_blendMask ))
|
&img_blendMask, ALLOWABLE_ERROR_OPAQUE ))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Test Blend. */
|
/* Test Blend. */
|
||||||
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ))
|
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ))
|
||||||
return -1;
|
return -1;
|
||||||
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).",
|
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).",
|
||||||
&img_blendBlend ))
|
&img_blendBlend, ALLOWABLE_ERROR_BLENDED ))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Test Add. */
|
/* Test Add. */
|
||||||
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD ))
|
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD ))
|
||||||
return -1;
|
return -1;
|
||||||
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).",
|
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).",
|
||||||
&img_blendAdd ))
|
&img_blendAdd, ALLOWABLE_ERROR_BLENDED ))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Test Mod. */
|
/* Test Mod. */
|
||||||
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD ))
|
if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD ))
|
||||||
return -1;
|
return -1;
|
||||||
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
|
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
|
||||||
&img_blendMod ))
|
&img_blendMod, ALLOWABLE_ERROR_BLENDED ))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Clear surface. */
|
/* Clear surface. */
|
||||||
|
@ -898,7 +898,7 @@ static int render_testBlitBlend (void)
|
||||||
|
|
||||||
/* Check to see if matches. */
|
/* Check to see if matches. */
|
||||||
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).",
|
if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).",
|
||||||
&img_blendAll ))
|
&img_blendAll, ALLOWABLE_ERROR_BLENDED ))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -69,7 +69,7 @@ static void surface_testLoad( SDL_Surface *testsur )
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* See if it's the same. */
|
||||||
if (SDL_ATassert( "Primitives output not the same.",
|
if (SDL_ATassert( "Primitives output not the same.",
|
||||||
surface_compare( rface, &img_face)==0 ))
|
surface_compare( rface, &img_face, 0 )==0 ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Clean up. */
|
/* Clean up. */
|
||||||
|
@ -159,7 +159,7 @@ static void surface_testPrimitives( SDL_Surface *testsur )
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* See if it's the same. */
|
||||||
if (SDL_ATassert( "Primitives output not the same.",
|
if (SDL_ATassert( "Primitives output not the same.",
|
||||||
surface_compare( testsur, &img_primitives )==0 ))
|
surface_compare( testsur, &img_primitives, 0 )==0 ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDL_ATend();
|
SDL_ATend();
|
||||||
|
@ -241,7 +241,7 @@ static void surface_testPrimitivesBlend( SDL_Surface *testsur )
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* See if it's the same. */
|
||||||
if (SDL_ATassert( "Primitives output not the same.",
|
if (SDL_ATassert( "Primitives output not the same.",
|
||||||
surface_compare( testsur, &img_blend )==0 ))
|
surface_compare( testsur, &img_blend, 0 )==0 ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDL_ATend();
|
SDL_ATend();
|
||||||
|
@ -304,7 +304,7 @@ static void surface_testBlit( SDL_Surface *testsur )
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* See if it's the same. */
|
||||||
if (SDL_ATassert( "Blitting output not the same (normal blit).",
|
if (SDL_ATassert( "Blitting output not the same (normal blit).",
|
||||||
surface_compare( testsur, &img_blit )==0 ))
|
surface_compare( testsur, &img_blit, 0 )==0 ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Clear surface. */
|
/* Clear surface. */
|
||||||
|
@ -332,7 +332,7 @@ static void surface_testBlit( SDL_Surface *testsur )
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* See if it's the same. */
|
||||||
if (SDL_ATassert( "Blitting output not the same (using SDL_SetSurfaceColorMod).",
|
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;
|
return;
|
||||||
|
|
||||||
/* Clear surface. */
|
/* Clear surface. */
|
||||||
|
@ -365,7 +365,7 @@ static void surface_testBlit( SDL_Surface *testsur )
|
||||||
|
|
||||||
/* See if it's the same. */
|
/* See if it's the same. */
|
||||||
if (SDL_ATassert( "Blitting output not the same (using SDL_SetSurfaceAlphaMod).",
|
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;
|
return;
|
||||||
|
|
||||||
/* Clean up. */
|
/* Clean up. */
|
||||||
|
@ -473,35 +473,35 @@ static void surface_testBlitBlend( SDL_Surface *testsur )
|
||||||
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE ))
|
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE ))
|
||||||
return;
|
return;
|
||||||
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_NONE).",
|
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;
|
return;
|
||||||
|
|
||||||
/* Test Mask. */
|
/* Test Mask. */
|
||||||
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MASK ))
|
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MASK ))
|
||||||
return;
|
return;
|
||||||
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MASK).",
|
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;
|
return;
|
||||||
|
|
||||||
/* Test Blend. */
|
/* Test Blend. */
|
||||||
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND ))
|
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND ))
|
||||||
return;
|
return;
|
||||||
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_BLEND).",
|
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;
|
return;
|
||||||
|
|
||||||
/* Test Add. */
|
/* Test Add. */
|
||||||
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD ))
|
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD ))
|
||||||
return;
|
return;
|
||||||
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_ADD).",
|
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;
|
return;
|
||||||
|
|
||||||
/* Test Mod. */
|
/* Test Mod. */
|
||||||
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD ))
|
if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD ))
|
||||||
return;
|
return;
|
||||||
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MOD).",
|
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;
|
return;
|
||||||
|
|
||||||
/* Clear surface. */
|
/* Clear surface. */
|
||||||
|
@ -545,7 +545,7 @@ static void surface_testBlitBlend( SDL_Surface *testsur )
|
||||||
|
|
||||||
/* Check to see if matches. */
|
/* Check to see if matches. */
|
||||||
if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLEND_*).",
|
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;
|
return;
|
||||||
|
|
||||||
/* Clean up. */
|
/* Clean up. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue