Bug 149673 - SVG group opacity is additive
Summary: SVG group opacity is additive
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
7.5.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Xisco Faulí
URL:
Whiteboard: target:24.2.0 target:7.6.0.2
Keywords: filter:svg
Depends on:
Blocks: SVG-Import
  Show dependency treegraph
 
Reported: 2022-06-22 11:38 UTC by Paris Oplopoios
Modified: 2023-07-10 17:52 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
example 1 (440 bytes, image/svg+xml)
2022-06-22 11:38 UTC, Paris Oplopoios
Details
comparison 1, LO left, Chrome right (6.67 KB, image/png)
2022-06-22 11:39 UTC, Paris Oplopoios
Details
example 2 (472 bytes, image/svg+xml)
2022-06-22 11:39 UTC, Paris Oplopoios
Details
comparison 2, LO left, Chrome right (10.97 KB, image/png)
2022-06-22 11:39 UTC, Paris Oplopoios
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paris Oplopoios 2022-06-22 11:38:09 UTC
Description:
When you have a group of elements like so:

<g id="g1" opacity=".5">
    <circle id="circle1" cx="100" cy="60" fill="#f00" r="40"/>
    <circle id="circle2" cx="70" cy="100" fill="#0f0" r="40"/>
    <circle id="circle3" cx="130" cy="100" fill="#00f" r="40"/>
</g>

the group opacity seems to be applied after all the other attributes in other SVG implementations

This means that, when group elements overlap:
    - the colors are not mixed
    - the opacities are not mixed

Optimally we'd render the entire group in the correct order, and then apply the opacity.

I've attached two examples with two comparisons to demonstrate, left is LO, right is Chrome

Steps to Reproduce:
1. Open attached SVG

Actual Results:
-

Expected Results:
-


Reproducible: Always


User Profile Reset: No



Additional Info:
-
Comment 1 Paris Oplopoios 2022-06-22 11:38:46 UTC
Created attachment 180898 [details]
example 1
Comment 2 Paris Oplopoios 2022-06-22 11:39:18 UTC
Created attachment 180899 [details]
comparison 1, LO left, Chrome right
Comment 3 Paris Oplopoios 2022-06-22 11:39:36 UTC
Created attachment 180900 [details]
example 2
Comment 4 Paris Oplopoios 2022-06-22 11:39:56 UTC
Created attachment 180901 [details]
comparison 2, LO left, Chrome right
Comment 5 Roman Kuznetsov 2022-06-23 20:10:13 UTC
confirm in

Version: 7.5.0.0.alpha0+ / LibreOffice Community
Build ID: ab12274ffda3a1a5a1ff33203acf9de665d4a636
CPU threads: 4; OS: Mac OS X 12.4; UI render: default; VCL: osx
Locale: ru-RU (ru_RU.UTF-8); UI: en-US
Calc: threaded
Comment 6 Xisco Faulí 2023-06-26 19:35:47 UTC
The problem is that the code first apply the opacity to each circle and then it groups them, it should be the other way around.
The current behaviour is when code looks like 

    <g id="g1">
        <circle id="circle1" cx="100" cy="60" fill="#f00" r="40" opacity="0.5"/>
        <circle id="circle2" cx="70" cy="100" fill="#0f0" r="40" opacity="0.5"/>
        <circle id="circle3" cx="130" cy="100" fill="#00f" r="40" opacity="0.5"/>
    </g>
Comment 7 Commit Notification 2023-07-10 14:54:16 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/56039daae4a436d7ea1b093a02cf0e8ad3bda4a9

tdf#149673: only check opacity from parent...

It will be available in 24.2.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 8 Commit Notification 2023-07-10 17:52:38 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

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

tdf#149673: only check opacity from parent...

It will be available in 7.6.0.2.

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.