Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Allow some variation in the pixel values to account for blending accu…
Browse files Browse the repository at this point in the history
…racy differences.
  • Loading branch information
slouken committed Nov 19, 2009
1 parent 1f7b78e commit cf47905
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/automated/common/common.c
Expand Up @@ -47,22 +47,24 @@ int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img )

case 4:
{
int fail;
int dist = 0;
Uint8 R, G, B, A;

SDL_GetRGBA(*(Uint32*)p, sur->format, &R, &G, &B, &A);

if (img->bytes_per_pixel == 3) {
fail = !( (R == pd[0]) &&
(G == pd[1]) &&
(B == pd[2]) );
dist += (R-pd[0])*(R-pd[0]);
dist += (G-pd[1])*(G-pd[1]);
dist += (B-pd[2])*(B-pd[2]);
} else {
fail = !( (R == pd[0]) &&
(G == pd[1]) &&
(B == pd[2]) &&
(A == pd[3]) );
dist += (R-pd[0])*(R-pd[0]);
dist += (G-pd[1])*(G-pd[1]);
dist += (B-pd[2])*(B-pd[2]);
dist += (A-pd[3])*(A-pd[3]);
}
if (fail) {
/* Allow up to sqrt(32) difference in blending accuracy */
if (dist > 32) {
/*printf("pixel %d,%d varies by %d\n", i, j, dist);*/
++ret;
}
}
Expand Down

0 comments on commit cf47905

Please sign in to comment.