From a3d907d7481b2179670ceeae479620c2cd996be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Wed, 13 Mar 2013 18:38:56 +0100 Subject: [PATCH] kwin/glx: Use glBlitFramebuffer() instead of glCopyPixels() glCopyPixels(), glRasterPos() and glBitmap() are not available in a core context. --- scene_opengl.cpp | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 889f07e0c3..fc28035200 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -258,39 +258,13 @@ bool SceneOpenGL::initFailed() const #ifndef KWIN_HAVE_OPENGLES void SceneOpenGL::copyPixels(const QRegion ®ion) { - GLint shader = 0; - if (ShaderManager::instance()->isShaderBound()) { - glGetIntegerv(GL_CURRENT_PROGRAM, &shader); - glUseProgram(0); - } - bool reenableTexUnit = false; - if (glIsEnabled(GL_TEXTURE_2D)) { - glDisable(GL_TEXTURE_2D); - reenableTexUnit = true; - } - // no idea why glScissor() is used, but Compiz has it and it doesn't seem to hurt - glEnable(GL_SCISSOR_TEST); - - int xpos = 0; - int ypos = 0; foreach (const QRect &r, region.rects()) { - // convert to OpenGL coordinates - int y = displayHeight() - r.y() - r.height(); - glBitmap(0, 0, 0, 0, r.x() - xpos, y - ypos, NULL); // not glRasterPos2f, see glxbackend.cpp - xpos = r.x(); - ypos = y; - glScissor(r.x(), y, r.width(), r.height()); - glCopyPixels(r.x(), y, r.width(), r.height(), GL_COLOR); - } + const int x0 = r.x(); + const int y0 = displayHeight() - r.y() - r.height(); + const int x1 = r.x() + r.width(); + const int y1 = displayHeight() - r.y(); - glBitmap(0, 0, 0, 0, -xpos, -ypos, NULL); // move position back to 0,0 - glDisable(GL_SCISSOR_TEST); - if (reenableTexUnit) { - glEnable(GL_TEXTURE_2D); - } - // rebind previously bound shader - if (ShaderManager::instance()->isShaderBound()) { - glUseProgram(shader); + glBlitFramebuffer(x0, y0, x1, y1, x0, y0, x1, y1, GL_COLOR_BUFFER_BIT, GL_NEAREST); } } #endif