Bug 99102 - rendering of linejoin miter differs between edit mode and presentation mode if antialiasing is on
Summary: rendering of linejoin miter differs between edit mode and presentation mode i...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
4.2 all versions
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Shapes
  Show dependency treegraph
 
Reported: 2016-04-05 14:45 UTC by Regina Henschel
Modified: 2023-05-11 14:58 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
The default minimum angle for miter is 15°. (15.64 KB, application/vnd.sun.xml.impress)
2016-04-05 14:45 UTC, Regina Henschel
Details
screenshot of edit mode, anti-aliasing off (14.55 KB, image/png)
2016-04-05 14:46 UTC, Regina Henschel
Details
screen of edit mode, anti-aliasing on (19.43 KB, image/png)
2016-04-05 14:46 UTC, Regina Henschel
Details
screenshot of presentation mode (35.83 KB, image/png)
2016-04-05 14:47 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2016-04-05 14:45:02 UTC
Created attachment 124094 [details]
The default minimum angle for miter is 15°.

Set your LibreOffice to not use OpenGL.

1. Switch Antialiasing off. Open the attached file. Look at it in edit mode and in presentation mode.
2. Switch Antialiasing on. Again look at the file in edit mode and in presentation mode.

Expected behavior: The shapes look the same in edit mode and presentation mode.

Seen behavior: A miter limit is used in presentation mode and in edit mode without antialiasing. No miter limit is used in edit mode, if antialiasing is on.

I see the problem since Version: 4.2.5.2
Build ID: 6ff819b65674ae6c83f3cbab9e4a4c2b292a7a94

My PC cannot use OpenGL, but I would like to know the test result for the case OpenGL too. Please add your findings, if you can use OpenGL.
Comment 1 Regina Henschel 2016-04-05 14:46:15 UTC
Created attachment 124095 [details]
screenshot of edit mode, anti-aliasing off
Comment 2 Regina Henschel 2016-04-05 14:46:46 UTC
Created attachment 124096 [details]
screen of edit mode, anti-aliasing on
Comment 3 Regina Henschel 2016-04-05 14:47:16 UTC
Created attachment 124097 [details]
screenshot of presentation mode
Comment 4 Regina Henschel 2016-04-06 22:09:09 UTC
It seems, that the problem is, that anti-aliased line rendering uses directly gdi+ without own decomposition. (Windows 7 here). And gdi+ handles miter limit different from LibreOffice. And without anti-aliasing the own decomposition is used, which switches from line join 'miter' to 'bevel', if the angle is too small. 

In addition, there is a real bug in bool WinSalGraphicsImpl::drawPolyLine  (line#2018).
   const Gdiplus::REAL aMiterLimit(15.0); 
   aPen.SetMiterLimit(aMiterLimit);
uses the default 15° MiterMinimum_Angle_, but gdi+ expects a MiterLimit, which is the ratio of MiterLength to stroke-width. Correcting that error, I get nearly the same cuts of the tips as rendered in PowerPoint.
Comment 5 Tomaz Vajngerl 2016-04-07 02:40:31 UTC
OpenGL rendering of polylines currently doesn't support miter limit (it doesn't fallback to bevel at a certain angle) which is bad. When I'll implement this then I'll make sure the document is rendered correctly.
Comment 6 Regina Henschel 2016-04-08 08:03:08 UTC
One error is in case basegfx::B2DLineJoin::Miter in WinSalGraphicsImpl::drawPolyLine, in /core/vcl/win/gdi/gdiimpl.cxx

Currently it is
             case basegfx::B2DLineJoin::Miter :
             {
                 const Gdiplus::REAL aMiterLimit(15.0); 
                 aPen.SetMiterLimit(aMiterLimit);
                 aPen.SetLineJoin(Gdiplus::LineJoinMiter);
                 break;
             }

But the type "Gdiplus::LineJoinMiter" acts different than LO. The correct type is "Gdiplus::LineJoinMiterClipped" see https://msdn.microsoft.com/en-us/library/windows/desktop/ms534148%28v=vs.85%29.aspx

Therefore it should be in content
            case basegfx::B2DLineJoin::Miter :
            {
                const Gdiplus::REAL aMiterLimit(1/sin(7.5*F_PI180));
                aPen.SetMiterLimit(aMiterLimit);
                aPen.SetLineJoin(Gdiplus::LineJoinMiterClipped);
                break;
            }

There exist the general formula
    miter length = 1 / sin (phi/2 )
where phi is the angle between the lines. As Gdi+ expects a miter limit and LO uses a minimum angle, you have to convert it. Currently LO has only default 15° as minimum angle. Making the angle variable is work in progress.
Comment 7 QA Administrators 2017-05-22 13:26:36 UTC Comment hidden (obsolete)
Comment 8 Tomaz Vajngerl 2017-05-22 14:26:21 UTC
Didn't we fix this already?
Comment 9 Regina Henschel 2017-05-22 15:34:56 UTC
In edit mode it is correct now in both cases, anti-aliasing on or off.

But in presentation mode the switch to bevel does not happen at all, all four examples in the attached file have a sharp long corner. Anti-aliasing on/off setting has no effects on presentation mode. In presentation mode view is always anti-aliased.

Tested with Version: 5.4.0.0.alpha1+
Build ID: 965494c544dd8f35ae83b7cf38549009da06c367
CPU threads: 4; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@62-TDF, Branch:MASTER, Time: 2017-05-10_23:06:27
Locale: de-DE (de_DE); Calc: group
Comment 10 QA Administrators 2018-05-23 02:37:41 UTC Comment hidden (obsolete)
Comment 11 Regina Henschel 2018-05-23 20:46:25 UTC
The error still exists in Version: 6.0.4.2 (x64)
Build ID: 9b0d9b32d5dcda91d2f1a96dc04c645c450872bf
CPU threads: 8; OS: Windows 10.0; UI render: default; 
Locale: de-DE (de_DE); Calc: CL

and

Version: 6.1.0.0.alpha1+ (x64)
Build ID: 88051c660fc6759346a01bc559818d3e23f8f55c
CPU threads: 8; OS: Windows 10.0; UI render: default; 
Locale: de-DE (de_DE); Calc: CL
Comment 12 QA Administrators 2019-05-24 02:57:22 UTC Comment hidden (obsolete)
Comment 13 Regina Henschel 2019-05-24 11:03:58 UTC
The linejoin miter is still wrongly rendered in presentation mode.
Tested with Version: 6.3.0.0.alpha1+ (x64)
Build ID: 115ab48f86d4e3c6eede49767df1ee5a82b4ab22
CPU threads: 8; OS: Windows 10.0; UI render: default; VCL: win; 
TinderBox: Win-x86_64@62-TDF, Branch:master, Time: 2019-05-20_17:50:30
Locale: en-US (en_US); UI-Language: en-US
Calc: threaded
Comment 14 QA Administrators 2021-05-24 04:27:34 UTC Comment hidden (obsolete)
Comment 15 Regina Henschel 2021-05-24 14:08:09 UTC
The problem still exists in Version: 7.2.0.0.alpha1+ (x64) / LibreOffice Community
Build ID: 60cba23bc0f5e8eafecc03c437f1133b62569fa6
CPU threads: 8; OS: Windows 10.0 Build 19041; UI render: default; VCL: win
Locale: de-DE (en_US); UI: en-US
Calc: CL

If Skia is enabled, rendering is OK, same in edit as in presentation mode.
If Skia is disable, rendering in presentation mode is wrong, now independent from setting for antialiasing.