Commit 2656238a authored by Robert Bragg's avatar Robert Bragg Committed by Matt Turner

egl-util: Adds probe_front_pixel_rgb function

This adds an egl_probe_front_pixel_rgb function that is analogous to
piglit_probe_pixel_rgba except it probes the front buffer instead of
probing the back buffer.
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
parent 5e0fde7f
......@@ -37,6 +37,37 @@ static int automatic;
int depth;
int
egl_probe_front_pixel_rgb(struct egl_state *state,
int x, int y, const float *expected)
{
XImage *ximage = XGetImage(state->dpy, state->win,
x, state->height - y - 1, 1, 1, AllPlanes, ZPixmap);
unsigned long pixel = XGetPixel(ximage, 0, 0);
uint8_t *probe = (uint8_t *)&pixel;
int pass = 1;
int i;
XDestroyImage(ximage);
/* NB: XGetPixel returns a normalized BGRA, byte per
* component, pixel format */
for(i = 0; i < 3; ++i) {
if (fabs(probe[2 - i]/255.0 - expected[i]) > piglit_tolerance[i]) {
pass = 0;
}
}
if (pass)
return 1;
printf("Front Buffer Probe at (%i,%i)\n", x, y);
printf(" Expected: %f %f %f %f\n", expected[0], expected[1], expected[2], expected[3]);
printf(" Observed: %f %f %f %f\n", probe[0]/255.0, probe[1]/255.0, probe[2]/255.0, probe[3]/255.0);
return 0;
}
void
egl_init_test(struct egl_test *test)
{
......
......@@ -62,4 +62,8 @@ egl_util_create_pixmap(struct egl_state *state,
int egl_util_run(const struct egl_test *test, int argc, char *argv[]);
int
egl_probe_front_pixel_rgb(struct egl_state *state,
int x, int y, const float *expected);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment