aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-05-19 16:06:44 +0200
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-05-19 16:09:32 +0200
commitfa128f5252761ca944c7b670887a4553d2afdf61 (patch)
tree1ad8d2ead018bfa81938c8c71dd0757b6ec352f9
parentdefb7bc3e4ac0fe5de66e310a99afddc0c077d5e (diff)
Avoid using indices in the RectangleNode implementation.
Task-number: QTBUG-18731
-rw-r--r--src/declarative/scenegraph/qsgdefaultrectanglenode.cpp50
1 files changed, 21 insertions, 29 deletions
diff --git a/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp b/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp
index 21632040d9..34a6db4f78 100644
--- a/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp
+++ b/src/declarative/scenegraph/qsgdefaultrectanglenode.cpp
@@ -455,17 +455,16 @@ void QSGDefaultRectangleNode::updateGeometry()
--lastGradientStop;
int borderVertexCount = 0;
- ushort *borderIndices = 0;
if (penWidth) {
- borderGeometry->allocate((1 + lastGradientStop - nextGradientStop) * 2 + 8,
- (1 + lastGradientStop - nextGradientStop) * 4 + 10);
+ borderGeometry->allocate((1 + lastGradientStop - nextGradientStop) * 4 + 10);
borderVertices = (Vertex *)borderGeometry->vertexData();
- Q_ASSERT(borderGeometry->indexType() == GL_UNSIGNED_SHORT);
- borderIndices = borderGeometry->indexDataAsUShort();
}
fill->allocate((3 + lastGradientStop - nextGradientStop) * 2);
fillVertices = (uchar *)fill->vertexData();
+ QVarLengthArray<qreal, 16> ys(3 + lastGradientStop - nextGradientStop);
+ int yCount = 0;
+
for (int part = 0; part < 2; ++part) {
qreal y = (part ? innerRect.bottom() : innerRect.top());
gradientPos = (y - innerRect.top() + halfPenWidth) / m_rect.height();
@@ -485,10 +484,7 @@ void QSGDefaultRectangleNode::updateGeometry()
vertices[fillVertexCount].color = fillColor;
++fillVertexCount;
- if (penWidth) {
- borderVertices[borderVertexCount++].position = QVector2D(innerRect.right(), gy);
- borderVertices[borderVertexCount++].position = QVector2D(innerRect.left(), gy);
- }
+ ys[yCount++] = gy;
++nextGradientStop;
}
@@ -519,32 +515,28 @@ void QSGDefaultRectangleNode::updateGeometry()
++fillVertexCount;
}
- if (penWidth) {
- borderVertices[borderVertexCount++].position = QVector2D(innerRect.right(), y);
- borderVertices[borderVertexCount++].position = QVector2D(innerRect.left(), y);
- }
+ ys[yCount++] = y;
}
if (penWidth) {
- // Add four corners.
borderVertices[borderVertexCount++].position = QVector2D(outerRect.right(), outerRect.top());
- borderVertices[borderVertexCount++].position = QVector2D(outerRect.left(), outerRect.top());
- borderVertices[borderVertexCount++].position = QVector2D(outerRect.right(), outerRect.bottom());
- borderVertices[borderVertexCount++].position = QVector2D(outerRect.left(), outerRect.bottom());
-
- int borderIndexCount = 0;
- for (int i = 0; i < fillVertexCount / 2; ++i) {
- borderIndices[borderIndexCount++] = borderVertexCount - (i == 0 ? 4 : 2); // Upper or lower right corner.
- borderIndices[borderIndexCount++] = 2 * i + 0;
+ borderVertices[borderVertexCount++].position = QVector2D(innerRect.right(), ys[0]);
+ for (int i = 1; i < fillVertexCount / 2; ++i) {
+ borderVertices[borderVertexCount++].position = QVector2D(outerRect.right(), outerRect.bottom());
+ borderVertices[borderVertexCount++].position = QVector2D(innerRect.right(), ys[i]);
}
- for (int i = 0; i < fillVertexCount / 2; ++i) {
- borderIndices[borderIndexCount++] = borderVertexCount - (i == 0 ? 1 : 3); // Lower or upper left corner.
- borderIndices[borderIndexCount++] = fillVertexCount - 2 * i - 1;
+
+ borderVertices[borderVertexCount++].position = QVector2D(outerRect.left(), outerRect.bottom());
+ borderVertices[borderVertexCount++].position = QVector2D(innerRect.left(), ys[fillVertexCount / 2 - 1]);
+ for (int i = fillVertexCount / 2 - 2; i >= 0; --i) {
+ borderVertices[borderVertexCount++].position = QVector2D(outerRect.left(), outerRect.top());
+ borderVertices[borderVertexCount++].position = QVector2D(innerRect.left(), ys[i]);
}
- borderIndices[borderIndexCount++] = fillVertexCount; // Upper right corner.
- borderIndices[borderIndexCount++] = 0;
- Q_ASSERT(fillVertexCount + 4 == borderVertexCount);
- Q_ASSERT(borderIndexCount == borderGeometry->indexCount());
+
+ borderVertices[borderVertexCount++].position = QVector2D(outerRect.right(), outerRect.top());
+ borderVertices[borderVertexCount++].position = QVector2D(innerRect.right(), innerRect.top());
+
+ Q_ASSERT(borderVertexCount == borderGeometry->vertexCount());
}
Q_ASSERT(fillVertexCount == fill->vertexCount());
}