Commit f09e3a98 authored by Martin Flöser's avatar Martin Flöser
Browse files

Fix decoration rendering with GL_TEXTURE_RECTANGLE_ARB

When using graphicssystem native the texture may be using
GL_TEXTURE_RECTANGLE_ARB instead of GL_TEXTURE_2D. This
needs to be honoured in order to make KWin work reliable
with e.g. R300 chipsets.

BUG: 274607
CCBUG: 276622
FIXED-IN: 4.7.0
parent 7962847f
......@@ -646,7 +646,7 @@ void SceneOpenGL::Window::paintDecoration(const QPixmap* decoration, TextureType
decorationTexture->bind();
prepareStates(decorationType, data.opacity * data.decoration_opacity, data.brightness, data.saturation, data.shader);
makeDecorationArrays(quads, rect, decorationTexture->getYInverted());
makeDecorationArrays(quads, rect, decorationTexture);
GLVertexBuffer::streamingBuffer()->render(region, GL_TRIANGLES);
restoreStates(decorationType, data.opacity * data.decoration_opacity, data.brightness, data.saturation, data.shader);
decorationTexture->unbind();
......@@ -685,14 +685,20 @@ void SceneOpenGL::Window::paintShadow(WindowQuadType type, const QRegion &region
#endif
}
void SceneOpenGL::Window::makeDecorationArrays(const WindowQuadList& quads, const QRect& rect, bool y_inverted) const
void SceneOpenGL::Window::makeDecorationArrays(const WindowQuadList& quads, const QRect &rect, Texture *tex) const
{
QVector<float> vertices;
QVector<float> texcoords;
vertices.reserve(quads.count() * 6 * 2);
texcoords.reserve(quads.count() * 6 * 2);
float width = rect.width();
float height = rect.height();
float width = tex->size().width();
float height = tex->size().height();
#ifndef KWIN_HAVE_OPENGLES
if (tex->target() == GL_TEXTURE_RECTANGLE_ARB) {
width = 1.0;
height = 1.0;
}
#endif
foreach (const WindowQuad & quad, quads) {
vertices << quad[ 1 ].x();
vertices << quad[ 1 ].y();
......@@ -707,7 +713,7 @@ void SceneOpenGL::Window::makeDecorationArrays(const WindowQuadList& quads, cons
vertices << quad[ 1 ].x();
vertices << quad[ 1 ].y();
if (y_inverted) {
if (tex->getYInverted()) {
texcoords << (float)(quad.originalRight() - rect.x()) / width;
texcoords << (float)(quad.originalTop() - rect.y()) / height;
texcoords << (float)(quad.originalLeft() - rect.x()) / width;
......
......@@ -168,7 +168,7 @@ protected:
QMatrix4x4 transformation(int mask, const WindowPaintData &data) const;
void paintDecoration(const QPixmap* decoration, TextureType decorationType, const QRegion& region, const QRect& rect, const WindowPaintData& data, const WindowQuadList& quads, bool updateDeco);
void paintShadow(WindowQuadType type, const QRegion &region, const WindowPaintData &data);
void makeDecorationArrays(const WindowQuadList& quads, const QRect& rect, bool y_inverted) const;
void makeDecorationArrays(const WindowQuadList& quads, const QRect &rect, Texture *tex) const;
void renderQuads(int, const QRegion& region, const WindowQuadList& quads, Texture* tex, bool normalized = false);
void prepareStates(TextureType type, double opacity, double brightness, double saturation, GLShader* shader);
void prepareStates(TextureType type, double opacity, double brightness, double saturation, GLShader* shader, Texture *texture);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment