summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2020-06-12 18:46:33 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2020-06-12 18:47:26 +0200
commit3b009178a941ce29f911ceef013c3a20f598377b (patch)
treeeff785e4467c1a07bf2fcfacfd7608569c80244c
parent3a991695b5520ee90f349bddb6070bd4ea18c5c1 (diff)
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.
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 593f16954a..8b9ef94d1b 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -1905,6 +1905,18 @@ eng_gl_surface_read_pixels(void *engine EINA_UNUSED, void *surface,
1905 { 1905 {
1906 glReadPixels(x, y, w, h, GL_BGRA, GL_UNSIGNED_BYTE, pixels); 1906 glReadPixels(x, y, w, h, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
1907 done = (glGetError() == GL_NO_ERROR); 1907 done = (glGetError() == GL_NO_ERROR);
1908#ifdef WORDS_BIGENDIAN
1909 if (done)
1910 {
1911 DATA32 *ptr = pixels;
1912 int k;
1913 for (k = w * h; k; --k)
1914 {
1915 const DATA32 v = *ptr;
1916 *ptr++ = eina_swap32(v);
1917 }
1918 }
1919#endif
1908 } 1920 }
1909 1921
1910 if (!done) 1922 if (!done)
@@ -1916,9 +1928,13 @@ eng_gl_surface_read_pixels(void *engine EINA_UNUSED, void *surface,
1916 for (k = w * h; k; --k) 1928 for (k = w * h; k; --k)
1917 { 1929 {
1918 const DATA32 v = *ptr; 1930 const DATA32 v = *ptr;
1931#ifdef WORDS_BIGENDIAN
1932 *ptr++ = (v << 24) | (v >> 8);
1933#else
1919 *ptr++ = (v & 0xFF00FF00) 1934 *ptr++ = (v & 0xFF00FF00)
1920 | ((v & 0x00FF0000) >> 16) 1935 | ((v & 0x00FF0000) >> 16)
1921 | ((v & 0x000000FF) << 16); 1936 | ((v & 0x000000FF) << 16);
1937#endif
1922 } 1938 }
1923 } 1939 }
1924 1940