On 09/20/2012 09:59 AM, Robert Bragg wrote:
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.
---
  tests/egl/egl-util.c |   31 +++++++++++++++++++++++++++++++
  tests/egl/egl-util.h |    4 ++++
  2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/tests/egl/egl-util.c b/tests/egl/egl-util.c
index 20cd699..4f06cab 100644
--- a/tests/egl/egl-util.c
+++ b/tests/egl/egl-util.c
@@ -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)
  {
diff --git a/tests/egl/egl-util.h b/tests/egl/egl-util.h
index 87c2db3..e1caa94 100644
--- a/tests/egl/egl-util.h
+++ b/tests/egl/egl-util.h
@@ -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

For both:  Reviewed-by: Brian Paul <bri...@vmware.com>

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to