From 9cda847a0bec307a909b927e0928cdbb0b00fc81 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 12 Apr 2016 17:23:34 +0200 Subject: tdf#99165 always provide control points for beziers Some graphic sub systems cannot handle cases where control points of bezier curves are not set and produce wrong geometry for fat line drawing when MITER or similar LineCap and/or LineJoin is used. To avoid that, provide the mathematically correct fallback control points instead. Change-Id: Iabc724e51fb89e702f858db820c920f7b5b7d302 Reviewed-on: https://gerrit.libreoffice.org/24031 Tested-by: Jenkins Reviewed-by: Armin Le Grand --- canvas/source/cairo/cairo_canvashelper.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'canvas') diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index 91bc052b509b..bd86c8977152 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -276,6 +276,8 @@ namespace cairocanvas useStates( viewState, renderState, true ); cairo_move_to( mpCairo.get(), aBezierSegment.Px + 0.5, aBezierSegment.Py + 0.5 ); + // tdf#99165 correction of control poinits not needed here, only hairlines drawn + // (see cairo_set_line_width above) cairo_curve_to( mpCairo.get(), aBezierSegment.C1x + 0.5, aBezierSegment.C1y + 0.5, aBezierSegment.C2x + 0.5, aBezierSegment.C2y + 0.5, @@ -949,7 +951,7 @@ namespace cairocanvas bool bOpToDo = false; cairo_matrix_t aOrigMatrix, aIdentityMatrix; - double nX, nY, nBX, nBY, nAX, nAY; + double nX, nY, nBX, nBY, nAX, nAY, nLastX, nLastY; cairo_get_matrix( pCairo, &aOrigMatrix ); cairo_matrix_init_identity( &aIdentityMatrix ); @@ -1022,6 +1024,20 @@ namespace cairocanvas nBY += 0.5; } + // tdf#99165 if the control points are 'empty', create the mathematical + // correct replacement ones to avoid problems with the graphical sub-system + if(basegfx::fTools::equal(nAX, nLastX) && basegfx::fTools::equal(nAY, nLastY)) + { + nAX = nLastX + ((nBX - nLastX) * 0.3); + nAY = nLastY + ((nBY - nLastY) * 0.3); + } + + if(basegfx::fTools::equal(nBX, nX) && basegfx::fTools::equal(nBY, nY)) + { + nBX = nX + ((nAX - nX) * 0.3); + nBY = nY + ((nAY - nY) * 0.3); + } + cairo_curve_to( pCairo, nAX, nAY, nBX, nBY, nX, nY ); } else @@ -1031,6 +1047,9 @@ namespace cairocanvas } bOpToDo = true; } + + nLastX = nX; + nLastY = nY; } if( aPolygon.isClosed() ) -- cgit