Merge lp:~osomon/unity-2d/bigendian into lp:unity-2d/3.0

Proposed by Olivier Tilloy
Status: Merged
Approved by: Ugo Riboni
Approved revision: 561
Merged at revision: 562
Proposed branch: lp:~osomon/unity-2d/bigendian
Merge into: lp:unity-2d/3.0
Diff against target: 30 lines (+19/-0)
1 file modified
launcher/UnityApplications/iconimageprovider.cpp (+19/-0)
To merge this branch: bzr merge lp:~osomon/unity-2d/bigendian
Reviewer Review Type Date Requested Status
Ugo Riboni (community) Approve
Florian Boucault Pending
Review via email: mp+60264@code.launchpad.net

Commit message

Fix the byte order of images on Big Endian architectures (like PowerPC).
Original algorithm by Paul J. Wells, reworked for efficiency.

Description of the change

See the discussion in bug #758782 for details.

The original solution was proposed by Paul J. Wells, I merely re-wrote it to be more efficient. This branch was tested by Paul who confirmed it fixes the issue on his G5.

Ideally it should be tested on another big endian piece of hardware to double-confirm it fixes the issue, and of course it should be checked against regressions on little endian platforms (i386, amd64, …).

To post a comment you must log in.
Revision history for this message
Ugo Riboni (uriboni) wrote :

I double checked that it doesn't cause any regression on amd64 but can't test on any ppc machine.
Let's merge it so that it will get more widespread testing, including on ppc.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/UnityApplications/iconimageprovider.cpp'
2--- launcher/UnityApplications/iconimageprovider.cpp 2011-04-28 13:09:25 +0000
3+++ launcher/UnityApplications/iconimageprovider.cpp 2011-05-07 08:35:57 +0000
4@@ -139,7 +139,26 @@
5 gdk_pixbuf_get_height(pixbuf),
6 gdk_pixbuf_get_rowstride(pixbuf),
7 QImage::Format_ARGB32);
8+
9+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
10+ /* ABGR → ARGB */
11 QImage swappedImage = image.rgbSwapped();
12+#else
13+ /* ABGR → BGRA */
14+ /* Reference: https://bugs.launchpad.net/unity-2d/+bug/758782 */
15+ QImage swappedImage(image.size(), image.format());
16+ for (int i = 0; i < swappedImage.height(); ++i) {
17+ QRgb* p = (QRgb*) image.constScanLine(i);
18+ QRgb* q = (QRgb*) swappedImage.scanLine(i);
19+ QRgb* end = p + image.width();
20+ while (p < end) {
21+ *q = qRgba(qAlpha(*p), qRed(*p), qGreen(*p), qBlue(*p));
22+ p++;
23+ q++;
24+ }
25+ }
26+#endif
27+
28 g_object_unref(pixbuf);
29
30 if (size) {

Subscribers

People subscribed via source and target branches