diff --git a/CMakeLists.txt b/CMakeLists.txt index 64542f1f35..c67cb9fb0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,6 @@ option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON) option(KWIN_BUILD_SCREENEDGES "Enable building of KWin with screen edge support" ON) option(KWIN_BUILD_KAPPMENU "Enable building of KWin with application menu support" ON) option(KWIN_BUILD_XRENDER_COMPOSITING "Enable building of KWin with XRender Compositing support" ON) -option(KWIN_BUILD_OPENGL_1_COMPOSITING "Enable support for OpenGL 1.x, automatically disabled when building for OpenGL ES 2.0" ON) cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF) option(KWIN_PLASMA_ACTIVE "Enable building KWin for Plasma Active." OFF) @@ -317,9 +316,6 @@ set_target_properties(kwin PROPERTIES OUTPUT_NAME ${KWIN_NAME}) generate_export_header(kdeinit_kwin EXPORT_FILE_NAME kwin_export.h) if(KWIN_BUILD_OPENGL) - if( KWIN_BUILD_OPENGL_1_COMPOSITING ) - set_target_properties(kdeinit_kwin PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGL_1) - endif() target_link_libraries(kdeinit_kwin kwinglutils ${OPENGL_gl_LIBRARY}) # -ldl used by OpenGL code find_library(DL_LIBRARY dl) diff --git a/composite.cpp b/composite.cpp index 5cd28e8fc3..0a83fb28de 100644 --- a/composite.cpp +++ b/composite.cpp @@ -835,8 +835,6 @@ QString Compositor::compositingType() const switch (m_scene->compositingType()) { case XRenderCompositing: return QStringLiteral("xrender"); - case OpenGL1Compositing: - return QStringLiteral("gl1"); case OpenGL2Compositing: #ifdef KWIN_HAVE_OPENGLES return QStringLiteral("gles"); diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 34dd97fb21..d8466fdb60 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -49,11 +49,7 @@ endmacro() # Adds effect plugin with given name. Sources are given after the name macro( KWIN4_ADD_EFFECT name ) kwin4_add_effect_backend(kwin4_effect_${name} ${ARGN}) - if(KWIN_BUILD_OPENGL) - if( KWIN_BUILD_OPENGL_1_COMPOSITING ) - set_target_properties(kwin4_effect_${name} PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGL_1) - endif() - elseif(KWIN_BUILD_OPENGLES) + if(KWIN_BUILD_OPENGLES) set_target_properties(kwin4_effect_${name} PROPERTIES COMPILE_FLAGS "-DKWIN_HAVE_OPENGLES") endif() diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp index 8f30d714b4..655bb4d64e 100644 --- a/effects/backgroundcontrast/contrast.cpp +++ b/effects/backgroundcontrast/contrast.cpp @@ -168,10 +168,6 @@ bool ContrastEffect::enabledByDefault() if (gl->isIntel() && gl->chipClass() < SandyBridge) return false; - if (gl->driver() == Driver_Catalyst && effects->compositingType() == OpenGL1Compositing) { - // fglrx supports only ARB shaders and those tend to crash KWin (see Bug #270818 and #286795) - return false; - } return true; } @@ -383,16 +379,9 @@ void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const shader->setOpacity(opacity); // Set up the texture matrix to transform from screen coordinates // to texture coordinates. -#ifdef KWIN_HAVE_OPENGL_1 - if (effects->compositingType() == OpenGL1Compositing) { - glMatrixMode(GL_TEXTURE); - pushMatrix(); - } -#endif QMatrix4x4 textureMatrix; textureMatrix.scale(1.0 / scratch.width(), -1.0 / scratch.height(), 1); textureMatrix.translate(-r.x(), -scratch.height() - r.y(), 0); - loadMatrix(textureMatrix); shader->setTextureMatrix(textureMatrix); vbo->draw(GL_TRIANGLES, 0, actualShape.rectCount() * 6); @@ -402,13 +391,6 @@ void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const vbo->unbindArrays(); -#ifdef KWIN_HAVE_OPENGL_1 - if (effects->compositingType() == OpenGL1Compositing) { - popMatrix(); - glMatrixMode(GL_MODELVIEW); - } -#endif - if (opacity < 1.0) { glDisable(GL_BLEND); } diff --git a/effects/backgroundcontrast/contrastshader.cpp b/effects/backgroundcontrast/contrastshader.cpp index 99325526c3..8d620db5c6 100644 --- a/effects/backgroundcontrast/contrastshader.cpp +++ b/effects/backgroundcontrast/contrastshader.cpp @@ -64,28 +64,9 @@ bool ContrastShader::supported() { if (!GLPlatform::instance()->supports(GLSL)) return false; - if (effects->compositingType() == OpenGL1Compositing) - return false; (void) glGetError(); // Clear the error state -#ifdef KWIN_HAVE_OPENGL_1 - // These are the minimum values the implementation is required to support - int value = 0; - - glGetIntegerv(GL_MAX_VARYING_FLOATS, &value); - if (value < 32) - return false; - - glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &value); - if (value < 64) - return false; - - glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &value); - if (value < 512) - return false; -#endif - if (glGetError() != GL_NO_ERROR) return false; diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index ea89f02fae..828edbc9e1 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -146,10 +146,6 @@ bool BlurEffect::enabledByDefault() if (gl->isIntel() && gl->chipClass() < SandyBridge) return false; - if (gl->driver() == Driver_Catalyst && effects->compositingType() == OpenGL1Compositing) { - // fglrx supports only ARB shaders and those tend to crash KWin (see Bug #270818 and #286795) - return false; - } return true; } @@ -157,11 +153,6 @@ bool BlurEffect::enabledByDefault() bool BlurEffect::supported() { bool supported = GLRenderTarget::supported() && GLTexture::NPOTTextureSupported() && GLSLBlurShader::supported(); -#ifdef KWIN_HAVE_OPENGL_1 - if (effects->compositingType() == OpenGL1Compositing) { - supported = GLRenderTarget::supported() && GLTexture::NPOTTextureSupported() && ARBBlurShader::supported(); - } -#endif if (supported) { int maxTexSize; @@ -463,16 +454,9 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o // Set up the texture matrix to transform from screen coordinates // to texture coordinates. -#ifdef KWIN_HAVE_OPENGL_1 - if (effects->compositingType() == OpenGL1Compositing) { - glMatrixMode(GL_TEXTURE); - pushMatrix(); - } -#endif QMatrix4x4 textureMatrix; textureMatrix.scale(1.0 / scratch.width(), -1.0 / scratch.height(), 1); textureMatrix.translate(-r.x(), -scratch.height() - r.y(), 0); - loadMatrix(textureMatrix); shader->setTextureMatrix(textureMatrix); vbo->draw(GL_TRIANGLES, 0, expanded.rectCount() * 6); @@ -500,19 +484,11 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o textureMatrix.setToIdentity(); textureMatrix.scale(1.0 / tex.width(), -1.0 / tex.height(), 1); textureMatrix.translate(0, -tex.height(), 0); - loadMatrix(textureMatrix); shader->setTextureMatrix(textureMatrix); vbo->draw(GL_TRIANGLES, expanded.rectCount() * 6, shape.rectCount() * 6); vbo->unbindArrays(); -#ifdef KWIN_HAVE_OPENGL_1 - if (effects->compositingType() == OpenGL1Compositing) { - popMatrix(); - glMatrixMode(GL_MODELVIEW); - } -#endif - if (opacity < 1.0) { glDisable(GL_BLEND); } @@ -553,17 +529,6 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa shader->bind(); QMatrix4x4 textureMatrix; QMatrix4x4 modelViewProjectionMatrix; -#ifdef KWIN_HAVE_OPENGL_1 - if (effects->compositingType() == OpenGL1Compositing) { - glMatrixMode(GL_MODELVIEW); - pushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_TEXTURE); - pushMatrix(); - glMatrixMode(GL_PROJECTION); - pushMatrix(); - } -#endif /** * Which part of the background texture can be updated ? @@ -632,20 +597,12 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa modelViewProjectionMatrix.ortho(0, r.width(), r.height(), 0 , 0, 65535); modelViewProjectionMatrix.translate(-r.x(), -r.y(), 0); - loadMatrix(modelViewProjectionMatrix); shader->setModelViewProjectionMatrix(modelViewProjectionMatrix); // Set up the texture matrix to transform from screen coordinates // to texture coordinates. textureMatrix.scale(1.0 / tex.width(), -1.0 / tex.height(), 1); textureMatrix.translate(-updateRect.x(), -updateRect.height() - updateRect.y(), 0); -#ifdef KWIN_HAVE_OPENGL_1 - if (effects->compositingType() == OpenGL1Compositing) { - glMatrixMode(GL_TEXTURE); - loadMatrix(textureMatrix); - glMatrixMode(GL_PROJECTION); - } -#endif shader->setTextureMatrix(textureMatrix); vbo->draw(GL_TRIANGLES, horizontalOffset, horizontalCount); @@ -673,7 +630,6 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa modelViewProjectionMatrix.setToIdentity(); const QSize screenSize = effects->virtualScreenSize(); modelViewProjectionMatrix.ortho(0, screenSize.width(), screenSize.height(), 0, 0, 65535); - loadMatrix(modelViewProjectionMatrix); shader->setModelViewProjectionMatrix(modelViewProjectionMatrix); // Set the up the texture matrix to transform from screen coordinates @@ -681,28 +637,11 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa textureMatrix.setToIdentity(); textureMatrix.scale(1.0 / targetTexture.width(), -1.0 / targetTexture.height(), 1); textureMatrix.translate(-r.x(), -targetTexture.height() - r.y(), 0); -#ifdef KWIN_HAVE_OPENGL_1 - if (effects->compositingType() == OpenGL1Compositing) { - glMatrixMode(GL_TEXTURE); - loadMatrix(textureMatrix); - glMatrixMode(GL_PROJECTION); - } -#endif shader->setTextureMatrix(textureMatrix); vbo->draw(GL_TRIANGLES, verticalOffset, verticalCount); vbo->unbindArrays(); -#ifdef KWIN_HAVE_OPENGL_1 - if (effects->compositingType() == OpenGL1Compositing) { - popMatrix(); - glMatrixMode(GL_TEXTURE); - popMatrix(); - glMatrixMode(GL_MODELVIEW); - popMatrix(); - } -#endif - if (opacity < 1.0) { glDisable(GL_BLEND); } diff --git a/effects/blur/blurshader.cpp b/effects/blur/blurshader.cpp index f86ca0567b..8886ed827a 100644 --- a/effects/blur/blurshader.cpp +++ b/effects/blur/blurshader.cpp @@ -46,11 +46,7 @@ BlurShader *BlurShader::create() if (GLSLBlurShader::supported()) return new GLSLBlurShader(); -#ifdef KWIN_HAVE_OPENGL_1 - return new ARBBlurShader(); -#else - return NULL; -#endif + return nullptr; } void BlurShader::setRadius(int radius) @@ -139,28 +135,9 @@ bool GLSLBlurShader::supported() { if (!GLPlatform::instance()->supports(GLSL)) return false; - if (effects->compositingType() == OpenGL1Compositing) - return false; (void) glGetError(); // Clear the error state -#ifdef KWIN_HAVE_OPENGL_1 - // These are the minimum values the implementation is required to support - int value = 0; - - glGetIntegerv(GL_MAX_VARYING_FLOATS, &value); - if (value < 32) - return false; - - glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &value); - if (value < 64) - return false; - - glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &value); - if (value < 512) - return false; -#endif - if (glGetError() != GL_NO_ERROR) return false; @@ -333,174 +310,3 @@ void GLSLBlurShader::init() setIsValid(shader->isValid()); } - - - -// ---------------------------------------------------------------------------- - - -#ifdef KWIN_HAVE_OPENGL_1 -ARBBlurShader::ARBBlurShader() - : BlurShader(), program(0) -{ -} - -ARBBlurShader::~ARBBlurShader() -{ - reset(); -} - -void ARBBlurShader::reset() -{ - if (program) { - glDeleteProgramsARB(1, &program); - program = 0; - } - - setIsValid(false); -} - -bool ARBBlurShader::supported() -{ - if (!hasGLExtension(QStringLiteral("GL_ARB_fragment_program"))) - return false; - - (void) glGetError(); // Clear the error state - - // These are the minimum values the implementation is required to support - int value = 0; - - glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_PARAMETERS_ARB, &value); - if (value < 24) - return false; - - glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_TEMPORARIES_ARB, &value); - if (value < 16) - return false; - - glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_INSTRUCTIONS_ARB, &value); - if (value < 72) - return false; - - glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, &value); - if (value < 24) - return false; - - glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, &value); - if (value < 4) - return false; - - if (glGetError() != GL_NO_ERROR) - return false; - - return true; -} - -void ARBBlurShader::setPixelDistance(float val) -{ - float firstStep = val * 1.5; - float nextStep = val * 2.0; - - if (direction() == Qt::Horizontal) { - glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, firstStep, 0, 0, 0); - glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, nextStep, 0, 0, 0); - } else { - glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 0, firstStep, 0, 0); - glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 0, nextStep, 0, 0); - } -} - -void ARBBlurShader::bind() -{ - if (!isValid()) - return; - - glEnable(GL_FRAGMENT_PROGRAM_ARB); - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program); -} - -void ARBBlurShader::unbind() -{ - int boundObject; - glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &boundObject); - if (boundObject == (int)program) { - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0); - glDisable(GL_FRAGMENT_PROGRAM_ARB); - } -} - -int ARBBlurShader::maxKernelSize() const -{ - int value; - int result; - - glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_PARAMETERS_ARB, &value); - result = (value - 1) * 2; // We only need to store half the kernel, since it's symmetrical - - glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_INSTRUCTIONS_ARB, &value); - result = qMin(result, value / 3); // We need 3 instructions / sample - - return result; -} - -void ARBBlurShader::init() -{ - QList kernel = gaussianKernel(); - const int size = kernel.size(); - const int center = size / 2; - - QByteArray text; - QTextStream stream(&text); - - stream << "!!ARBfp1.0\n"; - - // The kernel values are hardcoded into the program - for (int i = 0; i <= center; i++) - stream << "PARAM kernel" << i << " = " << kernel[center + i].g << ";\n"; - - stream << "PARAM firstSample = program.local[0];\n"; // Distance from gl_TexCoord[0] to the next sample - stream << "PARAM nextSample = program.local[1];\n"; // Distance to the subsequent sample - - // Temporary variables to hold coordinates and texture samples - for (int i = 0; i < size; i++) - stream << "TEMP temp" << i << ";\n"; - - // Compute the texture coordinates - stream << "ADD temp1, fragment.texcoord[0], firstSample;\n"; // temp1 = gl_TexCoord[0] + firstSample - stream << "SUB temp2, fragment.texcoord[0], firstSample;\n"; // temp2 = gl_TexCoord[0] - firstSample - for (int i = 1, j = 3; i < center; i++, j += 2) { - stream << "ADD temp" << j + 0 << ", temp" << j - 2 << ", nextSample;\n"; - stream << "SUB temp" << j + 1 << ", temp" << j - 1 << ", nextSample;\n"; - } - - // Sample the texture coordinates - stream << "TEX temp0, fragment.texcoord[0], texture[0], 2D;\n"; - for (int i = 1; i < size; i++) - stream << "TEX temp" << i << ", temp" << i << ", texture[0], 2D;\n"; - - // Multiply the samples with the kernel values and compute the sum - stream << "MUL temp0, temp0, kernel0;\n"; - for (int i = 0, j = 1; i < center; i++) { - stream << "MAD temp0, temp" << j++ << ", kernel" << i + 1 << ", temp0;\n"; - stream << "MAD temp0, temp" << j++ << ", kernel" << i + 1 << ", temp0;\n"; - } - - stream << "MOV result.color, temp0;\n"; // gl_FragColor = temp0 - stream << "END\n"; - stream.flush(); - - glGenProgramsARB(1, &program); - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program); - glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, text.length(), text.constData()); - - if (glGetError()) { - const char *error = (const char*)glGetString(GL_PROGRAM_ERROR_STRING_ARB); - qCritical() << "Failed to compile fragment program:" << error; - setIsValid(false); - } else - setIsValid(true); - - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0); -} -#endif - diff --git a/effects/blur/blurshader.h b/effects/blur/blurshader.h index 54bde620b3..b1769be7a8 100644 --- a/effects/blur/blurshader.h +++ b/effects/blur/blurshader.h @@ -116,36 +116,6 @@ private: int pixelSizeLocation; }; - - -// ---------------------------------------------------------------------------- - - -#ifdef KWIN_HAVE_OPENGL_1 -class ARBBlurShader : public BlurShader -{ -public: - ARBBlurShader(); - ~ARBBlurShader(); - - void setPixelDistance(float val); - void bind(); - void unbind(); - void setTextureMatrix(const QMatrix4x4 &) {} - void setModelViewProjectionMatrix(const QMatrix4x4 &) {} - - static bool supported(); - -protected: - void init(); - void reset(); - int maxKernelSize() const; - -private: - GLuint program; -}; -#endif - } // namespace KWin #endif diff --git a/effects/coverswitch/coverswitch.cpp b/effects/coverswitch/coverswitch.cpp index 022580ece5..107697175f 100644 --- a/effects/coverswitch/coverswitch.cpp +++ b/effects/coverswitch/coverswitch.cpp @@ -187,22 +187,12 @@ void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d projection.frustum(xmin * xminFactor, xmax * xmaxFactor, ymin * yminFactor, ymax * ymaxFactor, zNear, zFar); QMatrix4x4 modelview; modelview.translate(xTranslate, yTranslate, 0.0); - if (shaderManager->isShaderBound()) { - GLShader *shader = shaderManager->pushShader(ShaderManager::GenericShader); - origProjection = shader->getUniformMatrix4x4("projection"); - origModelview = shader->getUniformMatrix4x4("modelview"); - shader->setUniform("projection", projection); - shader->setUniform("modelview", origModelview * modelview); - shaderManager->popShader(); - } else { -#ifdef KWIN_HAVE_OPENGL_1 - glMatrixMode(GL_PROJECTION); - pushMatrix(); - loadMatrix(projection); - glMatrixMode(GL_MODELVIEW); - pushMatrix(modelview); -#endif - } + GLShader *shader = shaderManager->pushShader(ShaderManager::GenericShader); + origProjection = shader->getUniformMatrix4x4("projection"); + origModelview = shader->getUniformMatrix4x4("modelview"); + shader->setUniform("projection", projection); + shader->setUniform("modelview", origModelview * modelview); + shaderManager->popShader(); } QList< EffectWindow* > tempList = currentWindowList; @@ -305,7 +295,7 @@ void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d glScissor(area.x(), y, area.width(), area.height()); glEnable(GL_SCISSOR_TEST); - if (shaderManager->isValid() && m_reflectionShader && m_reflectionShader->isValid()) { + if (m_reflectionShader && m_reflectionShader->isValid()) { shaderManager->pushShader(m_reflectionShader); QMatrix4x4 windowTransformation; windowTransformation.translate(area.x() + area.width() * 0.5f, 0.0, 0.0); @@ -335,27 +325,6 @@ void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d vbo->render(GL_TRIANGLES); shaderManager->popShader(); - } else { -#ifdef KWIN_HAVE_OPENGL_1 - glPushMatrix(); - QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); - if (effects->numScreens() > 1 && area.x() != fullRect.x()) { - // have to change the reflection area in horizontal layout and right screen - glTranslatef(-area.x(), 0.0, 0.0); - } - glTranslatef(area.x() + area.width() * 0.5f, 0.0, 0.0); - glColor4fv(mirrorColor[0]); - glBegin(GL_POLYGON); - glVertex3f(vertices[0], vertices[1], vertices[2]); - glVertex3f(vertices[3], vertices[4], vertices[5]); - // rearground - glColor4fv(mirrorColor[1]); - glVertex3f(vertices[6], vertices[7], vertices[8]); - glVertex3f(vertices[9], vertices[10], vertices[11]); - glEnd(); - - glPopMatrix(); -#endif } glDisable(GL_SCISSOR_TEST); glDisable(GL_BLEND); @@ -363,20 +332,10 @@ void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d paintScene(frontWindow, leftWindows, rightWindows); if (effects->numScreens() > 1) { - if (shaderManager->isShaderBound()) { - GLShader *shader = shaderManager->pushShader(ShaderManager::GenericShader); - shader->setUniform("projection", origProjection); - shader->setUniform("modelview", origModelview); - shaderManager->popShader(); - } else { -#ifdef KWIN_HAVE_OPENGL_1 - popMatrix(); - // revert change of projection matrix - glMatrixMode(GL_PROJECTION); - popMatrix(); - glMatrixMode(GL_MODELVIEW); -#endif - } + GLShader *shader = shaderManager->pushShader(ShaderManager::GenericShader); + shader->setUniform("projection", origProjection); + shader->setUniform("modelview", origModelview); + shaderManager->popShader(); } // Render the caption frame @@ -727,34 +686,22 @@ void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow, } if (reflectedWindow) { - if (effects->compositingType() == OpenGL2Compositing) { - GLShader *shader = ShaderManager::instance()->pushShader(ShaderManager::GenericShader); - QMatrix4x4 origMatrix = shader->getUniformMatrix4x4("screenTransformation"); - QMatrix4x4 reflectionMatrix; - reflectionMatrix.scale(1.0, -1.0, 1.0); - shader->setUniform("screenTransformation", origMatrix * reflectionMatrix); - data.setYTranslation(- area.height() - windowRect.y() - windowRect.height()); - if (start) { - data.multiplyOpacity(timeLine.currentValue()); - } else if (stop) { - data.multiplyOpacity(1.0 - timeLine.currentValue()); - } - effects->drawWindow(w, - PAINT_WINDOW_TRANSFORMED, - infiniteRegion(), data); - shader->setUniform("screenTransformation", origMatrix); - ShaderManager::instance()->popShader(); - } else { -#ifdef KWIN_HAVE_OPENGL_1 - glPushMatrix(); - glScalef(1.0, -1.0, 1.0); - data.setYTranslation(- area.height() - windowRect.y() - windowRect.height()); - effects->paintWindow(w, - PAINT_WINDOW_TRANSFORMED, - infiniteRegion(), data); - glPopMatrix(); -#endif + GLShader *shader = ShaderManager::instance()->pushShader(ShaderManager::GenericShader); + QMatrix4x4 origMatrix = shader->getUniformMatrix4x4("screenTransformation"); + QMatrix4x4 reflectionMatrix; + reflectionMatrix.scale(1.0, -1.0, 1.0); + shader->setUniform("screenTransformation", origMatrix * reflectionMatrix); + data.setYTranslation(- area.height() - windowRect.y() - windowRect.height()); + if (start) { + data.multiplyOpacity(timeLine.currentValue()); + } else if (stop) { + data.multiplyOpacity(1.0 - timeLine.currentValue()); } + effects->drawWindow(w, + PAINT_WINDOW_TRANSFORMED, + infiniteRegion(), data); + shader->setUniform("screenTransformation", origMatrix); + ShaderManager::instance()->popShader(); } else { effects->paintWindow(w, PAINT_WINDOW_TRANSFORMED, diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 1ef798a9bd..e9fc4dd6a2 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -441,7 +441,6 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) } else { m_reflectionMatrix.translate(0.0, sin(fabs(manualAngle) * M_PI / 360.0f * float(effects->numberOfDesktops())) * addedHeight2 + addedHeight1 - float(rect.height()), 0.0); } - pushMatrix(m_reflectionMatrix); #ifndef KWIN_HAVE_OPENGLES // TODO: find a solution for GLES @@ -453,25 +452,10 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) // cube glCullFace(GL_BACK); - pushMatrix(m_rotationMatrix); paintCube(mask, region, data); - popMatrix(); - - // call the inside cube effects -#ifdef KWIN_HAVE_OPENGL_1 - foreach (CubeInsideEffect * inside, m_cubeInsideEffects) { - pushMatrix(m_rotationMatrix); - glTranslatef(rect.width() / 2, rect.height() / 2, -point - zTranslate); - glRotatef((1 - frontDesktop) * 360.0f / effects->numberOfDesktops(), 0.0, 1.0, 0.0); - inside->paint(); - popMatrix(); - } -#endif glCullFace(GL_FRONT); - pushMatrix(m_rotationMatrix); paintCube(mask, region, data); - popMatrix(); paintCap(false, -point - zTranslate); glDisable(GL_CULL_FACE); @@ -480,7 +464,6 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) // TODO: find a solution for GLES glDisable(GL_CLIP_PLANE0); #endif - popMatrix(); const float width = rect.width(); const float height = rect.height(); @@ -499,7 +482,7 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ShaderManager *shaderManager = ShaderManager::instance(); - if (shaderManager->isValid() && m_reflectionShader && m_reflectionShader->isValid()) { + if (m_reflectionShader && m_reflectionShader->isValid()) { // ensure blending is enabled - no attribute stack ShaderBinder binder(m_reflectionShader); QMatrix4x4 windowTransformation; @@ -526,22 +509,6 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) vbo->reset(); vbo->setData(6, 3, verts.data(), texcoords.data()); vbo->render(GL_TRIANGLES); - } else { -#ifdef KWIN_HAVE_OPENGL_1 - glColor4f(0.0, 0.0, 0.0, alpha); - glPushMatrix(); - glTranslatef(rect.x() + rect.width() * 0.5f, 0.0, 0.0); - glBegin(GL_POLYGON); - glVertex3f(vertices[0], vertices[1], vertices[2]); - glVertex3f(vertices[3], vertices[4], vertices[5]); - // rearground - alpha = -1.0; - glColor4f(0.0, 0.0, 0.0, alpha); - glVertex3f(vertices[6], vertices[7], vertices[8]); - glVertex3f(vertices[9], vertices[10], vertices[11]); - glEnd(); - glPopMatrix(); -#endif } glDisable(GL_BLEND); } @@ -551,26 +518,10 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) // cube glCullFace(GL_FRONT); - pushMatrix(m_rotationMatrix); paintCube(mask, region, data); - popMatrix(); - - - // call the inside cube effects -#ifdef KWIN_HAVE_OPENGL_1 - foreach (CubeInsideEffect * inside, m_cubeInsideEffects) { - pushMatrix(m_rotationMatrix); - glTranslatef(rect.width() / 2, rect.height() / 2, -point - zTranslate); - glRotatef((1 - frontDesktop) * 360.0f / effects->numberOfDesktops(), 0.0, 1.0, 0.0); - inside->paint(); - popMatrix(); - } -#endif glCullFace(GL_BACK); - pushMatrix(m_rotationMatrix); paintCube(mask, region, data); - popMatrix(); // cap paintCap(true, -point - zTranslate); @@ -806,41 +757,6 @@ void CubeEffect::paintCap(bool frontFirst, float zOffset) if (texturedCaps && effects->numberOfDesktops() > 3 && capTexture) { capTexture->bind(); } - } else { -#ifdef KWIN_HAVE_OPENGL_1 - pushMatrix(m_rotationMatrix * capMatrix); - - glMatrixMode(GL_TEXTURE); - pushMatrix(); - loadMatrix(m_textureMirrorMatrix); - glMatrixMode(GL_MODELVIEW); - - glColor4f(capColor.redF(), capColor.greenF(), capColor.blueF(), cubeOpacity); - if (texturedCaps && effects->numberOfDesktops() > 3 && capTexture) { - // modulate the cap texture: cap color should be background for translucent pixels - // cube opacity should be used for all pixels - // blend with cap color - float color[4] = { static_cast(capColor.redF()), static_cast(capColor.greenF()), - static_cast(capColor.blueF()), cubeOpacity }; - glActiveTexture(GL_TEXTURE0); - capTexture->bind(); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - glColor4fv(color); - - // set Opacity to cube opacity - // TODO: change opacity during start/stop animation - glActiveTexture(GL_TEXTURE1); - capTexture->bind(); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_CONSTANT); - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color); - glActiveTexture(GL_TEXTURE0); - glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color); - } -#endif } glEnable(GL_BLEND); @@ -854,14 +770,6 @@ void CubeEffect::paintCap(bool frontFirst, float zOffset) if (capShader) { m_capShader->setUniform("windowTransformation", capMatrix); m_capShader->setUniform("u_mirror", 0); - } else { -#ifndef KWIN_HAVE_OPENGLES - glMatrixMode(GL_TEXTURE); - popMatrix(); - glMatrixMode(GL_MODELVIEW); -#endif - popMatrix(); - pushMatrix(m_rotationMatrix * capMatrix); } glCullFace(secondCull); m_cubeCapBuffer->render(GL_TRIANGLES); @@ -872,18 +780,6 @@ void CubeEffect::paintCap(bool frontFirst, float zOffset) if (texturedCaps && effects->numberOfDesktops() > 3 && capTexture) { capTexture->unbind(); } - } else { - popMatrix(); - if (texturedCaps && effects->numberOfDesktops() > 3 && capTexture) { -#ifndef KWIN_HAVE_OPENGLES - glActiveTexture(GL_TEXTURE1); - glDisable(capTexture->target()); - glActiveTexture(GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glColor4f(0.0f, 0.0f, 0.0f, 0.0f); - capTexture->unbind(); -#endif - } } } @@ -1361,9 +1257,6 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa int next_desktop = painting_desktop + 1; if (next_desktop > effects->numberOfDesktops()) next_desktop = 1; - if (!shader) { - pushMatrix(); - } if (w->isOnDesktop(prev_desktop) && (mask & PAINT_WINDOW_TRANSFORMED)) { QRect rect = effects->clientArea(FullArea, activeScreen, prev_desktop); WindowQuadList new_quads; @@ -1375,17 +1268,6 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa data.quads = new_quads; if (shader) { data.setXTranslation(-rect.width()); - } else { - data.setRotationAxis(Qt::YAxis); - data.setRotationOrigin(QVector3D(rect.width() - w->x(), 0.0, 0.0)); - data.setRotationAngle(-360.0f / effects->numberOfDesktops()); - float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f); - float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f); - QMatrix4x4 matrix; - matrix.translate(rect.width() / 2, 0.0, -point); - matrix.rotate(-360.0f / effects->numberOfDesktops(), 0.0, 1.0, 0.0); - matrix.translate(-rect.width() / 2, 0.0, point); - multiplyMatrix(matrix); } } if (w->isOnDesktop(next_desktop) && (mask & PAINT_WINDOW_TRANSFORMED)) { @@ -1399,17 +1281,6 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa data.quads = new_quads; if (shader) { data.setXTranslation(rect.width()); - } else { - data.setRotationAxis(Qt::YAxis); - data.setRotationOrigin(QVector3D(-w->x(), 0.0, 0.0)); - data.setRotationAngle(-360.0f / effects->numberOfDesktops()); - float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f); - float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f); - QMatrix4x4 matrix; - matrix.translate(rect.width() / 2, 0.0, -point); - matrix.rotate(360.0f / effects->numberOfDesktops(), 0.0, 1.0, 0.0); - matrix.translate(-rect.width() / 2, 0.0, point); - multiplyMatrix(matrix); } } QRect rect = effects->clientArea(FullArea, activeScreen, painting_desktop); @@ -1587,9 +1458,6 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa glDisable(GL_BLEND); } } - if (!shader) { - popMatrix(); - } } } diff --git a/effects/cube/cubeslide.cpp b/effects/cube/cubeslide.cpp index fddb48f264..79a4193b63 100644 --- a/effects/cube/cubeslide.cpp +++ b/effects/cube/cubeslide.cpp @@ -87,13 +87,9 @@ void CubeSlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat if (!slideRotations.empty()) { glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); - pushMatrix(); paintSlideCube(mask, region, data); - popMatrix(); glCullFace(GL_BACK); - pushMatrix(); paintSlideCube(mask, region, data); - popMatrix(); glDisable(GL_CULL_FACE); if (dontSlidePanels) { diff --git a/effects/flipswitch/flipswitch.cpp b/effects/flipswitch/flipswitch.cpp index db652c4ef2..0d1c9a4745 100644 --- a/effects/flipswitch/flipswitch.cpp +++ b/effects/flipswitch/flipswitch.cpp @@ -239,22 +239,12 @@ void FlipSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da projection.frustum(xmin * xminFactor, xmax * xmaxFactor, ymin * yminFactor, ymax * ymaxFactor, zNear, zFar); QMatrix4x4 modelview; modelview.translate(xTranslate, yTranslate, 0.0); - if (effects->compositingType() == OpenGL2Compositing) { - ShaderBinder binder(ShaderManager::GenericShader); - GLShader *shader = binder.shader(); - origProjection = shader->getUniformMatrix4x4("projection"); - origModelview = shader->getUniformMatrix4x4("modelview"); - shader->setUniform("projection", projection); - shader->setUniform("modelview", origModelview * modelview); - } else { -#ifdef KWIN_HAVE_OPENGL_1 - glMatrixMode(GL_PROJECTION); - pushMatrix(); - loadMatrix(projection); - glMatrixMode(GL_MODELVIEW); - pushMatrix(modelview); -#endif - } + ShaderBinder binder(ShaderManager::GenericShader); + GLShader *shader = binder.shader(); + origProjection = shader->getUniformMatrix4x4("projection"); + origModelview = shader->getUniformMatrix4x4("modelview"); + shader->setUniform("projection", projection); + shader->setUniform("modelview", origModelview * modelview); } int winMask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT; @@ -351,20 +341,10 @@ void FlipSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da } if (effects->numScreens() > 1) { - if (effects->compositingType() == OpenGL2Compositing) { - ShaderBinder binder(ShaderManager::GenericShader); - GLShader *shader = binder.shader(); - shader->setUniform("projection", origProjection); - shader->setUniform("modelview", origModelview); - } else { -#ifdef KWIN_HAVE_OPENGL_1 - popMatrix(); - // revert change of projection matrix - glMatrixMode(GL_PROJECTION); - popMatrix(); - glMatrixMode(GL_MODELVIEW); -#endif - } + ShaderBinder binder(ShaderManager::GenericShader); + GLShader *shader = binder.shader(); + shader->setUniform("projection", origProjection); + shader->setUniform("modelview", origModelview); } if (m_windowTitle) { diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index d50293d69d..599efcd215 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -296,10 +296,6 @@ bool LogoutEffect::isLogoutDialog(EffectWindow* w) void LogoutEffect::renderVignetting() { - if (effects->compositingType() == OpenGL1Compositing) { - renderVignettingLegacy(); - return; - } if (!m_vignettingShader) { m_vignettingShader = ShaderManager::instance()->loadFragmentShader(KWin::ShaderManager::ColorShader, QStandardPaths::locate(QStandardPaths::GenericDataLocation, @@ -346,41 +342,8 @@ void LogoutEffect::renderVignetting() glDisable(GL_BLEND); } -void LogoutEffect::renderVignettingLegacy() -{ -#ifdef KWIN_HAVE_OPENGL_1 - glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT); - glEnable(GL_BLEND); // If not already (Such as when rendered straight to the screen) - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - for (int screen = 0; screen < effects->numScreens(); screen++) { - QRect screenGeom = effects->clientArea(ScreenArea, screen, 0); - glScissor(screenGeom.x(), displayHeight() - screenGeom.y() - screenGeom.height(), - screenGeom.width(), screenGeom.height()); // GL coords are flipped - glEnable(GL_SCISSOR_TEST); // Geom must be set before enable - const float cenX = screenGeom.x() + screenGeom.width() / 2; - const float cenY = screenGeom.y() + screenGeom.height() / 2; - const float a = M_PI / 16.0f; // Angle of increment - const float r = float((screenGeom.width() > screenGeom.height()) - ? screenGeom.width() : screenGeom.height()) * 0.8f; // Radius - glBegin(GL_TRIANGLE_FAN); - glColor4f(0.0f, 0.0f, 0.0f, 0.0f); - glVertex3f(cenX, cenY, 0.0f); - glColor4f(0.0f, 0.0f, 0.0f, progress * 0.9f); - for (float i = 0.0f; i <= M_PI * 2.01f; i += a) - glVertex3f(cenX + r * cos(i), cenY + r * sin(i), 0.0f); - glEnd(); - glDisable(GL_SCISSOR_TEST); - } - glPopAttrib(); -#endif -} - void LogoutEffect::renderBlurTexture() { - if (effects->compositingType() == OpenGL1Compositing) { - renderBlurTextureLegacy(); - return; - } if (!m_blurShader) { m_blurShader = ShaderManager::instance()->loadFragmentShader(KWin::ShaderManager::SimpleShader, QStandardPaths::locate(QStandardPaths::GenericDataLocation, @@ -407,31 +370,6 @@ void LogoutEffect::renderBlurTexture() checkGLError("Render blur texture"); } -void LogoutEffect::renderBlurTextureLegacy() -{ -#ifdef KWIN_HAVE_OPENGL_1 - glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT); - // Unmodified base image - blurTexture->bind(); - blurTexture->render(infiniteRegion(), effects->virtualScreenGeometry()); - - // Blurred image - GLfloat bias[1]; - glGetTexEnvfv(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, bias); - glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 1.75); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(1.0f, 1.0f, 1.0f, progress * 0.4); - - blurTexture->render(infiniteRegion(), effects->virtualScreenGeometry()); - - glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, bias[0]); - blurTexture->unbind(); - glPopAttrib(); -#endif -} - void LogoutEffect::slotPropertyNotify(EffectWindow* w, long a) { if (w || a != logoutAtom) diff --git a/effects/logout/logout.h b/effects/logout/logout.h index dee53bc992..073e1a5ff9 100644 --- a/effects/logout/logout.h +++ b/effects/logout/logout.h @@ -70,9 +70,7 @@ private: EffectWindowList ignoredWindows; void renderVignetting(); - void renderVignettingLegacy(); void renderBlurTexture(); - void renderBlurTextureLegacy(); int frameDelay; bool blurSupported, useBlur; GLTexture* blurTexture; diff --git a/effects/mouseclick/mouseclick.cpp b/effects/mouseclick/mouseclick.cpp index dbdcc9dbb1..2a5b0a28a5 100644 --- a/effects/mouseclick/mouseclick.cpp +++ b/effects/mouseclick/mouseclick.cpp @@ -373,9 +373,7 @@ void MouseClickEffect::drawCircleQPainter(const QColor &color, float cx, float c void MouseClickEffect::paintScreenSetupGl(int, QRegion, ScreenPaintData&) { - if (ShaderManager::instance()->isValid()) { - ShaderManager::instance()->pushShader(ShaderManager::ColorShader); - } + ShaderManager::instance()->pushShader(ShaderManager::ColorShader); glLineWidth(m_lineWidth); glEnable(GL_BLEND); @@ -386,9 +384,7 @@ void MouseClickEffect::paintScreenFinishGl(int, QRegion, ScreenPaintData&) { glDisable(GL_BLEND); - if (ShaderManager::instance()->isValid()) { - ShaderManager::instance()->popShader(); - } + ShaderManager::instance()->popShader(); } } // namespace diff --git a/effects/screenedge/screenedgeeffect.cpp b/effects/screenedge/screenedgeeffect.cpp index f38c92bd0d..1db6483e07 100644 --- a/effects/screenedge/screenedgeeffect.cpp +++ b/effects/screenedge/screenedgeeffect.cpp @@ -91,18 +91,10 @@ void ScreenEdgeEffect::paintScreen(int mask, QRegion region, ScreenPaintData &da glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); texture->bind(); - if (effects->compositingType() == OpenGL2Compositing) { - ShaderBinder binder(ShaderManager::SimpleShader); - const QVector4D constant(opacity, opacity, opacity, opacity); - binder.shader()->setUniform(GLShader::ModulationConstant, constant); - texture->render(infiniteRegion(), (*it)->geometry); - } else if (effects->compositingType() == OpenGL1Compositing) { -#ifdef KWIN_HAVE_OPENGL_1 - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glColor4f(1.0, 1.0, 1.0, opacity); - texture->render(infiniteRegion(), (*it)->geometry); -#endif - } + ShaderBinder binder(ShaderManager::SimpleShader); + const QVector4D constant(opacity, opacity, opacity, opacity); + binder.shader()->setUniform(GLShader::ModulationConstant, constant); + texture->render(infiniteRegion(), (*it)->geometry); texture->unbind(); glDisable(GL_BLEND); } else if (effects->compositingType() == XRenderCompositing) { diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp index f0a36887a7..0d3333ad42 100644 --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -187,40 +187,20 @@ void ScreenShotEffect::setMatrix(int width, int height) QMatrix4x4 projection; QMatrix4x4 identity; projection.ortho(QRect(0, 0, width, height)); - if (effects->compositingType() == OpenGL2Compositing) { - ShaderBinder binder(ShaderManager::GenericShader); - GLShader *shader = binder.shader(); - s_origProjection = shader->getUniformMatrix4x4("projection"); - s_origModelview = shader->getUniformMatrix4x4("modelview"); - shader->setUniform(GLShader::ProjectionMatrix, projection); - shader->setUniform(GLShader::ModelViewMatrix, identity); - } else if (effects->compositingType() == OpenGL1Compositing) { -#ifdef KWIN_HAVE_OPENGL_1 - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - loadMatrix(projection); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); -#endif - } + ShaderBinder binder(ShaderManager::GenericShader); + GLShader *shader = binder.shader(); + s_origProjection = shader->getUniformMatrix4x4("projection"); + s_origModelview = shader->getUniformMatrix4x4("modelview"); + shader->setUniform(GLShader::ProjectionMatrix, projection); + shader->setUniform(GLShader::ModelViewMatrix, identity); } void ScreenShotEffect::restoreMatrix() { - if (effects->compositingType() == OpenGL2Compositing) { - ShaderBinder binder(ShaderManager::GenericShader); - GLShader *shader = binder.shader(); - shader->setUniform(GLShader::ProjectionMatrix, s_origProjection); - shader->setUniform(GLShader::ModelViewMatrix, s_origModelview); - } else if (effects->compositingType() == OpenGL1Compositing) { -#ifdef KWIN_HAVE_OPENGL_1 - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); -#endif - } + ShaderBinder binder(ShaderManager::GenericShader); + GLShader *shader = binder.shader(); + shader->setUniform(GLShader::ProjectionMatrix, s_origProjection); + shader->setUniform(GLShader::ModelViewMatrix, s_origModelview); } void ScreenShotEffect::screenshotWindowUnderCursor(int mask) diff --git a/effects/startupfeedback/startupfeedback.cpp b/effects/startupfeedback/startupfeedback.cpp index ea3a468e5e..120c826282 100644 --- a/effects/startupfeedback/startupfeedback.cpp +++ b/effects/startupfeedback/startupfeedback.cpp @@ -192,26 +192,8 @@ void StartupFeedbackEffect::paintScreen(int mask, QRegion region, ScreenPaintDat useShader = true; ShaderManager::instance()->pushShader(m_blinkingShader); m_blinkingShader->setUniform("u_color", blinkingColor); - } else { -#ifdef KWIN_HAVE_OPENGL_1 - // texture transformation - float color[4] = { static_cast(blinkingColor.redF()), static_cast(blinkingColor.greenF()), - static_cast(blinkingColor.blueF()), 1.0f }; - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - glColor4fv(color); - glActiveTexture(GL_TEXTURE1); - texture->bind(); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_CONSTANT); - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color); - glActiveTexture(GL_TEXTURE0); - glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color); -#endif } - } else if (effects->compositingType() == OpenGL2Compositing) { + } else { useShader = true; ShaderManager::instance()->pushShader(ShaderManager::SimpleShader); } @@ -219,16 +201,6 @@ void StartupFeedbackEffect::paintScreen(int mask, QRegion region, ScreenPaintDat if (useShader) { ShaderManager::instance()->popShader(); } - if (m_type == BlinkingFeedback && !useShader) { -#ifdef KWIN_HAVE_OPENGL_1 - // resture states - glActiveTexture(GL_TEXTURE1); - texture->unbind(); - glActiveTexture(GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glColor4f(0.0f, 0.0f, 0.0f, 0.0f); -#endif - } texture->unbind(); glDisable(GL_BLEND); } diff --git a/effects/trackmouse/trackmouse.cpp b/effects/trackmouse/trackmouse.cpp index 77da7b4cd6..8cade77ac6 100644 --- a/effects/trackmouse/trackmouse.cpp +++ b/effects/trackmouse/trackmouse.cpp @@ -124,10 +124,11 @@ void TrackMouseEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da if ( effects->isOpenGLCompositing() && m_texture[0] && m_texture[1]) { ShaderBinder binder(ShaderManager::GenericShader); GLShader *shader(binder.shader()); - QMatrix4x4 modelview; - if (shader) { - modelview = shader->getUniformMatrix4x4("modelview"); + if (!shader) { + return; } + QMatrix4x4 modelview; + modelview = shader->getUniformMatrix4x4("modelview"); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); QMatrix4x4 matrix(modelview); @@ -136,22 +137,15 @@ void TrackMouseEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da matrix.translate(p.x(), p.y(), 0.0); matrix.rotate(i ? -2*m_angle : m_angle, 0, 0, 1.0); matrix.translate(-p.x(), -p.y(), 0.0); - if (shader) { - shader->setUniform(GLShader::ModelViewMatrix, matrix); - shader->setUniform(GLShader::Saturation, 1.0); - shader->setUniform(GLShader::ModulationConstant, QVector4D(1.0, 1.0, 1.0, 1.0)); - } else - pushMatrix(matrix); + shader->setUniform(GLShader::ModelViewMatrix, matrix); + shader->setUniform(GLShader::Saturation, 1.0); + shader->setUniform(GLShader::ModulationConstant, QVector4D(1.0, 1.0, 1.0, 1.0)); m_texture[i]->bind(); m_texture[i]->render(region, m_lastRect[i]); m_texture[i]->unbind(); - if (!shader) - popMatrix(); } glDisable(GL_BLEND); - if (shader) { - shader->setUniform(GLShader::ModelViewMatrix, modelview); - } + shader->setUniform(GLShader::ModelViewMatrix, modelview); } #ifdef KWIN_HAVE_XRENDER_COMPOSITING if ( effects->compositingType() == XRenderCompositing && m_picture[0] && m_picture[1]) { diff --git a/glxbackend.cpp b/glxbackend.cpp index 6944dfdf84..fb53c1d2ec 100644 --- a/glxbackend.cpp +++ b/glxbackend.cpp @@ -702,18 +702,14 @@ bool GlxTexture::loadTexture(const Pixmap& pix, const QSize& size, int depth) GLX_MIPMAP_TEXTURE_EXT, m_backend->fbcdrawableinfo[ depth ].mipmap > 0, None, None, None }; - // Specifying the texture target explicitly is reported to cause a performance - // regression with R300G (see bug #256654). - if (GLPlatform::instance()->driver() != Driver_R300G) { - if ((m_backend->fbcdrawableinfo[ depth ].texture_targets & GLX_TEXTURE_2D_BIT_EXT) && - (GLTexture::NPOTTextureSupported() || - (isPowerOfTwo(size.width()) && isPowerOfTwo(size.height())))) { - attrs[ 4 ] = GLX_TEXTURE_TARGET_EXT; - attrs[ 5 ] = GLX_TEXTURE_2D_EXT; - } else if (m_backend->fbcdrawableinfo[ depth ].texture_targets & GLX_TEXTURE_RECTANGLE_BIT_EXT) { - attrs[ 4 ] = GLX_TEXTURE_TARGET_EXT; - attrs[ 5 ] = GLX_TEXTURE_RECTANGLE_EXT; - } + if ((m_backend->fbcdrawableinfo[ depth ].texture_targets & GLX_TEXTURE_2D_BIT_EXT) && + (GLTexture::NPOTTextureSupported() || + (isPowerOfTwo(size.width()) && isPowerOfTwo(size.height())))) { + attrs[ 4 ] = GLX_TEXTURE_TARGET_EXT; + attrs[ 5 ] = GLX_TEXTURE_2D_EXT; + } else if (m_backend->fbcdrawableinfo[ depth ].texture_targets & GLX_TEXTURE_RECTANGLE_BIT_EXT) { + attrs[ 4 ] = GLX_TEXTURE_TARGET_EXT; + attrs[ 5 ] = GLX_TEXTURE_RECTANGLE_EXT; } m_glxpixmap = glXCreatePixmap(display(), m_backend->fbcdrawableinfo[ depth ].fbconfig, pix, attrs); #ifdef CHECK_GL_ERROR diff --git a/libkwineffects/CMakeLists.txt b/libkwineffects/CMakeLists.txt index 45b4e22b1a..b14c862635 100644 --- a/libkwineffects/CMakeLists.txt +++ b/libkwineffects/CMakeLists.txt @@ -68,10 +68,6 @@ if(KWIN_BUILD_OPENGL) kwin4_add_glutils_backend(kwinglutils ${OPENGL_INCLUDE_DIR} ${OPENGL_gl_LIBRARY}) set_target_properties(kwinglutils PROPERTIES OUTPUT_NAME ${KWIN_NAME}glutils) - if( KWIN_BUILD_OPENGL_1_COMPOSITING ) - set_target_properties(kwinglutils PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGL_1) - endif() - target_link_libraries(kwinglutils PUBLIC ${OPENGL_gl_LIBRARY}) # -ldl used by OpenGL code find_library(DL_LIBRARY dl) diff --git a/libkwineffects/kwinglobals.h b/libkwineffects/kwinglobals.h index a9f2dd3cdd..a45ff63fa9 100644 --- a/libkwineffects/kwinglobals.h +++ b/libkwineffects/kwinglobals.h @@ -41,14 +41,13 @@ enum CompositingType { /** * Used as a flag whether OpenGL based compositing is used. * The flag is or-ed to the enum values of the specific OpenGL types. - * The actual Compositors use the @c OpenGL1Compositing or @c OpenGL2Compositing + * The actual Compositors use the or @c OpenGL2Compositing * flags. If you need to know whether OpenGL is used, either and the flag or * use EffectsHandler::isOpenGLCompositing(). **/ OpenGLCompositing = 1, XRenderCompositing = 1<<1, QPainterCompositing = 1<< 2, - OpenGL1Compositing = 1<<2 | OpenGLCompositing, OpenGL2Compositing = 1<<3 | OpenGLCompositing }; diff --git a/libkwineffects/kwinglplatform.cpp b/libkwineffects/kwinglplatform.cpp index 7349cc36f2..83c1c475bf 100644 --- a/libkwineffects/kwinglplatform.cpp +++ b/libkwineffects/kwinglplatform.cpp @@ -778,8 +778,8 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) // fallback to XRender for R100 and R200 m_recommendedCompositor = XRenderCompositing; } else if (m_chipClass < R600) { - // OpenGL 1 due to NPOT limitations not supported by KWin's shaders - m_recommendedCompositor = OpenGL1Compositing; + // XRender due to NPOT limitations not supported by KWin's shaders + m_recommendedCompositor = XRenderCompositing; } else { m_recommendedCompositor = OpenGL2Compositing; } @@ -799,10 +799,8 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) m_preferBufferSubData = true; } - if (m_chipClass < NV20) { + if (m_chipClass < NV40) { m_recommendedCompositor = XRenderCompositing; - } else if (m_chipClass < NV40) { - m_recommendedCompositor = OpenGL1Compositing; } else { m_recommendedCompositor = OpenGL2Compositing; } @@ -819,7 +817,7 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) m_looseBinding = true; if (m_chipClass < I965) { - m_recommendedCompositor = OpenGL1Compositing; + m_recommendedCompositor = XRenderCompositing; } else { m_recommendedCompositor = OpenGL2Compositing; } diff --git a/libkwineffects/kwingltexture.cpp b/libkwineffects/kwingltexture.cpp index f34af9c909..c79a178061 100644 --- a/libkwineffects/kwingltexture.cpp +++ b/libkwineffects/kwingltexture.cpp @@ -301,10 +301,6 @@ void GLTexture::discard() void GLTexturePrivate::bind() { -#ifdef KWIN_HAVE_OPENGL_1 - if (!ShaderManager::instance()->isValid()) - glEnable(m_target); -#endif glBindTexture(m_target, m_texture); } @@ -351,10 +347,6 @@ void GLTexture::bind() void GLTexturePrivate::unbind() { glBindTexture(m_target, 0); -#ifdef KWIN_HAVE_OPENGL_1 - if (!ShaderManager::instance()->isValid()) - glDisable(m_target); -#endif } void GLTexture::unbind() @@ -397,20 +389,11 @@ void GLTexture::render(QRegion region, const QRect& rect, bool hardwareClipping) } QMatrix4x4 translation; translation.translate(rect.x(), rect.y()); - if (ShaderManager::instance()->isShaderBound()) { - GLShader *shader = ShaderManager::instance()->getBoundShader(); - shader->setUniform(GLShader::Offset, QVector2D(rect.x(), rect.y())); - shader->setUniform(GLShader::WindowTransformation, translation); - } else { - pushMatrix(translation); - } + GLShader *shader = ShaderManager::instance()->getBoundShader(); + shader->setUniform(GLShader::Offset, QVector2D(rect.x(), rect.y())); + shader->setUniform(GLShader::WindowTransformation, translation); d->m_vbo->render(region, GL_TRIANGLE_STRIP, hardwareClipping); - if (ShaderManager::instance()->isShaderBound()) { - GLShader *shader = ShaderManager::instance()->getBoundShader(); - shader->setUniform(GLShader::WindowTransformation, QMatrix4x4()); - } else { - popMatrix(); - } + shader->setUniform(GLShader::WindowTransformation, QMatrix4x4()); } GLuint GLTexture::texture() const diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp index 928acd47db..23b225ac7e 100644 --- a/libkwineffects/kwinglutils.cpp +++ b/libkwineffects/kwinglutils.cpp @@ -204,78 +204,6 @@ int nearestPowerOfTwo(int x) return 1 << last; } -void pushMatrix() -{ -#ifdef KWIN_HAVE_OPENGL_1 - if (ShaderManager::instance()->isValid()) { - return; - } - glPushMatrix(); -#endif -} - -void pushMatrix(const QMatrix4x4 &matrix) -{ -#ifndef KWIN_HAVE_OPENGL_1 - Q_UNUSED(matrix) -#else - if (ShaderManager::instance()->isValid()) { - return; - } - glPushMatrix(); - multiplyMatrix(matrix); -#endif -} - -void multiplyMatrix(const QMatrix4x4 &matrix) -{ -#ifndef KWIN_HAVE_OPENGL_1 - Q_UNUSED(matrix) -#else - if (ShaderManager::instance()->isValid()) { - return; - } - GLfloat m[16]; - const auto *data = matrix.constData(); - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - m[i*4+j] = data[i*4+j]; - } - } - glMultMatrixf(m); -#endif -} - -void loadMatrix(const QMatrix4x4 &matrix) -{ -#ifndef KWIN_HAVE_OPENGL_1 - Q_UNUSED(matrix) -#else - if (ShaderManager::instance()->isValid()) { - return; - } - GLfloat m[16]; - const auto *data = matrix.constData(); - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - m[i*4+j] = data[i*4+j]; - } - } - glLoadMatrixf(m); -#endif -} - -void popMatrix() -{ -#ifdef KWIN_HAVE_OPENGL_1 - if (ShaderManager::instance()->isValid()) { - return; - } - glPopMatrix(); -#endif -} - - //**************************************** // GLShader //**************************************** @@ -698,17 +626,6 @@ ShaderManager *ShaderManager::instance() return s_shaderManager; } -void ShaderManager::disable() -{ - // for safety do a Cleanup first - ShaderManager::cleanup(); - - // create a new ShaderManager and set it to inited without calling init - // that will ensure that the ShaderManager is not valid - s_shaderManager = new ShaderManager(); - s_shaderManager->m_inited = true; -} - void ShaderManager::cleanup() { delete s_shaderManager; @@ -1576,8 +1493,7 @@ public: , nextOffset(0) , baseAddress(0) { - if (GLVertexBufferPrivate::supported) - glGenBuffers(1, &buffer); + glGenBuffers(1, &buffer); switch(usageHint) { case GLVertexBuffer::Dynamic: @@ -1593,8 +1509,7 @@ public: } ~GLVertexBufferPrivate() { - if (GLVertexBufferPrivate::supported) - glDeleteBuffers(1, &buffer); + glDeleteBuffers(1, &buffer); } void interleaveArrays(float *array, int dim, const float *vertices, const float *texcoords, int count); @@ -1607,7 +1522,6 @@ public: GLenum usage; int stride; int vertexCount; - static bool supported; static GLVertexBuffer *streamingBuffer; static bool hasMapBufferRange; static bool supportsIndexedQuads; @@ -1625,7 +1539,6 @@ public: #endif }; -bool GLVertexBufferPrivate::supported = false; bool GLVertexBufferPrivate::hasMapBufferRange = false; bool GLVertexBufferPrivate::supportsIndexedQuads = false; GLVertexBuffer *GLVertexBufferPrivate::streamingBuffer = nullptr; @@ -1676,63 +1589,27 @@ void GLVertexBufferPrivate::interleaveArrays(float *dst, int dim, void GLVertexBufferPrivate::bindArrays() { -#ifndef KWIN_HAVE_OPENGLES - if (ShaderManager::instance()->isShaderBound()) { -#endif - if (useColor) { - GLShader *shader = ShaderManager::instance()->getBoundShader(); - shader->setUniform(GLShader::Color, color); - } - - glBindBuffer(GL_ARRAY_BUFFER, buffer); - - BitfieldIterator it(enabledArrays); - while (it.hasNext()) { - const int index = it.next(); - glVertexAttribPointer(index, attrib[index].size, attrib[index].type, GL_FALSE, stride, - (const GLvoid *) (baseAddress + attrib[index].offset)); - glEnableVertexAttribArray(index); - } -#ifndef KWIN_HAVE_OPENGLES - } else { - if (GLVertexBufferPrivate::supported) - glBindBuffer(GL_ARRAY_BUFFER, buffer); - - // FIXME Is there any good reason to not leave this array permanently enabled? - // When do we not use it in the GL 1.x path? - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(attrib[VA_Position].size, attrib[VA_Position].type, stride, - (const GLvoid *) (baseAddress + attrib[VA_Position].offset)); - - if (enabledArrays[VA_TexCoord]) { - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(attrib[VA_TexCoord].size, attrib[VA_TexCoord].type, stride, - (const GLvoid *) (baseAddress + attrib[VA_TexCoord].offset)); - } - - if (useColor) - glColor4f(color.x(), color.y(), color.z(), color.w()); + if (useColor) { + GLShader *shader = ShaderManager::instance()->getBoundShader(); + shader->setUniform(GLShader::Color, color); + } + + glBindBuffer(GL_ARRAY_BUFFER, buffer); + + BitfieldIterator it(enabledArrays); + while (it.hasNext()) { + const int index = it.next(); + glVertexAttribPointer(index, attrib[index].size, attrib[index].type, GL_FALSE, stride, + (const GLvoid *) (baseAddress + attrib[index].offset)); + glEnableVertexAttribArray(index); } -#endif } void GLVertexBufferPrivate::unbindArrays() { -#ifndef KWIN_HAVE_OPENGLES - if (ShaderManager::instance()->isShaderBound()) { -#endif - BitfieldIterator it(enabledArrays); - while (it.hasNext()) - glDisableVertexAttribArray(it.next()); -#ifndef KWIN_HAVE_OPENGLES - } else { - // Assume that the conventional arrays were enabled - glDisableClientState(GL_VERTEX_ARRAY); - - if (enabledArrays[VA_TexCoord]) - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } -#endif + BitfieldIterator it(enabledArrays); + while (it.hasNext()) + glDisableVertexAttribArray(it.next()); } void GLVertexBufferPrivate::reallocateBuffer(size_t size) @@ -1808,8 +1685,7 @@ GLvoid *GLVertexBuffer::map(size_t size) { d->mappedSize = size; - if (GLVertexBufferPrivate::supported) - glBindBuffer(GL_ARRAY_BUFFER, d->buffer); + glBindBuffer(GL_ARRAY_BUFFER, d->buffer); bool preferBufferSubData = GLPlatform::instance()->preferBufferSubData(); @@ -1834,7 +1710,7 @@ void GLVertexBuffer::unmap() d->baseAddress = d->nextOffset; d->nextOffset += align(d->mappedSize, 16); // Align to 16 bytes for SSE - } else if (GLVertexBufferPrivate::supported) { + } else { // Upload the data from local memory to the buffer object if (preferBufferSubData) { if ((d->nextOffset + d->mappedSize) > d->bufferSize) { @@ -1855,10 +1731,6 @@ void GLVertexBuffer::unmap() if (d->usage == GL_STATIC_DRAW) d->dataStore = QByteArray(); - } else { - // If buffer objects aren't supported we just need to update - // the client memory pointer and we're done. - d->baseAddress = intptr_t(d->dataStore.data()); } d->mappedSize = 0; @@ -1955,11 +1827,6 @@ void GLVertexBuffer::draw(const QRegion ®ion, GLenum primitiveMode, int first } } -bool GLVertexBuffer::isSupported() -{ - return GLVertexBufferPrivate::supported; -} - bool GLVertexBuffer::supportsIndexedQuads() { return GLVertexBufferPrivate::supportsIndexedQuads; @@ -1991,11 +1858,9 @@ void GLVertexBuffer::reset() void GLVertexBuffer::initStatic() { #ifdef KWIN_HAVE_OPENGLES - GLVertexBufferPrivate::supported = true; GLVertexBufferPrivate::hasMapBufferRange = hasGLExtension(QStringLiteral("GL_EXT_map_buffer_range")); GLVertexBufferPrivate::supportsIndexedQuads = false; #else - GLVertexBufferPrivate::supported = hasGLVersion(1, 5) || hasGLExtension(QStringLiteral("GL_ARB_vertex_buffer_object")); GLVertexBufferPrivate::hasMapBufferRange = hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_map_buffer_range")); GLVertexBufferPrivate::supportsIndexedQuads = glMapBufferRange && glCopyBufferSubData && glDrawElementsBaseVertex; GLVertexBufferPrivate::s_indexBuffer = nullptr; diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h index 63e0d2a3b0..f41506ec1e 100644 --- a/libkwineffects/kwinglutils.h +++ b/libkwineffects/kwinglutils.h @@ -83,48 +83,6 @@ inline bool KWINGLUTILS_EXPORT isPowerOfTwo(int x) **/ int KWINGLUTILS_EXPORT nearestPowerOfTwo(int x); -/** - * Push a new matrix on the GL matrix stack. - * In GLES this method is a noop. This method should be preferred over glPushMatrix - * as it also handles GLES. - * @since 4.7 - **/ -KWINGLUTILS_EXPORT void pushMatrix(); -/** - * Multiplies current matrix on GL stack with @p matrix and pushes the result on the matrix stack. - * This method is the same as pushMatrix followed by multiplyMatrix. - * In GLES this method is a noop. This method should be preferred over glPushMatrix - * as it also handles GLES. - * @param matrix The matrix the current matrix on the stack should be multiplied with. - * @see pushMatrix - * @see multiplyMatrix - * @since 4.7 - **/ -KWINGLUTILS_EXPORT void pushMatrix(const QMatrix4x4 &matrix); -/** - * Multiplies the current matrix on GL stack with @p matrix. - * In GLES this method is a noop. This method should be preferred over glMultMatrix - * as it also handles GLES. - * @param matrix The matrix the current matrix on the stack should be multiplied with. - * @since 4.7 - **/ -KWINGLUTILS_EXPORT void multiplyMatrix(const QMatrix4x4 &matrix); -/** - * Replaces the current matrix on GL stack with @p matrix. - * In GLES this method is a no-op. This method should be preferred over glLoadMatrix - * as it also handles GLES. - * @param matrix The new matrix to replace the existing one on the GL stack. - * @since 4.7 - **/ -KWINGLUTILS_EXPORT void loadMatrix(const QMatrix4x4 &matrix); -/** - * Pops the current matrix from the GL matrix stack. - * In GLES this method is a noop. This method should be preferred over glPopMatrix - * as it also handles GLES. - * @since 4.7 - **/ -KWINGLUTILS_EXPORT void popMatrix(); - class KWINGLUTILS_EXPORT GLShader { public: @@ -304,10 +262,6 @@ public: * Allows to query whether Shaders are supported by the compositor, that is * whether the Shaders compiled successfully. * - * With OpenGL 1 compositing this method will always return @c false. - * - * Do not use this method to check whether the compositor uses OpenGL 1 or 2, - * use @link EffectsHandler::compositingType instead. * @return @c true if the built-in shaders are valid, @c false otherwise **/ bool isValid() const; @@ -386,15 +340,6 @@ public: * @return a pointer to the ShaderManager instance **/ static ShaderManager *instance(); - /** - * @brief Ensures that the ShaderManager is disabled. - * - * Used only by an OpenGL 1 Scene which does not use OpenGL 2 Shaders. - * - * @internal - * @since 4.10 - **/ - static void disable(); /** * @internal @@ -433,9 +378,6 @@ private: * // here the Shader is automatically popped as helper does no longer exist. * @endcode * - * This class takes care for the case that the Compositor uses OpenGL 1 and the ShaderManager is - * not valid. In that case the helper does not do anything. So this helper can be used to simplify - * the code to remove checks for OpenGL 1/2. * @since 4.10 **/ class KWINGLUTILS_EXPORT ShaderBinder @@ -459,7 +401,7 @@ public: ~ShaderBinder(); /** - * @return The Shader pushed to the Stack. On OpenGL 1 this returns a @c null pointer. + * @return The Shader pushed to the Stack. **/ GLShader *shader(); @@ -471,11 +413,6 @@ inline ShaderBinder::ShaderBinder(ShaderManager::ShaderType type, bool reset) : m_shader(nullptr) { -#ifdef KWIN_HAVE_OPENGL_1 - if (!ShaderManager::instance()->isValid()) { - return; - } -#endif m_shader = ShaderManager::instance()->pushShader(type, reset); } @@ -483,22 +420,12 @@ inline ShaderBinder::ShaderBinder(GLShader *shader) : m_shader(shader) { -#ifdef KWIN_HAVE_OPENGL_1 - if (!ShaderManager::instance()->isValid()) { - return; - } -#endif ShaderManager::instance()->pushShader(shader); } inline ShaderBinder::~ShaderBinder() { -#ifdef KWIN_HAVE_OPENGL_1 - if (!ShaderManager::instance()->isValid()) { - return; - } -#endif ShaderManager::instance()->popShader(); } @@ -792,13 +719,6 @@ public: */ static void cleanup(); - /** - * Returns true if VBOs are supported, it is save to use this class even if VBOs are not - * supported. - * @returns true if vertex buffer objects are supported - */ - static bool isSupported(); - /** * Returns true if indexed quad mode is supported, and false otherwise. */ diff --git a/options.cpp b/options.cpp index f6eae0f3c7..dc839e14ac 100644 --- a/options.cpp +++ b/options.cpp @@ -145,7 +145,6 @@ Options::Options(QObject *parent) , m_vBlankTime(Options::defaultVBlankTime()) , m_glStrictBinding(Options::defaultGlStrictBinding()) , m_glStrictBindingFollowsDriver(Options::defaultGlStrictBindingFollowsDriver()) - , m_glLegacy(Options::defaultGlLegacy()) , m_glCoreProfile(Options::defaultGLCoreProfile()) , m_glPreferBufferSwap(Options::defaultGlPreferBufferSwap()) , OpTitlebarDblClick(Options::defaultOperationTitlebarDblClick()) @@ -724,15 +723,6 @@ void Options::setGlStrictBindingFollowsDriver(bool glStrictBindingFollowsDriver) emit glStrictBindingFollowsDriverChanged(); } -void Options::setGlLegacy(bool glLegacy) -{ - if (m_glLegacy == glLegacy) { - return; - } - m_glLegacy = glLegacy; - emit glLegacyChanged(); -} - void Options::setGLCoreProfile(bool value) { if (m_glCoreProfile == value) { @@ -940,7 +930,6 @@ void Options::reloadCompositingSettings(bool force) if (!isGlStrictBindingFollowsDriver()) { setGlStrictBinding(config.readEntry("GLStrictBinding", Options::defaultGlStrictBinding())); } - setGlLegacy(config.readEntry("GLLegacy", Options::defaultGlLegacy())); setGLCoreProfile(config.readEntry("GLCore", Options::defaultGLCoreProfile())); char c = 0; diff --git a/options.h b/options.h index 48ce693681..6273ef9bdd 100644 --- a/options.h +++ b/options.h @@ -187,10 +187,6 @@ class Options : public KDecorationOptions * If @c false @link glStrictBinding is set from a config value and not updated during scene initialization. **/ Q_PROPERTY(bool glStrictBindingFollowsDriver READ isGlStrictBindingFollowsDriver WRITE setGlStrictBindingFollowsDriver NOTIFY glStrictBindingFollowsDriverChanged) - /** - * Whether legacy OpenGL should be used or OpenGL (ES) 2 - **/ - Q_PROPERTY(bool glLegacy READ isGlLegacy WRITE setGlLegacy NOTIFY glLegacyChanged) Q_PROPERTY(bool glCoreProfile READ glCoreProfile WRITE setGLCoreProfile NOTIFY glCoreProfileChanged) Q_PROPERTY(GlSwapStrategy glPreferBufferSwap READ glPreferBufferSwap WRITE setGlPreferBufferSwap NOTIFY glPreferBufferSwapChanged) public: @@ -541,9 +537,6 @@ public: bool isGlStrictBindingFollowsDriver() const { return m_glStrictBindingFollowsDriver; } - bool isGlLegacy() const { - return m_glLegacy; - } bool glCoreProfile() const { return m_glCoreProfile; } @@ -610,7 +603,6 @@ public: void setVBlankTime(qint64 vBlankTime); void setGlStrictBinding(bool glStrictBinding); void setGlStrictBindingFollowsDriver(bool glStrictBindingFollowsDriver); - void setGlLegacy(bool glLegacy); void setGLCoreProfile(bool glCoreProfile); void setGlPreferBufferSwap(char glPreferBufferSwap); @@ -714,9 +706,6 @@ public: static bool defaultGlStrictBindingFollowsDriver() { return true; } - static bool defaultGlLegacy() { - return false; - } static bool defaultGLCoreProfile() { return false; } @@ -798,7 +787,6 @@ Q_SIGNALS: void vBlankTimeChanged(); void glStrictBindingChanged(); void glStrictBindingFollowsDriverChanged(); - void glLegacyChanged(); void glCoreProfileChanged(); void glPreferBufferSwapChanged(); @@ -847,7 +835,6 @@ private: qint64 m_vBlankTime; bool m_glStrictBinding; bool m_glStrictBindingFollowsDriver; - bool m_glLegacy; bool m_glCoreProfile; GlSwapStrategy m_glPreferBufferSwap; diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 5a51a8804d..20f1afd9bf 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -254,15 +254,6 @@ SceneOpenGL *SceneOpenGL::createScene() return scene; } } -#ifdef KWIN_HAVE_OPENGL_1 - if (SceneOpenGL1::supported(backend)) { - scene = new SceneOpenGL1(backend); - if (scene->initFailed()) { - delete scene; - scene = NULL; - } - } -#endif if (!scene) { if (GLPlatform::instance()->recommendedCompositor() == XRenderCompositing) { qCritical() << "OpenGL driver recommends XRender based compositing. Falling back to XRender."; @@ -622,10 +613,6 @@ bool SceneOpenGL2::supported(OpenGLBackend *backend) return false; #endif } - if (options->isGlLegacy()) { - qDebug() << "OpenGL 2 disabled by config option"; - return false; - } return true; } @@ -778,116 +765,6 @@ void SceneOpenGL2::slotColorCorrectedChanged(bool recreateShaders) Compositor::self()->addRepaintFull(); } - -//**************************************** -// SceneOpenGL1 -//**************************************** -#ifdef KWIN_HAVE_OPENGL_1 -bool SceneOpenGL1::supported(OpenGLBackend *backend) -{ - Q_UNUSED(backend) - const QByteArray forceEnv = qgetenv("KWIN_COMPOSE"); - if (!forceEnv.isEmpty()) { - if (qstrcmp(forceEnv, "O1") == 0) { - qDebug() << "OpenGL 1 compositing enforced by environment variable"; - return true; - } else { - // OpenGL 1 disabled by environment variable - return false; - } - } - if (GLPlatform::instance()->recommendedCompositor() < OpenGL1Compositing) { - qDebug() << "Driver does not recommend OpenGL 1 compositing"; - return false; - } - return true; -} - -SceneOpenGL1::SceneOpenGL1(OpenGLBackend *backend) - : SceneOpenGL(Workspace::self(), backend) - , m_resetModelViewProjectionMatrix(true) -{ - if (!init_ok) { - // base ctor already failed - return; - } - ShaderManager::disable(); - setupModelViewProjectionMatrix(); - if (checkGLError("Init")) { - qCritical() << "OpenGL 1 compositing setup failed"; - init_ok = false; - return; // error - } - - qDebug() << "OpenGL 1 compositing successfully initialized"; -} - -SceneOpenGL1::~SceneOpenGL1() -{ -} - -qint64 SceneOpenGL1::paint(QRegion damage, ToplevelList windows) -{ - if (m_resetModelViewProjectionMatrix) { - // reset model view projection matrix if required - setupModelViewProjectionMatrix(); - } - return SceneOpenGL::paint(damage, windows); -} - -void SceneOpenGL1::paintGenericScreen(int mask, ScreenPaintData data) -{ - pushMatrix(transformation(mask, data)); - Scene::paintGenericScreen(mask, data); - popMatrix(); -} - -void SceneOpenGL1::doPaintBackground(const QVector< float >& vertices) -{ - GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); - vbo->reset(); - vbo->setUseColor(true); - vbo->setData(vertices.count() / 2, 2, vertices.data(), NULL); - vbo->render(GL_TRIANGLES); -} - -void SceneOpenGL1::setupModelViewProjectionMatrix() -{ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - float fovy = 60.0f; - float aspect = 1.0f; - float zNear = 0.1f; - float zFar = 100.0f; - float ymax = zNear * tan(fovy * M_PI / 360.0f); - float ymin = -ymax; - float xmin = ymin * aspect; - float xmax = ymax * aspect; - // swap top and bottom to have OpenGL coordinate system match X system - glFrustum(xmin, xmax, ymin, ymax, zNear, zFar); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - float scaleFactor = 1.1 * tan(fovy * M_PI / 360.0f) / ymax; - glTranslatef(xmin * scaleFactor, ymax * scaleFactor, -1.1); - glScalef((xmax - xmin)*scaleFactor / displayWidth(), -(ymax - ymin)*scaleFactor / displayHeight(), 0.001); - m_resetModelViewProjectionMatrix = false; -} - -void SceneOpenGL1::screenGeometryChanged(const QSize &size) -{ - SceneOpenGL::screenGeometryChanged(size); - m_resetModelViewProjectionMatrix = true; -} - -Scene::Window *SceneOpenGL1::createWindow(Toplevel *t) -{ - SceneOpenGL1Window *w = new SceneOpenGL1Window(t); - w->setScene(this); - return w; -} - -#endif - //**************************************** // SceneOpenGL::Texture //**************************************** @@ -1595,251 +1472,6 @@ void SceneOpenGL2Window::restoreStates(TextureType type, qreal opacity, qreal br } } -//*************************************** -// SceneOpenGL1Window -//*************************************** -#ifdef KWIN_HAVE_OPENGL_1 -SceneOpenGL1Window::SceneOpenGL1Window(Toplevel *c) - : SceneOpenGL::Window(c) -{ -} - -SceneOpenGL1Window::~SceneOpenGL1Window() -{ -} - -// paint the window -void SceneOpenGL1Window::performPaint(int mask, QRegion region, WindowPaintData data) -{ - if (!beginRenderWindow(mask, region, data)) - return; - - pushMatrix(transformation(mask, data)); - - // shadow - if (m_shadow) { - paintShadow(region, data); - } - // decorations - paintDecorations(data, region); - - // paint the content - OpenGLWindowPixmap *previous = previousWindowPixmap(); - const WindowQuadList contentQuads = data.quads.select(WindowQuadContents); - if (previous && data.crossFadeProgress() != 1.0) { - // TODO: ARGB crsoofading is atm. a hack, playing on opacities for two dumb SrcOver operations - // Will require a caching texture or sth. else 1.2 compliant - float opacity = data.opacity(); - if (opacity < 0.95f || toplevel->hasAlpha()) { - opacity = 1 - data.crossFadeProgress(); - opacity = data.opacity() * (1 - pow(opacity, 1.0f + 2.0f * data.opacity())); - } - paintContent(s_frameTexture, region, mask, opacity, data, contentQuads, false); - previous->texture()->setFilter(filter == Scene::ImageFilterGood ? GL_LINEAR : GL_NEAREST); - WindowQuadList oldContents; - const QRect &oldGeometry = previous->contentsRect(); - for (const WindowQuad &quad : contentQuads) { - // we need to create new window quads with normalize texture coordinates - // normal quads divide the x/y position by width/height. This would not work as the texture - // is larger than the visible content in case of a decorated Client resulting in garbage being shown. - // So we calculate the normalized texture coordinate in the Client's new content space and map it to - // the previous Client's content space. - WindowQuad newQuad(WindowQuadContents); - for (int i = 0; i < 4; ++i) { - const qreal xFactor = qreal(quad[i].textureX() - toplevel->clientPos().x())/qreal(toplevel->clientSize().width()); - const qreal yFactor = qreal(quad[i].textureY() - toplevel->clientPos().y())/qreal(toplevel->clientSize().height()); - WindowVertex vertex(quad[i].x(), quad[i].y(), - (xFactor * oldGeometry.width() + oldGeometry.x())/qreal(previous->size().width()), - (yFactor * oldGeometry.height() + oldGeometry.y())/qreal(previous->size().height())); - newQuad[i] = vertex; - } - oldContents.append(newQuad); - } - opacity = data.opacity() * (1.0 - data.crossFadeProgress()); - paintContent(previous->texture(), region, mask, opacity, data, oldContents, true); - } else { - paintContent(s_frameTexture, region, mask, data.opacity(), data, contentQuads, false); - } - - popMatrix(); - - endRenderWindow(); -} - -void SceneOpenGL1Window::paintContent(SceneOpenGL::Texture* content, const QRegion& region, int mask, - qreal opacity, const WindowPaintData& data, const WindowQuadList &contentQuads, bool normalized) -{ - if (contentQuads.isEmpty()) { - return; - } - content->bind(); - prepareStates(Content, opacity, data.brightness(), data.saturation(), data.screen()); - renderQuads(mask, region, contentQuads, content, normalized); - restoreStates(Content, opacity, data.brightness(), data.saturation()); - content->unbind(); -#ifndef KWIN_HAVE_OPENGLES - if (m_scene && m_scene->debug()) { - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - renderQuads(mask, region, contentQuads, content, normalized); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } -#endif -} - -void SceneOpenGL1Window::prepareStates(TextureType type, qreal opacity, qreal brightness, qreal saturation, int screen) -{ - Q_UNUSED(screen) - - GLTexture *tex = textureForType(type); - bool alpha = false; - bool opaque = true; - if (type == Content) { - alpha = toplevel->hasAlpha(); - opaque = isOpaque() && opacity == 1.0; - } else { - alpha = true; - opaque = false; - } - // setup blending of transparent windows - glPushAttrib(GL_ENABLE_BIT); - if (!opaque) { - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } - if (saturation != 1.0 && tex->saturationSupported()) { - // First we need to get the color from [0; 1] range to [0.5; 1] range - glActiveTexture(GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_CONSTANT); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA); - const float scale_constant[] = { 1.0, 1.0, 1.0, 0.5}; - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, scale_constant); - tex->bind(); - - // Then we take dot product of the result of previous pass and - // saturation_constant. This gives us completely unsaturated - // (greyscale) image - // Note that both operands have to be in range [0.5; 1] since opengl - // automatically substracts 0.5 from them - glActiveTexture(GL_TEXTURE1); - float saturation_constant[] = { 0.5 + 0.5 * 0.30, 0.5 + 0.5 * 0.59, 0.5 + 0.5 * 0.11, - static_cast(saturation) }; - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, saturation_constant); - tex->bind(); - - // Finally we need to interpolate between the original image and the - // greyscale image to get wanted level of saturation - glActiveTexture(GL_TEXTURE2); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_CONSTANT); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA); - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, saturation_constant); - // Also replace alpha by primary color's alpha here - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - // And make primary color contain the wanted opacity - glColor4f(opacity, opacity, opacity, opacity); - tex->bind(); - - if (alpha || !opaque || brightness != 1.0f) { - glActiveTexture(GL_TEXTURE3); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - // The color has to be multiplied by both opacity and brightness - float opacityByBrightness = opacity * brightness; - glColor4f(opacityByBrightness, opacityByBrightness, opacityByBrightness, opacity); - if (alpha) { - // Multiply original texture's alpha by our opacity - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE0); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PRIMARY_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); - } else { - // Alpha will be taken from previous stage - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - } - tex->bind(); - } - - glActiveTexture(GL_TEXTURE0); - } else if (opacity != 1.0 || brightness != 1.0) { - // the window is additionally configured to have its opacity adjusted, - // do it - float opacityByBrightness = opacity * brightness; - if (alpha) { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glColor4f(opacityByBrightness, opacityByBrightness, opacityByBrightness, - opacity); - } else { - // Multiply color by brightness and replace alpha by opacity - float constant[] = { opacityByBrightness, opacityByBrightness, opacityByBrightness, - static_cast(opacity) }; - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_CONSTANT); - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant); - } - } else if (!alpha && opaque) { - float constant[] = { 1.0, 1.0, 1.0, 1.0 }; - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_CONSTANT); - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant); - } -} - -void SceneOpenGL1Window::restoreStates(TextureType type, qreal opacity, qreal brightness, qreal saturation) -{ - GLTexture *tex = textureForType(type); - if (opacity != 1.0 || saturation != 1.0 || brightness != 1.0f) { - if (saturation != 1.0 && tex->saturationSupported()) { - glActiveTexture(GL_TEXTURE3); - glDisable(tex->target()); - glActiveTexture(GL_TEXTURE2); - glDisable(tex->target()); - glActiveTexture(GL_TEXTURE1); - glDisable(tex->target()); - glActiveTexture(GL_TEXTURE0); - } - } - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glColor4f(0, 0, 0, 0); - - glPopAttrib(); // ENABLE_BIT -} -#endif - //**************************************** // OpenGLWindowPixmap //**************************************** @@ -1980,7 +1612,7 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra GLShader* shader = m_effectFrame->shader(); bool sceneShader = false; - if (!shader && ShaderManager::instance()->isValid()) { + if (!shader) { shader = ShaderManager::instance()->pushShader(ShaderManager::SimpleShader); sceneShader = true; } else if (shader) { @@ -1997,10 +1629,6 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#ifdef KWIN_HAVE_OPENGL_1 - if (!shader) - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); -#endif // Render the actual frame if (m_effectFrame->style() == EffectFrameUnstyled) { @@ -2114,10 +1742,6 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra const float a = opacity * frameOpacity; shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a)); } -#ifdef KWIN_HAVE_OPENGL_1 - else - glColor4f(0.0, 0.0, 0.0, opacity * frameOpacity); -#endif m_unstyledTexture->bind(); const QPoint pt = m_effectFrame->geometry().topLeft(); @@ -2128,16 +1752,12 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra translation.translate(pt.x(), pt.y()); if (shader) { shader->setUniform(GLShader::WindowTransformation, translation); - } else { - pushMatrix(translation); } } m_unstyledVBO->render(region, GL_TRIANGLES); if (!sceneShader) { if (shader) { shader->setUniform(GLShader::WindowTransformation, QMatrix4x4()); - } else { - popMatrix(); } } m_unstyledTexture->unbind(); @@ -2149,10 +1769,6 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra const float a = opacity * frameOpacity; shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a)); } -#ifdef KWIN_HAVE_OPENGL_1 - else - glColor4f(1.0, 1.0, 1.0, opacity * frameOpacity); -#endif m_texture->bind(); qreal left, top, right, bottom; m_effectFrame->frame().getMargins(left, top, right, bottom); // m_geometry is the inner geometry @@ -2171,10 +1787,6 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra const float a = opacity * frameOpacity; shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a)); } - #ifdef KWIN_HAVE_OPENGL_1 - else - glColor4f(1.0, 1.0, 1.0, opacity * frameOpacity); - #endif glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); m_selectionTexture->bind(); m_selectionTexture->render(region, m_effectFrame->selection()); @@ -2193,10 +1805,6 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra const float a = opacity * (1.0 - m_effectFrame->crossFadeProgress()); shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a)); } -#ifdef KWIN_HAVE_OPENGL_1 - else - glColor4f(1.0, 1.0, 1.0, opacity * (1.0 - m_effectFrame->crossFadeProgress())); -#endif m_oldIconTexture->bind(); m_oldIconTexture->render(region, QRect(topLeft, m_effectFrame->iconSize())); @@ -2205,19 +1813,11 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra const float a = opacity * m_effectFrame->crossFadeProgress(); shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a)); } -#ifdef KWIN_HAVE_OPENGL_1 - else - glColor4f(1.0, 1.0, 1.0, opacity * m_effectFrame->crossFadeProgress()); -#endif } else { if (shader) { const QVector4D constant(opacity, opacity, opacity, opacity); shader->setUniform(GLShader::ModulationConstant, constant); } -#ifdef KWIN_HAVE_OPENGL_1 - else - glColor4f(1.0, 1.0, 1.0, opacity); -#endif } if (!m_iconTexture) { // lazy creation @@ -2235,10 +1835,6 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra const float a = opacity * (1.0 - m_effectFrame->crossFadeProgress()); shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a)); } -#ifdef KWIN_HAVE_OPENGL_1 - else - glColor4f(1.0, 1.0, 1.0, opacity *(1.0 - m_effectFrame->crossFadeProgress())); -#endif m_oldTextTexture->bind(); m_oldTextTexture->render(region, m_effectFrame->geometry()); @@ -2247,19 +1843,11 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra const float a = opacity * m_effectFrame->crossFadeProgress(); shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a)); } -#ifdef KWIN_HAVE_OPENGL_1 - else - glColor4f(1.0, 1.0, 1.0, opacity * m_effectFrame->crossFadeProgress()); -#endif } else { if (shader) { const QVector4D constant(opacity, opacity, opacity, opacity); shader->setUniform(GLShader::ModulationConstant, constant); } -#ifdef KWIN_HAVE_OPENGL_1 - else - glColor4f(1.0, 1.0, 1.0, opacity); -#endif } if (!m_textTexture) // Lazy creation updateTextTexture(); diff --git a/scene_opengl.h b/scene_opengl.h index 6b0fe600c9..4b0c37743d 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -137,31 +137,6 @@ private: GLuint vao; }; -#ifdef KWIN_HAVE_OPENGL_1 -class SceneOpenGL1 : public SceneOpenGL -{ -public: - explicit SceneOpenGL1(OpenGLBackend *backend); - virtual ~SceneOpenGL1(); - virtual void screenGeometryChanged(const QSize &size); - virtual qint64 paint(QRegion damage, ToplevelList windows); - virtual CompositingType compositingType() const { - return OpenGL1Compositing; - } - - static bool supported(OpenGLBackend *backend); - -protected: - virtual void paintGenericScreen(int mask, ScreenPaintData data); - virtual void doPaintBackground(const QVector< float >& vertices); - virtual Scene::Window *createWindow(Toplevel *t); - -private: - void setupModelViewProjectionMatrix(); - bool m_resetModelViewProjectionMatrix; -}; -#endif - class SceneOpenGL::TexturePrivate : public GLTexturePrivate { @@ -320,23 +295,6 @@ private: bool m_blendingEnabled; }; -#ifdef KWIN_HAVE_OPENGL_1 -class SceneOpenGL1Window : public SceneOpenGL::Window -{ -public: - explicit SceneOpenGL1Window(Toplevel *c); - virtual ~SceneOpenGL1Window(); - -protected: - virtual void performPaint(int mask, QRegion region, WindowPaintData data); - virtual void prepareStates(TextureType type, qreal opacity, qreal brightness, qreal saturation, int screen); - virtual void restoreStates(TextureType type, qreal opacity, qreal brightness, qreal saturation); -private: - void paintContent(SceneOpenGL::Texture* content, const QRegion& region, int mask, qreal opacity, - const WindowPaintData& data, const WindowQuadList &contentQuads, bool normalized); -}; -#endif - class OpenGLWindowPixmap : public WindowPixmap { public: diff --git a/workspace.cpp b/workspace.cpp index f6dff8a827..ea86af204c 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1416,7 +1416,6 @@ QString Workspace::supportInformation() const if (effects) { support.append(QStringLiteral("Compositing is active\n")); switch (effects->compositingType()) { - case OpenGL1Compositing: case OpenGL2Compositing: case OpenGLCompositing: { #ifdef KWIN_HAVE_OPENGLES @@ -1490,11 +1489,7 @@ QString Workspace::supportInformation() const support.append(QStringLiteral(" no\n")); } - if (effects->compositingType() == OpenGL2Compositing) { - support.append(QStringLiteral("OpenGL 2 Shaders are used\n")); - } else { - support.append(QStringLiteral("OpenGL 2 Shaders are not used. Legacy OpenGL 1.x code path is used.\n")); - } + support.append(QStringLiteral("OpenGL 2 Shaders are used\n")); support.append(QStringLiteral("Painting blocks for vertical retrace: ")); if (m_compositor->scene()->blocksForRetrace()) support.append(QStringLiteral(" yes\n"));