From 1acf5cc36f9ca8c92ea12f3f6d0e62c8e159804b Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 3 Nov 2009 12:54:45 +0000 Subject: [PATCH] [cogl_read_pixels] don't force a 4 byte pack alignment Technically this change shouldn't make a difference since we are calling glReadPixels with GL_RGBA GL_UNSIGNED_BYTE which is a 4 byte format and it should always result in the same value according to how OpenGL calculates the location of sequential rows. i.e. k = a/s * ceil(snl/a) where: a = alignment s = component size (1) n = number of components per pixel (4) l = number of pixels in a row gives: k = 4/1 * ceil(4l/4) and k = 1/1 * ceil(4l/1) which are equivalent I'm changing it because I've seen i915 driver code that bails out of hardware accelerated paths if the alignment isn't 1, and because conceptually we have no alignment constraints here so even if the current value has no effect, when we start reading back other formats it may upset things. --- cogl/cogl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cogl/cogl.c b/cogl/cogl.c index 21e5572e8..b8b51b375 100644 --- a/cogl/cogl.c +++ b/cogl/cogl.c @@ -826,14 +826,14 @@ cogl_read_pixels (int x, /* Setup the pixel store parameters that may have been changed by Cogl */ - glPixelStorei (GL_PACK_ALIGNMENT, 4); + GE (glPixelStorei (GL_PACK_ALIGNMENT, 1)); #ifdef HAVE_COGL_GL - glPixelStorei (GL_PACK_ROW_LENGTH, 0); - glPixelStorei (GL_PACK_SKIP_PIXELS, 0); - glPixelStorei (GL_PACK_SKIP_ROWS, 0); + GE (glPixelStorei (GL_PACK_ROW_LENGTH, 0)); + GE (glPixelStorei (GL_PACK_SKIP_PIXELS, 0)); + GE (glPixelStorei (GL_PACK_SKIP_ROWS, 0)); #endif /* HAVE_COGL_GL */ - glReadPixels (x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + GE (glReadPixels (x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels)); /* NB: All offscreen rendering is done upside down so there is no need * to flip in this case... */