summaryrefslogtreecommitdiff
path: root/src/svg/qsvgnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/svg/qsvgnode.cpp')
-rw-r--r--src/svg/qsvgnode.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/svg/qsvgnode.cpp b/src/svg/qsvgnode.cpp
index 62c118e..31e5338 100644
--- a/src/svg/qsvgnode.cpp
+++ b/src/svg/qsvgnode.cpp
@@ -4,11 +4,21 @@
#include "qsvgnode_p.h"
#include "qsvgtinydocument_p.h"
+#include <QLoggingCategory>
+
#include "qdebug.h"
#include "qstack.h"
+#include <QtGui/private/qoutlinemapper_p.h>
+
+#if !defined(QT_SVG_SIZE_LIMIT)
+# define QT_SVG_SIZE_LIMIT QT_RASTER_COORD_LIMIT
+#endif
+
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcSvgDraw)
+
QSvgNode::QSvgNode(QSvgNode *parent)
: m_parent(parent),
m_visible(true),
@@ -167,6 +177,11 @@ QSvgFillStyleProperty * QSvgNode::styleProperty(const QString &id) const
return doc ? doc->namedStyle(rid) : 0;
}
+QRectF QSvgNode::fastBounds(QPainter *p, QSvgExtraStates &states) const
+{
+ return bounds(p, states);
+}
+
QRectF QSvgNode::bounds(QPainter *, QSvgExtraStates &) const
{
return QRectF(0, 0, 0, 0);
@@ -311,4 +326,20 @@ qreal QSvgNode::strokeWidth(QPainter *p)
return pen.widthF();
}
+bool QSvgNode::shouldDrawNode(QPainter *p, QSvgExtraStates &states) const
+{
+ static bool alwaysDraw = qEnvironmentVariableIntValue("QT_SVG_DISABLE_SIZE_LIMIT");
+ if (alwaysDraw)
+ return true;
+
+ QRectF brect = fastBounds(p, states);
+ if (brect.width() <= QT_SVG_SIZE_LIMIT && brect.height() <= QT_SVG_SIZE_LIMIT) {
+ return true;
+ } else {
+ qCWarning(lcSvgDraw) << "Shape of type" << type() << "ignored because it will take too long to rasterize (bounding rect=" << brect << ")."
+ << "Set QT_SVG_DISABLE_SIZE_LIMIT=1 to disable this check.";
+ return false;
+ }
+}
+
QT_END_NAMESPACE