Remove WindowQuad::makeArrays and WindowQuad::makeInterleavedArrays

RenderGeometry can do all that these methods do and offers some extra
functionality, in addition to having a more explicit API.
This commit is contained in:
Arjen Hiemstra 2023-01-12 14:18:22 +01:00
parent 3118b48650
commit f95eb71173
2 changed files with 0 additions and 90 deletions

View file

@ -1020,94 +1020,6 @@ WindowQuadList WindowQuadList::makeRegularGrid(int xSubdivisions, int ySubdivisi
return ret;
}
#ifndef GL_TRIANGLES
#define GL_TRIANGLES 0x0004
#endif
#ifndef GL_QUADS
#define GL_QUADS 0x0007
#endif
void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertices, const QMatrix4x4 &textureMatrix, qreal scale) const
{
// Since we know that the texture matrix just scales and translates
// we can use this information to optimize the transformation
const QVector2D coeff(textureMatrix(0, 0), textureMatrix(1, 1));
const QVector2D offset(textureMatrix(0, 3), textureMatrix(1, 3));
GLVertex2D *vertex = vertices;
Q_ASSERT(type == GL_QUADS || type == GL_TRIANGLES);
switch (type) {
case GL_QUADS: {
for (const WindowQuad &quad : *this) {
#pragma GCC unroll 4
for (int j = 0; j < 4; j++) {
const WindowVertex &wv = quad[j];
auto vertexPos = roundVector(QVector2D(wv.x(), wv.y()) * scale);
GLVertex2D v;
v.position = vertexPos;
v.texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset;
*(vertex++) = v;
}
}
} break;
case GL_TRIANGLES: {
for (const WindowQuad &quad : *this) {
GLVertex2D v[4]; // Four unique vertices / quad
#pragma GCC unroll 4
for (int j = 0; j < 4; j++) {
const WindowVertex &wv = quad[j];
auto vertexPos = roundVector(QVector2D(wv.x(), wv.y()) * scale);
v[j].position = vertexPos;
v[j].texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset;
}
// First triangle
*(vertex++) = v[1]; // Top-right
*(vertex++) = v[0]; // Top-left
*(vertex++) = v[3]; // Bottom-left
// Second triangle
*(vertex++) = v[3]; // Bottom-left
*(vertex++) = v[2]; // Bottom-right
*(vertex++) = v[1]; // Top-right
}
} break;
default:
break;
}
}
void WindowQuadList::makeArrays(float **vertices, float **texcoords, const QSizeF &size, bool yInverted) const
{
*vertices = new float[count() * 6 * 2];
*texcoords = new float[count() * 6 * 2];
float *vpos = *vertices;
float *tpos = *texcoords;
// Note: The positions in a WindowQuad are stored in clockwise order
const int index[] = {1, 0, 3, 3, 2, 1};
for (const WindowQuad &quad : *this) {
for (int j = 0; j < 6; j++) {
const WindowVertex &wv = quad[index[j]];
*vpos++ = wv.x();
*vpos++ = wv.y();
*tpos++ = wv.u() / size.width();
*tpos++ = yInverted ? (wv.v() / size.height()) : (1.0 - wv.v() / size.height());
}
}
}
void RenderGeometry::copy(std::span<GLVertex2D> destination)
{
Q_ASSERT(int(destination.size()) >= size());

View file

@ -2948,8 +2948,6 @@ public:
WindowQuadList splitAtY(double y) const;
WindowQuadList makeGrid(int maxquadsize) const;
WindowQuadList makeRegularGrid(int xSubdivisions, int ySubdivisions) const;
void makeInterleavedArrays(unsigned int type, GLVertex2D *vertices, const QMatrix4x4 &matrix, qreal scale) const;
void makeArrays(float **vertices, float **texcoords, const QSizeF &size, bool yInverted) const;
};
/**