Bug 156539 - Fontwork with transparency won't be visible in presentation mode with Skia Raster
Summary: Fontwork with transparency won't be visible in presentation mode with Skia Ra...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
24.2.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Patrick (volunteer)
URL:
Whiteboard: target:24.2.0 target:7.6.3 target:7.5.8
Keywords:
Depends on:
Blocks: Slide-Show FontWork-WordArt
  Show dependency treegraph
 
Reported: 2023-07-30 18:59 UTC by Telesto
Modified: 2023-10-02 07:37 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample (13.82 KB, application/vnd.oasis.opendocument.presentation)
2023-07-30 19:07 UTC, Telesto
Details
Sidebar showing 50% transparency set for fontwork (529.15 KB, image/png)
2023-07-30 19:23 UTC, Patrick (volunteer)
Details
Stacktrace where the fontwork gradient fails to draw (28.53 KB, text/plain)
2023-08-05 23:22 UTC, Patrick (volunteer)
Details
Debug patch that reproduces bug with Skia/Metal on macOS (1.32 KB, patch)
2023-08-21 12:52 UTC, Patrick (volunteer)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2023-07-30 18:59:16 UTC
Description:
Fontwork with transparency won't be visible in presentation mode with Skia Raster. Didn't test Vulkan

Steps to Reproduce:
1. Open the attached file
2. Press F5

Actual Results:
No fontwork in presentation mode

Expected Results:
Should be visible


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: e26aeb882dd236adf19679d5df9b7ba5da1ed226
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: default; VCL: win
Locale: nl-NL (nl_NL); UI: en-US
Calc: CL threaded
Comment 1 Telesto 2023-07-30 19:07:42 UTC
Created attachment 188661 [details]
Sample
Comment 2 Telesto 2023-07-30 19:10:49 UTC
There actually two issues
1) Gradient fill doesn't render in presentation mode
2) With transparency set to the fontwork -> No fontwork in presentation mode
Comment 3 Patrick (volunteer) 2023-07-30 19:23:17 UTC
Created attachment 188663 [details]
Sidebar showing 50% transparency set for fontwork
Comment 4 Patrick (volunteer) 2023-07-30 19:27:58 UTC
(In reply to Telesto from comment #2)
> There actually two issues
> 1) Gradient fill doesn't render in presentation mode
> 2) With transparency set to the fontwork -> No fontwork in presentation mode

I can reproduce the first case with Skia/Metal, Skia/Raster, and Skia disabled.

I can also reproduce the second case with Skia/Raster. However, when I set the fontwork transparency to 50% (see screen snapshot in https://bugs.documentfoundation.org/attachment.cgi?id=188663), the gradient properly renders in a slideshow with Skia/Metal and Skia disabled.
Comment 5 Patrick (volunteer) 2023-07-31 17:05:09 UTC
(In reply to Patrick Luby from comment #4)
> (In reply to Telesto from comment #2)
> > There actually two issues
> > 1) Gradient fill doesn't render in presentation mode
> > 2) With transparency set to the fontwork -> No fontwork in presentation mode
> 
> I can reproduce the first case with Skia/Metal, Skia/Raster, and Skia
> disabled.
> 
> I can also reproduce the second case with Skia/Raster. However, when I set
> the fontwork transparency to 50% (see screen snapshot in
> https://bugs.documentfoundation.org/attachment.cgi?id=188663), the gradient
> properly renders in a slideshow with Skia/Metal and Skia disabled.

For comparison, here is the data for the latest Libreoffice 7.6 beta build:

I can reproduce the first case with Skia/Metal, Skia/Raster, and Skia disabled so same as master.

I cannot reproduce the second case regardless of Skia setting.

Conclusion: the first case is not a new bug and the second case is probably a side-effect of the following patch:

https://gerrit.libreoffice.org/c/core/+/114168

So, any fix for the first case should only be needed in the master branch and any fix for the second should be backported to at least libreoffice-7-6.
Comment 6 Patrick (volunteer) 2023-08-02 16:24:00 UTC
Unassigning myself. I couldn't find the drawing paths that these occur in, but I haven't had much time.
Comment 7 Patrick (volunteer) 2023-08-05 23:22:31 UTC
Created attachment 188796 [details]
Stacktrace where the fontwork gradient fails to draw
Comment 8 Patrick (volunteer) 2023-08-05 23:29:15 UTC
(In reply to Patrick Luby from comment #7)
> Created attachment 188796 [details]
> Stacktrace where the fontwork gradient fails to draw

Found the stacktrace where the fontwork is drawn during a slideshow.

Also, after grabbing the stacktrace, I did some debugging and drew the gradient itself. Instead of horizontal lines of varying shades of gray, the entire gradient rectangle is a dark gray outside of the text so the alpha mask is not right somewhere.
Comment 9 Telesto 2023-08-06 07:41:16 UTC
The gradient fill issue mentioned at comment 2 is likely bug 147645
Comment 10 Patrick (volunteer) 2023-08-15 18:38:35 UTC
(In reply to Telesto from comment #9)
> The gradient fill issue mentioned at comment 2 is likely bug 147645

I also noticed that after the fixes for bug 144073, gradient fill is also missing.

I believe that part of this bug and the missing gradient fill in bug 144073 are caused by code surrounding the code in the following commit:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=adc2ac31fb2763077e48658756946a39d91c8e12
Comment 11 Patrick (volunteer) 2023-08-16 12:22:44 UTC
(In reply to Patrick Luby from comment #10)
> I believe that part of this bug and the missing gradient fill in bug 144073
> are caused by code surrounding the code in the following commit:
> 
> https://cgit.freedesktop.org/libreoffice/core/commit/
> ?id=adc2ac31fb2763077e48658756946a39d91c8e12

I have committed a fix for https://bugs.documentfoundation.org/show_bug.cgi?id=147645 that should be available in tomorrow's (17 August 2023) nightly master build.

The fix for that bug fixes the gradient drawing in this bug and the bug is fixed, at least on macOS, with Skia/Metal.

However, there is one remaining bug that still needs to be fixed: the background text shapes fail to draw, at least on macOS, with Skia/Raster and Skia disabled.
Comment 12 Patrick (volunteer) 2023-08-16 13:13:34 UTC
(In reply to Patrick Luby from comment #11)
> The fix for that bug fixes the gradient drawing in this bug and the bug is
> fixed, at least on macOS, with Skia/Metal.
> 
> However, there is one remaining bug that still needs to be fixed: the
> background text shapes fail to draw, at least on macOS, with Skia/Raster and
> Skia disabled.

Just to clarify: "case 1" in https://bugs.documentfoundation.org/show_bug.cgi?id=156539#c2 is fixed, but I still need to fix "case 2" as well as the background text shapes failing to draw still need to be fixed.
Comment 13 Patrick (volunteer) 2023-08-20 18:16:34 UTC
(In reply to Patrick Luby from comment #12)
> Just to clarify: "case 1" in
> https://bugs.documentfoundation.org/show_bug.cgi?id=156539#c2 is fixed, but
> I still need to fix "case 2" as well as the background text shapes failing
> to draw still need to be fixed.

After some debugging, I have a theory as to why rendering is failing with Skia/Raster: two polygons are failing to draw in the following code in source/gdi/metaact.cxx:563:

void MetaPolyPolygonAction::Execute( OutputDevice* pOut )
{   
    pOut->DrawPolyPolygon( maPolyPoly );
}

Replacing the above call with pOut->DrawRect( maPolyPoly.GetBoundRect() ); changes the rendering noticeably with Skia/Metal and Skia disabled, but nothing is drawn with Skia/Raster.

So, my first guess is that some Skia call is silently failing with Skia/Raster. But what seems strange to me is that bug only appears when running a slideshow.

I'll post again when I have some more news.
Comment 14 Patrick (volunteer) 2023-08-21 12:52:54 UTC
Created attachment 189069 [details]
Debug patch that reproduces bug with Skia/Metal on macOS
Comment 15 Patrick (volunteer) 2023-08-21 13:06:30 UTC
(In reply to Patrick Luby from comment #13)
> (In reply to Patrick Luby from comment #12)
> So, my first guess is that some Skia call is silently failing with
> Skia/Raster. But what seems strange to me is that bug only appears when
> running a slideshow.

I finally found the one Skia call that is failing. By applying the following debug patch, I can reproduce all cases of this bug with Skia/Metal on macOS:

https://bugs.documentfoundation.org/attachment.cgi?id=189069

Conclusion: with Skia/Raster, drawing a polypolygon to a Skia surface does nothing. Even setting the paint color to red, disabling clipping, and just drawing a rectangle fails on Skia/Raster so my current theory is that there is a bug somewhere in the Skia code.

Looks like more debugging is needed.
Comment 16 Commit Notification 2023-09-24 00:25:28 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "master":

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

tdf#156539 Draw the gradient with polypolygonal clip when using Skia

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 17 Commit Notification 2023-09-24 01:19:35 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

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

tdf#156539 Draw the gradient with polypolygonal clip when using Skia

It will be available in 7.6.3.

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 18 Patrick (volunteer) 2023-09-24 13:19:53 UTC
I finally found the code that is failing to draw. It appears to me that, at least in this particular case, XOR drawing does not work when using Skia/Raster but works fine with Skia/Metal. So, I fixed this bug by using a different set of steps to draw a gradient clipped within a polypolygon when either Skia setting is enabled:

https://gerrit.libreoffice.org/c/core/+/157199

The fix should be in tomorrow's (25 September 2023) nightly master build. Just to be safe, can anyone also test with both Skia settings on Windows and Linux?
Comment 19 Noel Grandin 2023-09-26 10:12:42 UTC
> 
> The fix should be in tomorrow's (25 September 2023) nightly master build.
> Just to be safe, can anyone also test with both Skia settings on Windows and
> Linux?

On Windows I can confirm this works with both Vulkan and Raster.
Comment 20 Commit Notification 2023-10-02 07:37:11 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

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

tdf#156539 Draw the gradient with polypolygonal clip when using Skia

It will be available in 7.5.8.

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.