From 6e2e4894159da51ab3413b8a0bb9c8ba615f0b7c Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 27 Apr 2011 10:46:24 +1000 Subject: Sort gradient stops for the convenience of the scenegraph The scenegraph gradients require sorted graident stops, whereas QML does not. Gradient stops are now sorted at the point they are passed into the scenegraph. Change-Id: I499dd00dc78e60dfc2053f2ee3691e61e0cf2a5d Task-number: QTBUG-18494 Reviewed-by: Martin Jones (cherry picked from commit 8cbd68b29224eed19f6ca6ec8186766c69a35c83) --- src/declarative/items/qsgrectangle.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/declarative/items/qsgrectangle.cpp b/src/declarative/items/qsgrectangle.cpp index 247d6336b2..cba6527759 100644 --- a/src/declarative/items/qsgrectangle.cpp +++ b/src/declarative/items/qsgrectangle.cpp @@ -267,8 +267,12 @@ QSGNode *QSGRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *da QGradientStops stops; if (d->gradient) { QList qxstops = d->gradient->m_stops; - for (int i = 0; i < qxstops.size(); ++i) - stops.append(QGradientStop(qxstops.at(i)->position(), qxstops.at(i)->color())); + for (int i = 0; i < qxstops.size(); ++i){ + int j = 0; + while (j < stops.size() && stops.at(j).first < qxstops[i]->position()) + j++; + stops.insert(j, QGradientStop(qxstops.at(i)->position(), qxstops.at(i)->color())); + } } rectangle->setGradientStops(stops); -- cgit v1.2.3