Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Unmaintained
KDE Workspace
Commits
edd3e96c
Commit
edd3e96c
authored
Jan 06, 2011
by
Martin Flöser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StartupFeedback ported to GLES.
parent
62d0299a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
19 deletions
+76
-19
kwin/effects/CMakeLists.txt
kwin/effects/CMakeLists.txt
+1
-1
kwin/effects/startupfeedback/CMakeLists.txt
kwin/effects/startupfeedback/CMakeLists.txt
+5
-0
kwin/effects/startupfeedback/data/blinking-startup-fragment.glsl
...fects/startupfeedback/data/blinking-startup-fragment.glsl
+15
-0
kwin/effects/startupfeedback/startupfeedback.cpp
kwin/effects/startupfeedback/startupfeedback.cpp
+54
-18
kwin/effects/startupfeedback/startupfeedback.h
kwin/effects/startupfeedback/startupfeedback.h
+1
-0
No files found.
kwin/effects/CMakeLists.txt
View file @
edd3e96c
...
...
@@ -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
)
###############################################################################
...
...
kwin/effects/startupfeedback/CMakeLists.txt
View file @
edd3e96c
...
...
@@ -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
kwin/effects/startupfeedback/data/blinking-startup-fragment.glsl
0 → 100644
View file @
edd3e96c
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
;
}
kwin/effects/startupfeedback/startupfeedback.cpp
View file @
edd3e96c
...
...
@@ -22,7 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtCore/QSize>
#include <QtGui/QPainter>
// KDE
#include <KDE/KGlobal>
#include <KDE/KIconLoader>
#include <KDE/KStandardDirs>
#include <KDE/KStartupInfo>
#include <KDE/KSelectionOwner>
// 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.0
f
};
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.0
f
};
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.0
f
,
0.0
f
,
0.0
f
,
0.0
f
);
#endif
}
texture
->
unbind
();
glDisable
(
GL_BLEND
);
#ifndef KWIN_HAVE_OPENGLES
glPopAttrib
();
#endif
}
}
...
...
kwin/effects/startupfeedback/startupfeedback.h
View file @
edd3e96c
...
...
@@ -75,6 +75,7 @@ class StartupFeedbackEffect
GLTexture
*
m_texture
;
// for passive and blinking
FeedbackType
m_type
;
QRect
m_currentGeometry
;
GLShader
*
m_blinkingShader
;
};
}
// namespace
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment