eliminating the index buffer

This commit is contained in:
Uwe Rathmann 2024-09-25 07:51:02 +02:00
parent e9947c17a0
commit ae9bc90d38

View File

@ -13,12 +13,14 @@ QSK_QT_PRIVATE_BEGIN
#include <private/qtriangulator_p.h> #include <private/qtriangulator_p.h>
QSK_QT_PRIVATE_END QSK_QT_PRIVATE_END
#if 0
// keeping the index list
static void qskUpdateGeometry( const QPainterPath& path, static void qskUpdateGeometry( const QPainterPath& path,
const QTransform& transform, QSGGeometry& geometry ) const QTransform& transform, QSGGeometry& geometry )
{ {
const auto ts = qTriangulate( path, transform, 1, false ); const auto ts = qTriangulate( path, transform, 1, false );
#if 1
geometry.allocate( ts.vertices.size(), ts.indices.size() ); geometry.allocate( ts.vertices.size(), ts.indices.size() );
auto vertexData = reinterpret_cast< float* >( geometry.vertexData() ); auto vertexData = reinterpret_cast< float* >( geometry.vertexData() );
@ -29,11 +31,22 @@ static void qskUpdateGeometry( const QPainterPath& path,
memcpy( geometry.indexData(), ts.indices.data(), memcpy( geometry.indexData(), ts.indices.data(),
ts.indices.size() * sizeof( quint16 ) ); ts.indices.size() * sizeof( quint16 ) );
#else }
#endif
static void qskUpdateGeometry( const QPainterPath& path,
const QTransform& transform, QSGGeometry& geometry )
{
const auto ts = qTriangulate( path, transform, 1, false );
/* /*
The triangulation of a random path does not lead to index lists
that are substantially reducing the number of vertices.
As we have to iterate over the vertex buffer to copy qreal to float As we have to iterate over the vertex buffer to copy qreal to float
anyway we could reorder according to the index buffer and drop anyway we reorder according to the index buffer and drop
the index buffer then ??? the index buffer.
QTriangleSet: QTriangleSet:
@ -41,6 +54,7 @@ static void qskUpdateGeometry( const QPainterPath& path,
QVector<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...] QVector<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...]
QVector<quint16> indices; // [i[0], j[0], k[0], i[1], j[1], k[1], i[2], ...] QVector<quint16> indices; // [i[0], j[0], k[0], i[1], j[1], k[1], i[2], ...]
*/ */
const auto points = ts.vertices.constData(); const auto points = ts.vertices.constData();
const auto indices = reinterpret_cast< const quint16* >( ts.indices.data() ); const auto indices = reinterpret_cast< const quint16* >( ts.indices.data() );
@ -52,7 +66,6 @@ static void qskUpdateGeometry( const QPainterPath& path,
const int j = 2 * indices[i]; const int j = 2 * indices[i];
vertexData[i].set( points[j], points[j + 1] ); vertexData[i].set( points[j], points[j + 1] );
} }
#endif
} }
class QskShapeNodePrivate final : public QskFillNodePrivate class QskShapeNodePrivate final : public QskFillNodePrivate