From 980c3290de95d02a10e11c009920a7cbf20f313c Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Thu, 11 Oct 2012 14:11:00 -0400 Subject: [PATCH] shell-screen-grabber.c: Fix PBO path for big-endian machines GL_BGRA/GL_UNSIGNED_BYTE only properly represents the Cairo pixel format for little-endian machines. On big endian machines we need to use GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV. That would also work for little- endian, but for minimum disruption we keep using the old version on little endian. https://bugzilla.gnome.org/show_bug.cgi?id=685915 --- src/shell-screen-grabber.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/shell-screen-grabber.c b/src/shell-screen-grabber.c index 74caa8935..c19bbddfd 100644 --- a/src/shell-screen-grabber.c +++ b/src/shell-screen-grabber.c @@ -170,7 +170,16 @@ shell_screen_grabber_grab (ShellScreenGrabber *grabber, * top-left */ glGetIntegerv (GL_VIEWPORT, vp_size); y = vp_size[3] - (y + height); + + /* the "big-endian" version actually works for both, but the litle-endian + * version has been better tested with a range of drivers, so we'll + * keep on using it on little-endian. + */ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN glReadPixels (x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, 0); +#else + glReadPixels (x, y, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0); +#endif mapped_data = pf_glMapBufferARB (GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);