util: fix pwetty on big-endian
authorGeert Uytterhoeven <geert@linux-m68k.org>
Thu, 7 Jul 2022 13:33:04 +0000 (15:33 +0200)
committerDmitry Baryshkov <dbaryshkov@gmail.com>
Tue, 31 Oct 2023 13:24:32 +0000 (13:24 +0000)
commit32a03fb32c649a665d0ff7162cf13c770d4662ee
treea2a98160d7e0471c89beebb7fb881d3825d4096e
parent6f00a73485ba8cce6035b4c6e8995dc078afa05c
util: fix pwetty on big-endian

Cairo always uses native byte order for rendering.

Hence if the byte order of the frame buffer differs from the byte order
of the CPU, the frame buffer contents need to be byteswapped twice: once
before rendering, to convert to native byte order, and a second time
after rendering, to restore the frame buffer format's byte order.

Note that byte swapping is not done for ARGB32 formats, as for these
formats, byte order only affects the order of the red, green, and blue
channels, which we do not care about here.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
  - Add Reviewed-by,

v4:
  - No changes,

v3:
  - Wrap byteswap_buffer{16,32}() implementation inside #if HAVE_CAIRO
    to avoid defined-but-not-used compiler warnings,

v2:
  - RGB30 is untested.
tests/util/pattern.c