Bug 101026 - Polyline is clipped when rendered with cairo (gtk3)
Summary: Polyline is clipped when rendered with cairo (gtk3)
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
5.3.0.0.alpha0+
Hardware: All Linux (All)
: medium normal
Assignee: Armin Le Grand
URL:
Whiteboard: target:5.3.0
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-20 08:19 UTC by Tomaz Vajngerl
Modified: 2016-09-14 10:40 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Clipped polyline (8.33 KB, application/vnd.oasis.opendocument.graphics)
2016-07-20 08:19 UTC, Tomaz Vajngerl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomaz Vajngerl 2016-07-20 08:19:17 UTC
Created attachment 126315 [details]
Clipped polyline

Drawing a curved line (rendered as a polyline) when using GTK3 VCL backend or with GTK2 VCL backend that uses cairo code path for rendering of polylines, the polyline is clipped. Seems that the control points aren't correctly converted to cairo format (or something in this direction) which results that the curve is larger than it is supposed to be.

In the attached document there is an example of such a curve and the same curve dashed. Dashed curve is decomposed in drawinglayer to multiple lines so the rendering in that case is unaffected.
Comment 1 Armin Le Grand 2016-07-20 10:30:21 UTC
Should be close to tdf#99165 (if not even equal)
Comment 2 Armin Le Grand 2016-07-20 14:59:35 UTC
My fix for tdf#99165 was wrong. I somehow had in memory that 1/3rd of the vector to the other control point is equivalent to a mathematically correct replacement control point (for the missing one). This is true for modeling quadratic beziers using cubic ones, but not in general.
Thinking about how to solve this...
Comment 3 Armin Le Grand 2016-07-20 15:43:49 UTC
Worked with the formula reps of quadratic and cubic beziers, result is that a cubic bezier with one missing control point can not be eqally represented as quadratic bezier. Only way is to use a very small fallback vector - that works, but is not really correct.
All this to work around cairo and GDI+ not calculating the correct start/end vectors in these cases for the correct miter representation which are errors in these graphic sub-systems -> thinking about removing the fix tdf#99165...
Comment 4 Armin Le Grand 2016-07-21 07:58:10 UTC
Could reproduce on Win, too. Checked on win with testdoc from tdf#99165 and completely leaving out the old fix is not a good idea, still the wrong miter stuff. Checked on linux, does not happen there but seems to depend on the cairo version/identity, so may happen anytime.
For now I see no other possibility than using a very small replacement vector - what is a compromize since not mathematically correct. I experimented on both OSes, a value of 0.0005 of the full replacement control vector gives good results (0.05% of original length).
Comment 5 Armin Le Grand 2016-07-21 09:14:51 UTC
Patch on gerrit
Comment 6 Commit Notification 2016-07-28 09:43:37 UTC
Armin Le Grand committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ffa1c7bc86093b8445656bab1538939b9d3a6d88

tdf#101026 Create more correct replacement control vector

It will be available in 5.3.0.

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

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