summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraavit <eirik.aavitsland@theqtcompany.com>2014-11-25 15:40:54 +0100
committerEirik Aavitsland <eirik.aavitsland@theqtcompany.com>2014-11-25 17:01:54 +0200
commitde42b3a21ddb8aadd2f01c3f4c15663f78545ae6 (patch)
treebca3a9a884109f13d6592366f8eaeed21fa5cc6e
parent88690a7c78dc19fb43f3936aa56cd45f18b8e2dd (diff)
Fix crash for borderimage with negative borders
Replace negative margin values with 0. Test case: qtdeclarative/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_negative_borders.qml Change-Id: I53d143fd079cbaa5e6c8080ada81720f8b1b598b Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@theqtcompany.com>
-rw-r--r--src/plugins/scenegraph/softwarecontext/imagenode.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/scenegraph/softwarecontext/imagenode.cpp b/src/plugins/scenegraph/softwarecontext/imagenode.cpp
index 3146830172..0ca579db5b 100644
--- a/src/plugins/scenegraph/softwarecontext/imagenode.cpp
+++ b/src/plugins/scenegraph/softwarecontext/imagenode.cpp
@@ -28,8 +28,13 @@
namespace SoftwareContext {
-void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins,
- const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
+static inline QMargins normalizedMargins(const QMargins &m)
+{
+ return QMargins(qMax(m.left(), 0), qMax(m.top(), 0), qMax(m.right(), 0), qMax(m.bottom(), 0));
+}
+
+void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMarginsIn,
+ const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMarginsIn,
const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
{
QPainter::PixmapFragment d;
@@ -39,6 +44,9 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
QPixmapFragmentsArray opaqueData;
QPixmapFragmentsArray translucentData;
+ QMargins sourceMargins = normalizedMargins(sourceMarginsIn);
+ QMargins targetMargins = normalizedMargins(targetMarginsIn);
+
// source center
const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();