diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2012-07-06 18:34:22 -0700 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2012-07-15 21:16:35 -0700 |
commit | edbb8a48c57226aaac9e33ab3837ff3ba3fabd44 (patch) | |
tree | b07a3ded9c82b33e66a31f680dc26bca2225f8e7 /tests/util | |
parent | 636a5c41f5e72d90af66c790824e2f0552eaea62 (diff) |
util: Define piglit_probe_rect_halves_equal_rgba() for all GL API's
Move the function from piglit-util-gl.c to piglit-util-gl-common.c so that
all GL API's can use it.
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Diffstat (limited to 'tests/util')
-rw-r--r-- | tests/util/piglit-util-gl-common.c | 39 | ||||
-rw-r--r-- | tests/util/piglit-util-gl.c | 38 |
2 files changed, 39 insertions, 38 deletions
diff --git a/tests/util/piglit-util-gl-common.c b/tests/util/piglit-util-gl-common.c index 661fae032..f3e79366b 100644 --- a/tests/util/piglit-util-gl-common.c +++ b/tests/util/piglit-util-gl-common.c @@ -322,3 +322,42 @@ piglit_half_from_float(float val) result = (s << 15) | (e << 10) | m; return result; } + +int +piglit_probe_rect_halves_equal_rgba(int x, int y, int w, int h) +{ + int i, j, p; + GLfloat probe1[4]; + GLfloat probe2[4]; + GLubyte *pixels = malloc(w*h*4*sizeof(GLubyte)); + + glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + + for (j = 0; j < h; j++) { + for (i = 0; i < w / 2; i++) { + GLubyte *pixel1 = &pixels[4 * (j * w + i)]; + GLubyte *pixel2 = &pixels[4 * (j * w + w / 2 + i)]; + + for (p = 0; p < 4; ++p) { + probe1[p] = pixel1[p] / 255.0f; + probe2[p] = pixel2[p] / 255.0f; + } + + for (p = 0; p < 4; ++p) { + if (fabs(probe1[p] - probe2[p]) >= piglit_tolerance[p]) { + printf("Probe at (%i,%i)\n", x+i, x+j); + printf(" Left: %f %f %f %f\n", + probe1[0], probe1[1], probe1[2], probe1[3]); + printf(" Right: %f %f %f %f\n", + probe2[0], probe2[1], probe2[2], probe2[3]); + + free(pixels); + return 0; + } + } + } + } + + free(pixels); + return 1; +} diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c index 13a98fd2c..e91dfc245 100644 --- a/tests/util/piglit-util-gl.c +++ b/tests/util/piglit-util-gl.c @@ -651,44 +651,6 @@ int piglit_probe_texel_rgb(int target, int level, int x, int y, return piglit_probe_texel_rect_rgb(target, level, x, y, 1, 1, expected); } -int piglit_probe_rect_halves_equal_rgba(int x, int y, int w, int h) -{ - int i, j, p; - GLfloat probe1[4]; - GLfloat probe2[4]; - GLubyte *pixels = malloc(w*h*4*sizeof(GLubyte)); - - glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - - for (j = 0; j < h; j++) { - for (i = 0; i < w / 2; i++) { - GLubyte *pixel1 = &pixels[4 * (j * w + i)]; - GLubyte *pixel2 = &pixels[4 * (j * w + w / 2 + i)]; - - for (p = 0; p < 4; ++p) { - probe1[p] = pixel1[p] / 255.0f; - probe2[p] = pixel2[p] / 255.0f; - } - - for (p = 0; p < 4; ++p) { - if (fabs(probe1[p] - probe2[p]) >= piglit_tolerance[p]) { - printf("Probe at (%i,%i)\n", x+i, x+j); - printf(" Left: %f %f %f %f\n", - probe1[0], probe1[1], probe1[2], probe1[3]); - printf(" Right: %f %f %f %f\n", - probe2[0], probe2[1], probe2[2], probe2[3]); - - free(pixels); - return 0; - } - } - } - } - - free(pixels); - return 1; -} - int piglit_use_fragment_program(void) { static const char source[] = |