From: Alan Alpert Date: Wed, 27 Apr 2011 00:46:24 +0000 (+1000) Subject: Sort gradient stops for the convenience of the scenegraph X-Git-Tag: qt-v5.0.0-alpha1~2170^2~177 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e2e4894159da51ab3413b8a0bb9c8ba615f0b7c;p=profile%2Fivi%2Fqtdeclarative.git 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) --- diff --git a/src/declarative/items/qsgrectangle.cpp b/src/declarative/items/qsgrectangle.cpp index 247d633..cba6527 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);