kwin: Use the new map() interface in renderQuads()
Write the vertex data directly into the buffer object, instead of allocating two temporary arrays, coyping the data into them, and then copying the data from the arrays into the buffer object. This also makes renderQuads() handle coordinates for rectangular textures correctly.
This commit is contained in:
parent
7a00648195
commit
9c1833920c
1 changed files with 17 additions and 18 deletions
|
@ -1312,25 +1312,24 @@ void SceneOpenGL::Window::renderQuads(int, const QRegion& region, const WindowQu
|
||||||
{
|
{
|
||||||
if (quads.isEmpty())
|
if (quads.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const QMatrix4x4 matrix = tex->matrix(normalized ? NormalizedCoordinates : UnnormalizedCoordinates);
|
||||||
|
|
||||||
|
const GLVertexAttrib attribs[] = {
|
||||||
|
{ VA_Position, 2, GL_FLOAT, offsetof(GLVertex2D, position) },
|
||||||
|
{ VA_TexCoord, 2, GL_FLOAT, offsetof(GLVertex2D, texcoord) },
|
||||||
|
};
|
||||||
|
|
||||||
// Render geometry
|
// Render geometry
|
||||||
float* vertices;
|
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
|
||||||
float* texcoords;
|
vbo->setAttribLayout(attribs, 2, sizeof(GLVertex2D));
|
||||||
QSizeF size(tex->size());
|
vbo->setVertexCount(quads.count() * 6);
|
||||||
if (normalized) {
|
|
||||||
size.setWidth(1.0);
|
GLVertex2D *map = (GLVertex2D *) vbo->map(quads.count() * 6 * sizeof(GLVertex2D));
|
||||||
size.setHeight(1.0);
|
quads.makeInterleavedArrays(map, matrix);
|
||||||
}
|
vbo->unmap();
|
||||||
#ifndef KWIN_HAVE_OPENGLES
|
|
||||||
if (tex->target() == GL_TEXTURE_RECTANGLE_ARB) {
|
vbo->render(region, GL_TRIANGLES, hardwareClipping);
|
||||||
size.setWidth(1.0);
|
|
||||||
size.setHeight(1.0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
quads.makeArrays(&vertices, &texcoords, size, tex->isYInverted());
|
|
||||||
GLVertexBuffer::streamingBuffer()->setData(quads.count() * 6, 2, vertices, texcoords);
|
|
||||||
GLVertexBuffer::streamingBuffer()->render(region, GL_TRIANGLES, hardwareClipping);
|
|
||||||
delete[] vertices;
|
|
||||||
delete[] texcoords;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLTexture *SceneOpenGL::Window::textureForType(SceneOpenGL::Window::TextureType type)
|
GLTexture *SceneOpenGL::Window::textureForType(SceneOpenGL::Window::TextureType type)
|
||||||
|
|
Loading…
Reference in a new issue