229cbf
# HG changeset patch
229cbf
# Parent  3de59fe1b8708c01e134ce698c4232b8a854f617
7a48c4
Problem:  webGL sites are displayed in the wrong color (usually blue-ish)
7a48c4
Solution: Problem is with skia once again. Output of webgl seems endian-correct, but skia only
7a48c4
          knows how to deal with little endian.
7a48c4
          So we swizzle the output of webgl after reading it from readpixels()
7a48c4
Note:     This does not fix all webGL sites, but is a step in the right direction
229cbf
229cbf
diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h
229cbf
--- a/gfx/gl/GLContext.h
229cbf
+++ b/gfx/gl/GLContext.h
229cbf
@@ -1548,16 +1548,23 @@ class GLContext : public GenericAtomicRe
229cbf
     AFTER_GL_CALL;
229cbf
   }
229cbf
 
229cbf
   void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
229cbf
                        GLenum format, GLenum type, GLvoid* pixels) {
7a48c4
     BEFORE_GL_CALL;
7a48c4
     mSymbols.fReadPixels(x, y, width, height, format, type, pixels);
7a48c4
     OnSyncCall();
229cbf
+#if MOZ_BIG_ENDIAN()
7a48c4
+    uint8_t* itr = (uint8_t*)pixels;
7a48c4
+    for (GLsizei i = 0; i < width * height; i++) {
7a48c4
+      NativeEndian::swapToLittleEndianInPlace((uint32_t*)itr, 1);
7a48c4
+      itr += 4;
7a48c4
+    }
7a48c4
+#endif
7a48c4
     AFTER_GL_CALL;
7a48c4
     mHeavyGLCallsSinceLastFlush = true;
7a48c4
   }
229cbf
 
229cbf
   void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
229cbf
                    GLenum format, GLenum type, GLvoid* pixels);
229cbf
 
229cbf
  public: