summaryrefslogtreecommitdiff
path: root/vcl/opengl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-04-08 17:03:48 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-04-14 14:19:10 +0900
commitea6196f0a51d1bf4cd722468406dcc8c64c7435c (patch)
tree10ff4a0adc781fe951a8870d1420d59e426f544d /vcl/opengl
parent92d7fef02574051826e46a3a7e3d33a1afa062d7 (diff)
tdf#99244 opengl: miter limit for poly lines
Change-Id: I1c363a8f1d21bbacab0c5785544aa8becfe39363
Diffstat (limited to 'vcl/opengl')
-rw-r--r--vcl/opengl/gdiimpl.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 32e085fb4fe1..8b8046f7a5fa 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -39,6 +39,7 @@
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/norm.hpp>
+#include <glm/gtx/compatibility.hpp>
#include <stdlib.h>
@@ -684,6 +685,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)
@@ -866,6 +869,17 @@ void OpenGLSalGraphicsImpl::DrawPolyLine(const basegfx::B2DPolygon& rPolygon, fl
if (eLineJoin == basegfx::B2DLineJoin::Miter)
{
+ float angle = glm::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