diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2016-04-12 17:23:34 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2016-04-13 10:28:06 +0000 |
commit | 9cda847a0bec307a909b927e0928cdbb0b00fc81 (patch) | |
tree | af8deff6fdfa9de8e81d21c3261aed1997ad7755 /canvas | |
parent | e2d97f16482cf997e91433cc411d107f26bf7b75 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/source/cairo/cairo_canvashelper.cxx | 21 |
1 files changed, 20 insertions, 1 deletions
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() ) |