Port KWin to shader traits API
Review Request #126215 - Created Dec. 1, 2015 and submitted
tldr: this ports all areas of KWin which were not yet using the ShaderTraits API to it.
- Extending ShaderBinder with traits API
- Passing the generated projection matrix through ScreenPaintData (so that effects don't have to recalculate just for rendering a texture)
- Passing the actually used screen transformation + model view matrix through WindowPaintData
- Add API to generate a shader with traits and replacing vertex or fragment with custom code (useful for effects)
- adjust all effects
- adjust lanczos filter
- adjust scene
Simplifies binding a Shader with traits.
Create the new projection matrix at start of frame rendering
For both simple and generic rendering the projection is actually the
same. So let's create it at the start of the frame rendering which
allows us to also pass it through the effects.
Use ShaderTraits based shader for paint background
Little bit less usage of old Shader API.
Pass projection matrix to ScreenPaintData
With this change a new ctor overload is added to ScreenPaintData
which allows passing a projection matrix through the effects. This
allows effects to put up custom shaders with a shared projection matrix
and without having to calculate it themselves.
The projection matrix is a read-only information for the effects. There
is no way to change or overwrite it.
[kwineffects] Pass screen projection matrix to WindowPaintData
The screen projection matrix is needed if an effect wants to customize
the modelview projection matrix while rendering a window and keeping
the currently applied screen projection and transformation.
[kwineffects] Add a generateCustomShader to ShaderManager
This method allows to generate a shader with ShaderTraits but one
part (e.g. vertex and/or fragment) to be replaced by custom shader
Thus it can be used as a replacement for the load*(ShaderType) variants
and allows more effects to transition to shaders using traits.
Always set mvp on shader in SceneOpenGL2Window::performPaint
Makes it possible to pass in a shader with a custom fragment shader,
but a normal vertex shader which needs the mvp matrix to be set.
Render effect frame with shader trait API
[effects] Switch ShowFPS to ShaderTraits based rendering
[effects] Use shader traits in ShowPaint effect
[effects] Use shader traits in SnapHelper effect
To simplify rendering is moved from postPaintScreen to paintScreen.
[effects] Use color shader traits in magnifier effect
[effects] Use shader trait api in MouseClick
[effects] Use shader traits API for MouseMark effect
[effects] Use shader traits api in screenedge effect
[effects] Use shader traits API to render wallpaper in cube effect
[effects] Use shader traits API in trackmouse
[effects] Drop resetting Generic Shader from zoom effect
No longer needed as during the rendering the Generic Shader is not
used any more. So the zoom effect doesn't affect it.
[effects] Simplify setting mvp matrix for cursor in zoom effect
Now that we pass the projection matrix with screen paint data we
don't need to calculate our own matrix.
[effects] Use shader traits generated shader for invert effect
Source code needs minor adjustment to be compatible with the shader
traits variable naming.
[effects] Port startupfeedback to shader trait api
The blinking shader is adjusted to use a shader trait vertex shader
and gets generated with a shader trait variant.
Overall the code is simplified to ensure that we always have a shader
bound with the correct mvp matrix when rendering the icon.
[effects] Use shader traits API for CubeCap shader
[effects] Use shader traits API for reflection shader
[effects] Use shader traits in Resize
[effects] Use shader traits for CoverSwitch reflection shader
[effects] Fix reflections in coverswitch
Got broken due to switch to Shader Traits API.
[effects] Use shader traits API for lookingglass
In the long run this effect needs to be modified. Rendering the complete
scene to an FBO is not the best approach.
[effects] Use shader traits API for vignetting in Logout
[effects] Use shader traits API in logout blur
Use shader traits API to render cached texture in lanczos filter
Use shader traits API for lanczos filter's shader
[effects] Adjust Cube to use shader traits shader for window rendering
Main change is that the rotation for each face of the cube is now
done through a QMatrix4x4 instead of specifying through ScreenPaintData.
[effects] Change cylinder to shader traits variant
[effects] Change sphere to use shader traits variant
[effects] Drop resetting GenericShader from cube effect
The cube effect no longer modifies any aspects of the GenericShader,
thus there is no need to reset any values.
Drop remaining old shader API usage from SceneOpenGL
No effect uses old API, so we don't need to setup the old shaders
[kwinglutils] Don't setup old shader API for rendering a texture
Old shader API no longer in use, so we don't need to setup the texture
each individual change got tested. Several shader trait introduction regressions found and fixed.