From 1dac100531fd623ce8143f6ef1d39527e6c95728 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Fri, 2 Mar 2007 19:39:26 +0000 Subject: [PATCH] blind fix for endianness, needs testing by someone on a big-endian machine --- src/display/canvas-arena.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 95e3757d4..de43ec80d 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -293,6 +293,28 @@ streamline rendering. if (pb.empty == FALSE) { + if (arena->arena->rendermode == RENDERMODE_OUTLINE) { + // currently we only use cairo in outline mode + + // ENDIANNESS FIX + // Inkscape and GTK use fixed byte order in their buffers: r, g, b, a. + // Cairo reads/writes buffer values as in32s and therefore depends on the hardware byte order + // (little-endian vs big-endian). + // Until we move ALL of inkscape rendering and screen display to cairo, + // we must reverse the order for big-endian architectures (e.g. PowerPC). + if (G_BYTE_ORDER == G_BIG_ENDIAN) { + unsigned char *start = NR_PIXBLOCK_PX(&pb); + unsigned char *end = start + pb.rs * (pb.area.y1 - pb.area.y0); + for (unsigned char *i = start; i < end; i += 4) { + unsigned char tmp0 = i[0]; + unsigned char tmp1 = i[1]; + i[0] = i[3]; + i[1] = i[2]; + i[2] = tmp1; + i[3] = tmp0; + } + } + } // this does the 32->24 squishing, using an assembler routine: nr_blit_pixblock_pixblock (&cb, &pb); -- 2.30.2