Bug 166005 - Blue and Green pixels are swapped with --enable-cairo-rgba
Summary: Blue and Green pixels are swapped with --enable-cairo-rgba
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
25.2.2.2 release
Hardware: All All
: medium normal
Assignee: Aron Budea
URL:
Whiteboard: target:25.8.0 target:25.2.5 target:25...
Keywords:
: 166965 (view as bug list)
Depends on:
Blocks: CairoSDPR
  Show dependency treegraph
 
Reported: 2025-04-01 21:40 UTC by Andras Timar
Modified: 2025-06-13 08:39 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
bugdoc (191.94 KB, application/vnd.oasis.opendocument.text)
2025-04-01 21:40 UTC, Andras Timar
Details
screenshot (190.14 KB, image/png)
2025-04-03 19:46 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andras Timar 2025-04-01 21:40:06 UTC
Created attachment 200127 [details]
bugdoc

When LibreOffice is built with --enable-cairo-rgba (--without-system-cairo is implied), then imported images have wrong colors. In fact blue component is counted as green, green component is counted as blue. As you can see in the simple bugdoc: blue and green are swapped when you open it in LibreOffice that was built with --enable-cairo-rgba.
Comment 1 Aron Budea 2025-04-02 04:02:12 UTC
What needs to be noted is that red and blue are expected to be swapped (rgba vs bgra), but the buggy case has another swap, the one noted in the description.

rgb (original) -> bgr (expected) -> brg (wrong)
Comment 2 Julien Nabet 2025-04-02 10:41:50 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.

Starting point I suppose:
https://opengrok.libreoffice.org/xref/core/include/vcl/cairo.hxx?r=5357da349b4b266b4003d25b61ecb12a515893c4#38
Comment 3 Julien Nabet 2025-04-02 11:08:28 UTC
Noel/Caolán: thought you might be interested in this one.

I naively tried to swap values of SVP_CAIRO_BLUE and SVP_CAIRO_GREEN in ENABLE_CAIRO_RGBA part of include/vcl/cairo.hxx but no success.
Comment 4 Andras Timar 2025-04-02 16:08:17 UTC
With DISABLE_SYSTEM_DEPENDENT_PRIMITIVE_RENDERER=1 the bug is not there.
Comment 5 Aron Budea 2025-04-02 16:44:32 UTC
I checked with an older build containing the early work from Caolán on this: https://gerrit.libreoffice.org/c/core/+/144632

And with "export TEST_SYSTEM_PRIMITIVE_RENDERER=1" the bug is reproducible already.
Comment 6 Commit Notification 2025-04-02 20:15:46 UTC
Aron Budea committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/69162f01d3449e92e9a8b76c8a09378e1aef8a56

tdf#166005 vcl: cairo: use correct order in RGBA case

It will be available in 25.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Caolán McNamara 2025-04-02 20:20:46 UTC
seems to be the right fix
Comment 8 Julien Nabet 2025-04-03 19:46:55 UTC
Created attachment 200156 [details]
screenshot

Here what I got with --enable-cairo-rgba + master sources updated today (5daab76058e38ae16180b1bea239161b7c8be274)

(notice too the color of the icons on the standard toolbar which are wrong).
Comment 9 Andras Timar 2025-04-03 19:53:47 UTC
(In reply to Julien Nabet from comment #8)
> Created attachment 200156 [details]
> screenshot
> 
> Here what I got with --enable-cairo-rgba + master sources updated today
> (5daab76058e38ae16180b1bea239161b7c8be274)
> 
> (notice too the color of the icons on the standard toolbar which are wrong).

That's fine, nobody wants --enable-cairo-rgba with desktop LibreOffice. It is for Android and Online. And the fix was verified there.
Comment 10 Julien Nabet 2025-04-03 19:56:43 UTC
(In reply to Andras Timar from comment #9)
> ...
> That's fine, nobody wants --enable-cairo-rgba with desktop LibreOffice. It
> is for Android and Online. And the fix was verified there.
ok then. Thank you for the very quick feedback! :-)
Comment 11 Michael Weghorn 2025-06-12 15:18:25 UTC
*** Bug 166965 has been marked as a duplicate of this bug. ***
Comment 12 Commit Notification 2025-06-12 16:41:59 UTC
Aron Budea committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

https://git.libreoffice.org/core/commit/f11e05b914dbc69d9f0d1d88445a8f68159b5b46

tdf#166005 vcl: cairo: use correct order in RGBA case

It will be available in 25.2.5.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Commit Notification 2025-06-13 08:39:56 UTC
Aron Budea committed a patch related to this issue.
It has been pushed to "libreoffice-25-2-4":

https://git.libreoffice.org/core/commit/78ef3e95a38af23ba22e0bdc3ed7b7c6f94a1789

tdf#166005 vcl: cairo: use correct order in RGBA case

It will be available in 25.2.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.