test/automated/common/common.c
changeset 3477 2c07bb579922
parent 3476 ab99313951cd
child 3481 c32c53fca10d
equal deleted inserted replaced
3476:ab99313951cd 3477:2c07bb579922
    14 
    14 
    15 
    15 
    16 /**
    16 /**
    17  * @brief Compares a surface and a surface image for equality.
    17  * @brief Compares a surface and a surface image for equality.
    18  */
    18  */
    19 int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img )
    19 int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img, int allowable_error )
    20 {
    20 {
    21    int ret;
    21    int ret;
    22    int i,j;
    22    int i,j;
    23    int bpp;
    23    int bpp;
    24    Uint8 *p, *pd;
    24    Uint8 *p, *pd;
    60                      dist += (R-pd[0])*(R-pd[0]);
    60                      dist += (R-pd[0])*(R-pd[0]);
    61                      dist += (G-pd[1])*(G-pd[1]);
    61                      dist += (G-pd[1])*(G-pd[1]);
    62                      dist += (B-pd[2])*(B-pd[2]);
    62                      dist += (B-pd[2])*(B-pd[2]);
    63                      dist += (A-pd[3])*(A-pd[3]);
    63                      dist += (A-pd[3])*(A-pd[3]);
    64                   }
    64                   }
    65                   /* Allow up to sqrt(32) difference in blending accuracy */
    65                   /* Allow some difference in blending accuracy */
    66                   if (dist > 64) {
    66                   if (dist > allowable_error) {
    67                      /*printf("pixel %d,%d varies by %d\n", i, j, dist);*/
    67                      /*printf("pixel %d,%d varies by %d\n", i, j, dist);*/
    68                      ++ret;
    68                      ++ret;
    69                   }
    69                   }
    70                }
    70                }
    71                break;
    71                break;