summaryrefslogtreecommitdiffstats
path: root/src/canvas/qxclipnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/canvas/qxclipnode.cpp')
-rw-r--r--src/canvas/qxclipnode.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/canvas/qxclipnode.cpp b/src/canvas/qxclipnode.cpp
index aded473..4e3df53 100644
--- a/src/canvas/qxclipnode.cpp
+++ b/src/canvas/qxclipnode.cpp
@@ -88,10 +88,12 @@ void QxClipNode::updateGeometry()
Geometry *g = geometry();
int vertexCount = 0;
+ // Radius should never exceeds half of the width or half of the height
+ qreal radius = qMin(qMin(m_rect.width() / 2, m_rect.height() / 2), m_radius);
QRectF rect = m_rect;
- rect.adjust(m_radius, m_radius, -m_radius, -m_radius);
+ rect.adjust(radius, radius, -radius, -radius);
- int segments = qMin(15, qCeil(m_radius)); // Number of segments per corner.
+ int segments = qMin(30, qCeil(radius)); // Number of segments per corner.
// Overestimate the number of vertices and indices, reduce afterwards when the actual numbers are known.
g->setVertexCount((segments + 1) * 4);
@@ -105,9 +107,9 @@ void QxClipNode::updateGeometry()
qreal angle = qreal(0.5 * M_PI) * (part + i / qreal(segments));
qreal s = qFastSin(angle);
qreal c = qFastCos(angle);
- qreal y = (part ? rect.bottom() : rect.top()) - m_radius * c; // current inner y-coordinate.
- qreal lx = rect.left() - m_radius * s; // current inner left x-coordinate.
- qreal rx = rect.right() + m_radius * s; // current inner right x-coordinate.
+ qreal y = (part ? rect.bottom() : rect.top()) - radius * c; // current inner y-coordinate.
+ qreal lx = rect.left() - radius * s; // current inner left x-coordinate.
+ qreal rx = rect.right() + radius * s; // current inner right x-coordinate.
vertices[vertexCount++].position = QVector2D(rx, y);
vertices[vertexCount++].position = QVector2D(lx, y);