changeset 3456:6b182cbe38ac

Allow some variation in the pixel values to account for blending accuracy differences.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 19 Nov 2009 05:06:01 +0000
parents 5a7b5760c875
children 06e948183b59
files test/automated/common/common.c
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/test/automated/common/common.c	Thu Nov 19 04:59:19 2009 +0000
+++ b/test/automated/common/common.c	Thu Nov 19 05:06:01 2009 +0000
@@ -47,22 +47,24 @@
 
             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;
                   }
                }