diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-04-08 17:03:48 +0900 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2016-04-14 08:57:33 +0000 |
commit | a50eeba86bf746fc0f84948fee1a47819c3e8209 (patch) | |
tree | 31b25eac385cf9d475a82d44dcf2a37bae6054e9 | |
parent | 7dece94d6aa122d69e9740b93597d13347b5cb11 (diff) |
tdf#99244 opengl: miter limit for poly lines
(cherry picked from commit ea6196f0a51d1bf4cd722468406dcc8c64c7435c)
also includes commit cb4015bb28dd7430efaaa523d04a155eb7e46305
Change-Id: I1c363a8f1d21bbacab0c5785544aa8becfe39363
Reviewed-on: https://gerrit.libreoffice.org/24072
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index d3d6392bf96c..0c107da49abc 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -682,6 +682,8 @@ inline glm::vec2 normalize(const glm::vec2& vector) return vector; } +SAL_CONSTEXPR float constMiterMinimumAngle = 15.0f; + } // end anonymous namespace void OpenGLSalGraphicsImpl::DrawLineCap(float x1, float y1, float x2, float y2, css::drawing::LineCap eLineCap, float fLineWidth) @@ -864,6 +866,17 @@ void OpenGLSalGraphicsImpl::DrawPolyLine(const basegfx::B2DPolygon& rPolygon, fl if (eLineJoin == basegfx::B2DLineJoin::Miter) { + float angle = std::atan2(previousLineVector.x * nextLineVector.y - previousLineVector.y * nextLineVector.x, + previousLineVector.x * nextLineVector.x + previousLineVector.y * nextLineVector.y); + + angle = (F_PI - std::fabs(angle)) / F_PI180; + + if (angle < constMiterMinimumAngle) + eLineJoin = basegfx::B2DLineJoin::Bevel; + } + + if (eLineJoin == basegfx::B2DLineJoin::Miter) + { // With miter join we calculate the extrusion vector by adding normals of // previous and next line segment. The vector shows the way but we also // need the length (otherwise the line will be deformed). Length factor is |