Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-141218

Swapped colors on big endian systems when using OpenGL (glx) backend

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • 6.10.0
    • GUI: OpenGL
    • None
    • Debian sid
    • Linux/X11

      On a big-endian ppc64 host with llvmpipe providing OpenGL software rendering support, all Qt applications show incorrect colors (see attached).  Note that only Qt applications are affected; all other applications tested (including mesa test applications such as glxgears and the OpenGL xscreensavers) operate normally.

      This appears to be the result of a clarification at some point to the OpenGL specification for 8888 formats [1], which now states the format is host endian agnostic.  Qt on the other hand tries to swap the channels, causing the problem.

      Changing QImage::rgbSwapped_inplace() from

      *p = ((c << 16) & 0xff000000) | ((c >> 16) & 0xff00) | (c & 0x00ff00ff);

      to

      *p = ((c << 24) & 0xff000000) | ((c >> 8) & 0x00ff0000) | ((c >> 8) & 0x0000ff00) | ((c >> 8) & 0x000000ff);

      resolves the color issue entirely.  This effectively treats the outgoing OpenGL buffer as ARGB instead of BGRA, per the updated OpenGL format specifications.

      Note this only affects OpenGL visuals; passing a standard X11 visual to the Qt application or disabling the X11 glx extension results in normal colors both with and without this patch.

      [1] https://narkive.com/OP4sVuiK.4

        1. qt_color_bug.png
          285 kB
          Timothy Pearson
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            lagocs Laszlo Agocs
            tpearson-rcs Timothy Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes