summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpathsimplifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qpathsimplifier.cpp')
-rw-r--r--src/gui/painting/qpathsimplifier.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/gui/painting/qpathsimplifier.cpp b/src/gui/painting/qpathsimplifier.cpp
index af702435c5..f784a64304 100644
--- a/src/gui/painting/qpathsimplifier.cpp
+++ b/src/gui/painting/qpathsimplifier.cpp
@@ -8,7 +8,9 @@
#include <QtCore/qpoint.h>
#include <QtCore/qalgorithms.h>
-#include <private/qopengl_p.h>
+#if QT_CONFIG(opengl)
+# include <private/qopengl_p.h>
+#endif
#include <private/qrbtree_p.h>
QT_BEGIN_NAMESPACE
@@ -303,13 +305,14 @@ private:
Type type;
Element *element;
};
+ friend class QTypeInfo<Event>;
typedef QRBTree<Element *>::Node RBNode;
typedef BoundingVolumeHierarchy::Node BVHNode;
void initElements(const QVectorPath &path, const QTransform &matrix);
void removeIntersections();
- void connectElements();
+ bool connectElements();
void fillIndices();
BVHNode *buildTree(Element **elements, int elementCount);
bool intersectNodes(QDataBuffer<Element *> &elements, BVHNode *elementNode, BVHNode *treeNode);
@@ -341,6 +344,10 @@ private:
uint m_hints;
};
+} // unnamed namespace
+
+Q_DECLARE_TYPEINFO(PathSimplifier::Event, Q_PRIMITIVE_TYPE);
+
inline PathSimplifier::BoundingVolumeHierarchy::BoundingVolumeHierarchy()
: root(nullptr)
, nodeBlock(nullptr)
@@ -454,11 +461,17 @@ PathSimplifier::PathSimplifier(const QVectorPath &path, QDataBuffer<QPoint> &ver
{
m_points->reset();
m_indices->reset();
+ bool ok = true;
initElements(path, matrix);
if (!m_elements.isEmpty()) {
removeIntersections();
- connectElements();
- fillIndices();
+ ok = connectElements();
+ if (ok)
+ fillIndices();
+ }
+ if (!ok) {
+ m_points->reset();
+ m_indices->reset();
}
}
@@ -643,7 +656,7 @@ void PathSimplifier::removeIntersections()
m_bvh.free(); // The bounding volume hierarchy is not needed anymore.
}
-void PathSimplifier::connectElements()
+bool PathSimplifier::connectElements()
{
Q_ASSERT(!m_elements.isEmpty());
QDataBuffer<Event> events(m_elements.size() * 2);
@@ -823,7 +836,8 @@ void PathSimplifier::connectElements()
}
if (!orderedElements.isEmpty()) {
- Q_ASSERT((orderedElements.size() & 1) == 0);
+ if (orderedElements.size() & 1) // Unexpected path structure
+ return false;
int i = 0;
Element *firstElement = orderedElements.at(0);
if (m_points->at(firstElement->indices[0]) != eventPoint) {
@@ -849,6 +863,7 @@ void PathSimplifier::connectElements()
Q_ASSERT((element->next == nullptr) == (element->previous == nullptr));
}
#endif
+ return true;
}
void PathSimplifier::fillIndices()
@@ -1614,9 +1629,6 @@ void PathSimplifier::sortEvents(Event *events, int count)
}
}
-} // end anonymous namespace
-
-
void qSimplifyPath(const QVectorPath &path, QDataBuffer<QPoint> &vertices,
QDataBuffer<quint32> &indices, const QTransform &matrix)
{
@@ -1631,3 +1643,5 @@ void qSimplifyPath(const QPainterPath &path, QDataBuffer<QPoint> &vertices,
QT_END_NAMESPACE
+
+#undef Q_FIXED_POINT_SCALE