evas/engines/gl_generic: fix byte order after glReadPixels on BE

This fixes the screenshot tool in Enlightenment on big endian
systems besides other things.
This commit is contained in:
Daniel Kolesa 2020-06-12 18:46:33 +02:00
parent 3a991695b5
commit 3b009178a9
1 changed files with 16 additions and 0 deletions

View File

@ -1905,6 +1905,18 @@ eng_gl_surface_read_pixels(void *engine EINA_UNUSED, void *surface,
{
glReadPixels(x, y, w, h, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
done = (glGetError() == GL_NO_ERROR);
#ifdef WORDS_BIGENDIAN
if (done)
{
DATA32 *ptr = pixels;
int k;
for (k = w * h; k; --k)
{
const DATA32 v = *ptr;
*ptr++ = eina_swap32(v);
}
}
#endif
}
if (!done)
@ -1916,9 +1928,13 @@ eng_gl_surface_read_pixels(void *engine EINA_UNUSED, void *surface,
for (k = w * h; k; --k)
{
const DATA32 v = *ptr;
#ifdef WORDS_BIGENDIAN
*ptr++ = (v << 24) | (v >> 8);
#else
*ptr++ = (v & 0xFF00FF00)
| ((v & 0x00FF0000) >> 16)
| ((v & 0x000000FF) << 16);
#endif
}
}