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
Keywords:
Depends on:
Blocks: CairoSDPR
  Show dependency treegraph
 
Reported: 2025-04-01 21:40 UTC by Andras Timar
Modified: 2025-04-03 00:34 UTC (History)
5 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

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