Speed up distance field generation by another 20% or so.
authorGunnar Sletta <gunnar.sletta@nokia.com>
Wed, 15 Jun 2011 13:46:22 +0000 (15:46 +0200)
committerGunnar Sletta <gunnar.sletta@nokia.com>
Wed, 15 Jun 2011 13:46:22 +0000 (15:46 +0200)
src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp

index c1a46cb..31e654b 100644 (file)
@@ -344,10 +344,8 @@ static QImage makeDistanceField(int imgSize, const QPainterPath &path, int dfSca
     bool isShortData = polys.indices.type() == QVertexIndexVector::UnsignedShort;
     const void *indices = polys.indices.data();
     int index = 0;
-    QVector<DFPoint> normals;
-    QVector<DFVertex> vertices;
-    normals.reserve(polys.vertices.count());
-    vertices.reserve(polys.vertices.count());
+    QVarLengthArray<DFPoint> normals(polys.vertices.count());
+    QVarLengthArray<DFVertex> vertices(polys.vertices.count());
 
     while (index < polys.indices.size()) {
         normals.clear();
@@ -386,7 +384,7 @@ static QImage makeDistanceField(int imgSize, const QPainterPath &path, int dfSca
             vertices.append(v);
         }
 
-        QVector<bool> isConvex(normals.count());
+        QVarLengthArray<bool> isConvex(normals.count());
         for (int next = 0, prev = normals.count() - 1; next < normals.count(); prev = next++)
             isConvex[prev] = (normals.at(prev).x * normals.at(next).y - normals.at(prev).y * normals.at(next).x > 0);