diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt
index 6a4adad51d..9c046c17ad 100644
--- a/effects/CMakeLists.txt
+++ b/effects/CMakeLists.txt
@@ -97,6 +97,7 @@ if( KWIN_HAVE_OPENGL_COMPOSITING )
include( screenshot/CMakeLists.txt )
include( sheet/CMakeLists.txt )
include( snaphelper/CMakeLists.txt )
+ include( startupfeedback/CMakeLists.txt )
include( trackmouse/CMakeLists.txt )
include( wobblywindows/CMakeLists.txt )
endif( KWIN_HAVE_OPENGL_COMPOSITING )
@@ -108,7 +109,6 @@ if( KWIN_HAVE_OPENGL_COMPOSITING AND NOT KWIN_HAVE_OPENGLES_COMPOSITING )
include( magnifier/CMakeLists.txt )
include( sharpen/CMakeLists.txt )
include( snow/CMakeLists.txt )
- include( startupfeedback/CMakeLists.txt )
endif( KWIN_HAVE_OPENGL_COMPOSITING AND NOT KWIN_HAVE_OPENGLES_COMPOSITING )
###############################################################################
diff --git a/effects/startupfeedback/CMakeLists.txt b/effects/startupfeedback/CMakeLists.txt
index 7a2e5d558f..5bf2b7b0f9 100644
--- a/effects/startupfeedback/CMakeLists.txt
+++ b/effects/startupfeedback/CMakeLists.txt
@@ -11,5 +11,10 @@ install( FILES
startupfeedback/startupfeedback.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
+# Data files
+install( FILES
+ startupfeedback/data/blinking-startup-fragment.glsl
+ DESTINATION ${DATA_INSTALL_DIR}/kwin )
+
#######################################
# Config
diff --git a/effects/startupfeedback/data/blinking-startup-fragment.glsl b/effects/startupfeedback/data/blinking-startup-fragment.glsl
new file mode 100644
index 0000000000..40bbb751b1
--- /dev/null
+++ b/effects/startupfeedback/data/blinking-startup-fragment.glsl
@@ -0,0 +1,15 @@
+uniform sampler2D sample;
+uniform float textureWidth;
+uniform float textureHeight;
+uniform vec4 u_color;
+
+varying vec2 varyingTexCoords;
+
+void main()
+{
+ vec4 tex = texture2D(sample, varyingTexCoords);
+ if (tex.a != 1.0) {
+ tex = u_color;
+ }
+ gl_FragColor = tex;
+}
diff --git a/effects/startupfeedback/startupfeedback.cpp b/effects/startupfeedback/startupfeedback.cpp
index 89f669e4d6..f2ffe95850 100644
--- a/effects/startupfeedback/startupfeedback.cpp
+++ b/effects/startupfeedback/startupfeedback.cpp
@@ -22,7 +22,9 @@ along with this program. If not, see .
#include
#include
// KDE
+#include
#include
+#include
#include
#include
// KWin
@@ -81,6 +83,7 @@ StartupFeedbackEffect::StartupFeedbackEffect()
, m_progress( 0 )
, m_texture( 0 )
, m_type( BouncingFeedback )
+ , m_blinkingShader( 0 )
{
for( int i=0; i<5; ++i )
{
@@ -104,6 +107,7 @@ StartupFeedbackEffect::~StartupFeedbackEffect()
delete m_bouncingTextures[i];
}
delete m_texture;
+ delete m_blinkingShader;
}
bool StartupFeedbackEffect::supported()
@@ -126,8 +130,20 @@ void StartupFeedbackEffect::reconfigure( Effect::ReconfigureFlags flags )
m_type = NoFeedback;
else if( busyBouncing )
m_type = BouncingFeedback;
- else if( busyBlinking )
+ else if (busyBlinking) {
m_type = BlinkingFeedback;
+ if (ShaderManager::instance()->isValid()) {
+ delete m_blinkingShader;
+ m_blinkingShader = 0;
+ const QString shader = KGlobal::dirs()->findResource("data", "kwin/blinking-startup-fragment.glsl");
+ m_blinkingShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::SimpleShader, shader);
+ if (m_blinkingShader->isValid()) {
+ kDebug(1212) << "Blinking Shader is valid";
+ } else {
+ kDebug(1212) << "Blinking Shader is not valid";
+ }
+ }
+ }
else
m_type = PassiveFeedback;
if( m_active )
@@ -179,41 +195,61 @@ void StartupFeedbackEffect::paintScreen( int mask, QRegion region, ScreenPaintDa
default:
return; // safety
}
+#ifndef KWIN_HAVE_OPENGLES
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
+#endif
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
texture->bind();
- if( m_type == BlinkingFeedback )
- {
- // texture transformation
+ bool useShader = false;
+ if (m_type == BlinkingFeedback) {
const QColor& blinkingColor = BLINKING_COLORS[ FRAME_TO_BLINKING_COLOR[ m_frame ]];
- float color[4] = { blinkingColor.redF(), blinkingColor.greenF(), 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 );
+ if (m_blinkingShader && m_blinkingShader->isValid()) {
+ useShader = true;
+ ShaderManager::instance()->pushShader(m_blinkingShader);
+ m_blinkingShader->setUniform("u_color", blinkingColor);
+ } else {
+#ifndef KWIN_HAVE_OPENGLES
+ // texture transformation
+ float color[4] = { blinkingColor.redF(), blinkingColor.greenF(), 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 (ShaderManager::instance()->isValid()) {
+ useShader = true;
+ ShaderManager::instance()->pushShader(ShaderManager::SimpleShader);
+ }
texture->render( m_currentGeometry, m_currentGeometry );
- if( m_type == BlinkingFeedback )
+ if (useShader) {
+ ShaderManager::instance()->popShader();
+ }
+ if( m_type == BlinkingFeedback && !useShader )
{
+#ifndef KWIN_HAVE_OPENGLES
// 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 );
+#ifndef KWIN_HAVE_OPENGLES
glPopAttrib();
+#endif
}
}
diff --git a/effects/startupfeedback/startupfeedback.h b/effects/startupfeedback/startupfeedback.h
index 26957f7ffd..bef68e6ae8 100644
--- a/effects/startupfeedback/startupfeedback.h
+++ b/effects/startupfeedback/startupfeedback.h
@@ -75,6 +75,7 @@ class StartupFeedbackEffect
GLTexture* m_texture; // for passive and blinking
FeedbackType m_type;
QRect m_currentGeometry;
+ GLShader *m_blinkingShader;
};
} // namespace