Commit Graph

463 Commits (6ac73711134c98c5959ca1e22cf7304841a16e11)

Author SHA1 Message Date
Fredrik Höglund 6ac7371113 Remove most calls to checkGLError()
...and rely on KHR_debug/GL_ARB_debug_output instead.
2014-11-25 21:57:57 +01:00
Fredrik Höglund c0deadfaad Add support for KHR_debug
Register a callback function for debug output when KHR_debug or
ARB_debug_output is supported.

Only error messages and warnings about undefined behavior are
enabled in release builds, while all debug messages are enabled
in debug builds.
2014-11-25 21:57:15 +01:00
Fredrik Höglund 32e9de1e23 Refactor the swap completion interface
Move the buffer-swap-pending state from the compositing backends to
the Compositor class. The Compositor is the only class that needs to
access the state, and this way it to do it without calling through
a chain of virtual functions. This commit adds two new functions to
Compositor; aboutToSwapBuffers() and bufferSwapComplete(). The
backends call these functions to set and reset the buffer-swap-pending
state.

This commit also renames a number of functions and variables to make
their meaning clear.

The act of promoting the contents of the back buffer to become the
contents of the front buffer is referred to as posting the buffer,
presenting the buffer, or swapping the buffers; rendering the buffer
is what paintScreen() does.
2014-09-18 20:21:20 +02:00
Fredrik Höglund 3b4907d060 Add support for explicit command stream synchronization
Create and import X sync fences into GL and use them to synchronize
the kwin command stream with the X command stream.

This prevents damaged windows from being composited by kwin before
the rendering that triggered the damage events have finished on
the GPU.

Requires GL_EXT_x11_sync_object.

Tested-by: Marco Martin <notmart@gmail.com>
2014-09-12 14:50:12 +02:00
Fredrik Höglund 4f9ea5335d Remove SceneOpenGL::Texture::findTarget()
It is no longer used.
2014-09-01 17:45:58 +02:00
Fredrik Höglund 59212e3a79 Remove SceneOpenGL::Texture::load(..., int depth)
The scene always uses the version that takes an xcb_visualid_t.
2014-09-01 17:45:58 +02:00
Fredrik Höglund 88f8078073 glx: Use the X visual when choosing an FBConfig
This adds a SceneOpenGL::Texture::load(..., xcb_visualid_t) overload,
and uses it to bind window pixmaps to textures.

By taking the RGBA masks in the visual into account when choosing an
FBConfig for the GLXPixmap, we are able to disambiguate formats that
have the same depth, such as GL_RGB10_A2 and GL_RGBA8.
2014-09-01 17:45:58 +02:00
Fredrik Höglund fc56ac28fb Remove SceneOpenGL::Texture::update()
The default implementation is a no-op, and none of the current
backends reimplement it.
2014-09-01 17:45:57 +02:00
Fredrik Höglund 210df22b17 Remove SceneOpenGL::Texture::load(QPixmap)
Fold it into the constructor, since that's the only place
where it's called.
2014-09-01 17:45:57 +02:00
Fredrik Höglund 49c8827345 Remove SceneOpenGL::Texture::load(QImage)
It's never called.
2014-09-01 17:45:57 +02:00
Fredrik Höglund ff096e532f Remove the region parameter from Texture::load()
It's never used.
2014-09-01 17:45:57 +02:00
Fredrik Höglund 1c7938e43e Don't pass pixmap handles as const references
But do pass the region in SceneOpenGL::Texture::load() as a const
reference.

This patch also replaces the Xlib types with their xcb equivalents.
2014-09-01 17:45:57 +02:00
Fredrik Höglund 70d35d602f Remove SceneOpenGL2Window::prepare/restoreStates()
Dead code.
2014-08-25 17:09:48 +02:00
Fredrik Höglund 3d3a52c32d Remove SceneOpenGL::Window::renderQuads()
Leftover from the OpenGL 1.x backend.
2014-08-25 17:09:48 +02:00
Fredrik Höglund c9aacbc460 Remove SceneOpenGL::Window::paintDecoration()
Leftover from the OpenGL 1.x backend.
2014-08-25 17:09:48 +02:00
Fredrik Höglund 10120c6d42 Remove SceneOpenGL::Window::paintShadow()
Leftover from the OpenGL 1.x backend.
2014-08-25 17:09:48 +02:00
Fredrik Höglund b1586daab4 Remove the GL_QUADS_KWIN definition
GL_QUADS is always defined now that we're using libepoxy.
2014-07-22 12:56:32 +02:00
Fredrik Höglund aae08b16e9 Add a WindowQuadShadow
And use this type for all the shadow quads in the OpenGL scene.
2014-07-22 12:28:20 +02:00
Martin Gräßlin 7744608a1d Drop SceneOpenGL::Window::textureForType
Dead code.
2014-07-21 15:04:44 +02:00
Fredrik Höglund 6ad4c775d7 Use a single texture atlas for the decoration
The left and right border images are rotated 90° before they are
uploaded into the atlas texture. The images are separated by a row
of transparent texels to minimize artifacts from oversampling.

With this change kwin renders the whole decoration with a single
call to glDrawArrays().
2014-07-17 09:39:17 +02:00
Fredrik Höglund d9c4b77f0f Make the GL extension list a QList<QByteArray>
It doesn't make sense to convert the extension names to QStrings.

This also replaces the QString parameter in hasGLExtension() with
a QByteArray and adjusts all callers.
2014-07-14 12:04:37 +02:00
Martin Gräßlin be33c59c16 Introduce config option for OpenGLPlatformInterface
A new config option "GLPlatformInterface" is added to the Compositing
settings group. Valid values are "glx" and "egl". This config option is
honored by the Scene to decide which backend to create.

The setting gets sanitized by the operation mode (egl for Wayland),
the environment variable KWIN_OPENGL_INTERFACE and the compile time
support. These switches are removed from the Scene to not have them
duplicated.
2014-05-13 09:23:03 +02:00
Burkhard Lück 82b7804b0a rename kcmshell4 to kcmshell5 2014-05-02 17:24:47 +02:00
Martin Gräßlin aa7db138e8 Remove unused variables
Thanks to clang for better warnings than g++.
2014-04-04 13:55:57 +02:00
Martin Gräßlin ca5f8cfe03 [kwin] Remove unused config-workspace.h includes 2014-03-18 09:23:25 +01:00
Martin Gräßlin 92761e9e30 [kwin] Fix ifdefs for Wayland
With the switch to FindWayland from ECM WAYLAND_FOUND was no longer set
thus the ifdef didn't work. Now we use HAVE_WAYLAND and HAVE_WAYLAND_EGL.
2014-03-18 09:00:49 +01:00
Aleix Pol c72e519d9c Remove KDE/ prefix in include directories
It's unneeded and deprecated since KF5.
2014-03-17 16:24:10 +01:00
Martin Gräßlin 2675b5d4e7 Merge branch 'KDE/4.11'
Conflicts:
	CMakeLists.txt
	kcontrol/screensaver/screensaver.desktop
	kdm/kfrontend/themes/elarun/KdmGreeterTheme.desktop
	khotkeys/kcm_hotkeys/kcm_hotkeys.cpp
	kinfocenter/main.cpp
	kscreensaver/kblank_screensaver/blankscrn.cpp
	kscreensaver/krandom_screensaver/random.cpp
	kstyles/oxygen/config/main.cpp
	kstyles/oxygen/demo/main.cpp
	ksysguard/gui/ksysguard.cpp
	kwin/clients/oxygen/demo/main.cpp
	kwin/kcmkwin/kwincompositing/kwincompositing.desktop
	kwin/tabbox/qml/clients/text/metadata.desktop
	kwin/tabbox/qml/clients/window_strip/metadata.desktop
	libs/plasmagenericshell/widgetsexplorer/package/metadata.desktop
	plasma/desktop/applets/pager/package/metadata.desktop
	plasma/desktop/shell/activitymanager/package/metadata.desktop
	plasma/desktop/shell/data/layouts/org.kde.plasma-desktop.defaultPanel/contents/layout.js
	plasma/desktop/shell/desktopcorona.cpp
	plasma/desktop/shell/main.cpp
	plasma/desktop/toolboxes/plasma-toolbox-desktoptoolbox.desktop
	plasma/desktop/toolboxes/plasma-toolbox-paneltoolbox.desktop
	plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml
	plasma/generic/applets/systemtray/protocols/fdo/fdographicswidget.cpp
	plasma/generic/applets/systemtray/protocols/fdo/fdographicswidget.h
	plasma/generic/applets/systemtray/protocols/fdo/x11embeddelegate.cpp
	plasma/generic/runners/nepomuksearch/plasma-runner-nepomuksearch.desktop
	plasma/generic/wallpapers/color/plasma-wallpaper-color.desktop
	plasma/generic/wallpapers/image/plasma-wallpaper-image.desktop
	plasma/netbook/shell/nettoolbox/plasma-toolbox-nettoolbox.desktop
	statusnotifierwatcher/statusnotifierwatcher.cpp
	systemsettings/app/main.cpp
2014-03-10 21:21:16 +01:00
Martin Gräßlin c7d986c7fe [kwin] Remove the legacy OpenGL 1 compositing backend
KWin already has a de facto OpenGL 2 dependency through QML. Combined
with the fact that the OpenGL 1 backend is basically unmaintained and
also unused, it's better to remove it for the new major release.

This change includes:
 * Removal of cmake option KWIN_BUILD_OPENGL_1_COMPOSITING
 * Removal of KWIN_HAVE_OPENGL_1 compile option and all code
   ifdef'ed with it (partially removal of if-else constructs)
 * Removal of CompositingType::OpenGL1Compositing (flags are kept
   as a core flag should get introduced)
 * Driver recommendation for OpenGL1Compositing changed to XRender
   (should be evaluated whether the drivers can provide GL2)
 * Removal of configuration option "GLLegacy"
 * Removal of fooMatrix function in kwinglutils
 * Removal of ARBBlurShader
 * Removal of legacy code path in GLVertexBuffer
 * Removal of GLShaderManager::disable
 * if-blocks with ShaderManager::instance()->isValid() removed

REVIEW: 116042
2014-03-10 08:59:11 +01:00
Thomas Lübking e9a8ea24a6 fix frontbuffer copying swap preference
REVIEW: 115523
CCBUG: 330794
CCBUG: 322060
2014-02-24 20:11:31 +01:00
Martin Gräßlin 5b07d4c2a1 Merge branch 'KDE/4.11'
Conflicts:
	kwin/egl_wayland_backend.cpp
	kwin/eglonxbackend.cpp
	kwin/glxbackend.cpp
	kwin/scene_opengl.cpp
	plasma/generic/wallpapers/color/plasma-wallpaper-color.desktop
	plasma/generic/wallpapers/image/plasma-wallpaper-image.desktop
2014-01-28 08:18:41 +01:00
James Jones 6acef12932 Don't call into GL without a context
After losing current from the EGL or GLX
context, calls to the GL or GLES functions
have undefined behavior.  Perform all
cleanup that may touch OpenGL and check for
GL errors before losing current from the
context.

REVIEW: 115311
2014-01-28 07:54:32 +01:00
Martin Gräßlin 1be3a7a9f0 Introduce a method shouldUseWaylandForCompositing() in KWin::Application
Returns true if the OperationMode requires KWin to composite to a
Wayland surface. This replaces the checks for the WaylandBackend or env
variable used so far in the construction of the Scene.
2014-01-09 15:16:42 +01:00
Martin Gräßlin b28effff23 A Scene doesn't need to use an X11 Overlay Window
Only the X based Scenes need an overlay window, so the Compositor doesn't
need to check for it in the Wayland case.

OverlayWindow is moved from OpenGLBackend to the sub classes which need
to provide it.
2014-01-08 09:22:40 +01:00
Martin Gräßlin c9779825d1 Support frame callback in Wayland backend
The egl wayland backend registers for the callback for a rendered frame.
This allows to throttle KWin's compositor so that we don't render frames
which wouldn't end up on the screen.

For this the Scene provides a method to query whether the last frame got
rendered. By default this returns true in all backends. The Egl Wayland
backend returns true or false depending on whether the callback for the
last frame was recieved.

In case the last frame has not been renderd when performCompositing is
tried to be called, the method returns just like in the case when the
overlay window is not visible. Once the frame callback has been recieved
performCompositing is invoked again.
2014-01-08 09:22:40 +01:00
Martin Gräßlin ef4c32f79a Move Scene::Window handling methods into base class
The pure virtual methods windowAdded, windowClosed, windowDeleted and
windowGeometryShapeChanged had identical implementations in both XRender
and OpenGL scene. They were accessing the hash with Scene::Windows which
is nowhere else used except for creating the stacking order in ::paint.

The implementations are moved to the base class, the only Scene specific
code is a pure virtual factory method to create the Scene window. This
already existed in SceneOpenGL to create either a SceneOpenGL1 or 2
window.

Also the hash of windows is a Scene private member now and the creation
of the stacking order is provided by a method, so that the Scene sub
classes do no longer need to access the stacking order at all.

REVIEW: 111207
2014-01-07 15:34:19 +01:00
Martin Gräßlin 1a0e586b9c Pass creation of Shadow sub class instance to Scene
Instead of having the Shadow factory method check the compositor type and
do the decision which Shadow sub class to create, a pure virtual method in
Scene is called which returns the specific Shadow sub class instance.
2014-01-07 15:34:19 +01:00
Martin Gräßlin 5d3d8834ab Pass creation of Scene::EffectFrame to the Scene
Instead of having the EffectFrameImpl check the compositor type and do
the decision which Scene::EffectFrame to create, a pure virtual method
in Scene is called which returns the specific Scene::EffectFrame.
2014-01-07 15:34:19 +01:00
Martin Gräßlin 9b0c6ddef3 Drop pure virtual Scene::windowOpacityChanged slot
It's neither implemented in the XRender nor in the OpenGL Scene.
2014-01-07 15:34:19 +01:00
Martin Gräßlin afbc5222e1 Merge branch 'KDE/4.11' into master
Conflicts:
	CMakeLists.txt
	doc/kcontrol/screensaver/index.docbook
	kcontrol/krdb/krdb.cpp
	kscreensaver/kblank_screensaver/kblank.desktop
	kscreensaver/krandom_screensaver/krandom.desktop
	kscreensaver/libkscreensaver/main.cpp
	ksplash/ksplashqml/SplashApp.cpp
	kstyles/oxygen/config/main.cpp
	kstyles/oxygen/demo/main.cpp
	kstyles/oxygen/oxygenstylehelper.cpp
	kwin/clients/oxygen/config/oxygenexceptiondialog.cpp
	kwin/clients/oxygen/config/ui/oxygenconfigurationui.ui
	kwin/clients/oxygen/config/ui/oxygenexceptiondialog.ui
	kwin/clients/oxygen/demo/main.cpp
	kwin/clients/oxygen/oxygenconfigdata.kcfg
	kwin/egl_wayland_backend.cpp
	kwin/eglonxbackend.h
	kwin/glxbackend.cpp
	kwin/glxbackend.h
	kwin/kcmkwin/kwinoptions/kwinactions.desktop
	kwin/scene_opengl.cpp
	kwin/scene_opengl.h
	plasma/desktop/applets/pager/pager.cpp
	plasma/desktop/shell/activitymanager/activitymanager.cpp
	plasma/desktop/shell/activitymanager/activitymanager.h
	plasma/desktop/shell/controllerwindow.cpp
	plasma/desktop/shell/data/plasma-desktop.desktop
	plasma/generic/dataengines/geolocation/geolocation.cpp
	plasma/generic/dataengines/nowplaying/plasma-dataengine-nowplaying.desktop
	plasma/generic/wallpapers/color/plasma-wallpaper-color.desktop
	plasma/generic/wallpapers/image/image.cpp
	plasma/generic/wallpapers/image/image.h
2014-01-07 09:36:11 +01:00
Laurent Navet 88fc43beeb kwin : replace Q_FOREACH with for(a:b)
replace Q_FOREACH loops with newer for (a:b) notation

Signed-off-by: Laurent Navet <laurent.navet@gmail.com>

REVIEW: 114222
2013-12-13 08:54:34 +01:00
Fredrik Höglund eeb309c149 kwin: Add support for EXT_buffer_age
This patch adds support for GLX_EXT_buffer_age, and
EGL_EXT_buffer_age on X11.
2013-12-12 01:36:46 +01:00
Fredrik Höglund a9e49e218f kwin: Return the modified damage in a separate paintScreen() parameter 2013-12-12 01:36:46 +01:00
Fredrik Höglund c25b2939b1 kwin: Prepare the backend interface for EXT_buffer_age
Allow prepareRenderingFrame() to return a region that will be
repainted in addition to the damaged region.

Pass both the damaged region and the repainted region, which
may be larger, as parameters to endRenderingFrame().
2013-12-12 01:36:45 +01:00
Martin Gräßlin 2372e02752 [kwin] Use a QIcon in Client for the icons instead of Pixmaps
Client used to have dedicated methods for different icon sizes instead
of combining all pixmaps into one QIcon. This resulted in various parts
of KWin having different access to the icons:
* effects only got one pixmap of size 32x32
* decorations only got the 16x16 and 32x32 pixmaps combined into a QIcon
* tabbox could request all icon sizes, but only as pixmap

Now all sizes are available in one QIcon allowing to easily access the
best fitting icon in a given UI.
2013-12-06 14:41:23 +01:00
Raul Fernandes 4af303a48a Calculate the intersection only once
The intersection of rects are calculated twice without need.
The function QRectF::intersected() calculate and returns the intersection.
If there are no interesection, the returned QRectF is empty.
If the intersected QRectF is equal to QRectF argument, it contains the QRectF argument.

Reviewed in: https://git.reviewboard.kde.org/r/114036/
2013-11-28 10:19:48 -02:00
Martin Gräßlin b7be3cb621 Better handling for making the compositing OpenGL context current
With QtQuick2 it's possible that the scene graph rendering context either
lives in an own thread or uses the main GUI thread. In the latter case
it's the same thread as our compositing OpenGL context lives in. This
means our basic assumption that between two rendering passes the context
stays current does not hold.

The code already ensured that before we start a rendering pass the
context is made current, but there are many more possible cases. If we
use OpenGL in areas not triggered by the rendering loop but in response
to other events the context needs to be made current. This includes the
loading and unloading of effects (some effects use OpenGL in the static
effect check, in the ctor and dtor), background loading of texture data,
lazy loading after first usage invoked by shortcut, etc. etc.

To properly handle these cases new methods are added to EffectsHandler
to make the compositing OpenGL context current. These calls delegate down
into the scene. On non-OpenGL scenes they are noop, but on OpenGL they go
into the backend and make the context current. In addition they ensure
that Qt doesn't think that it's QOpenGLContext is current by calling
doneCurrent() on the QOpenGLContext::currentContext(). This unfortunately
causes an additional call to makeCurrent with a null context, but there
is no other way to tell Qt - it doesn't notice when a different context
is made current with low level API calls. In the multi-threaded
architecture this doesn't matter as ::currentContext() returns null.

A short evaluation showed that a transition to QOpenGLContext doesn't
seem feasible. Qt only supports either GLX or EGL while KWin supports
both and when entering the transition phase for Wayland, it would become
extremely tricky if our native platform is X11, but we want a Wayland
EGL context. A future solution might be to have a "KWin-QPA plugin" which
uses either xcb or Wayland and hides everything from Qt.

The API documentation is extended to describe when the effects-framework
ensures that an OpenGL context is current. The effects are changed to
make the context current in cases where it's not guaranteed. This has
been done by looking for creation or deletion of GLTextures and Shaders.
If there are other OpenGL usages outside the rendering loop, ctor/dtor
this needs to be changed, too.
2013-11-23 10:54:41 +01:00
Martin Gräßlin 969e6b85e7 Merge branch 'master' into frameworks-scratch
Conflicts:
	CMakeLists.txt
	kwin/client.cpp
	kwin/effects/highlightwindow/highlightwindow.cpp
	kwin/libkwineffects/kwingltexture.cpp
	kwin/libkwineffects/kwinxrenderutils.cpp
	kwin/scene_opengl.cpp
	kwin/workspace.cpp
	plasma/desktop/applets/kickoff/CMakeLists.txt
	plasma/desktop/applets/taskmanager/package/contents/code/tools.js
	plasma/desktop/applets/taskmanager/package/contents/ui/Task.qml
	plasma/desktop/applets/taskmanager/package/contents/ui/main.qml
	plasma/desktop/applets/taskmanager/package/metadata.desktop
	plasma/desktop/applets/taskmanager/plugin/textlabel.h
	plasma/desktop/applets/tasks/CMakeLists.txt
	plasma/desktop/applets/tasks/package/metadata.desktop
	plasma/desktop/applets/tasks/tasks.cpp
	plasma/desktop/toolboxes/plasma-toolbox-desktoptoolbox.desktop
	plasma/generic/applets/activitybar/activitybar.cpp
	plasma/generic/wallpapers/color/plasma-wallpaper-color.desktop
	plasma/generic/wallpapers/image/plasma-wallpaper-image.desktop
2013-09-24 11:28:38 +02:00
Martin Gräßlin b01f9ca077 Only create ColorCorrection if it is enabled in the options
According to massif just creating the ColorCorrection costs 2 MiB, so
it makes sense to not create it if it is not used.

REVIEW: 111604
DIGEST: Smaller memory footprint in KWin 4.11.2 if color correction is disabled
2013-09-04 14:42:45 +02:00
Martin Gräßlin 57905c0cc2 And we got rid of KDebug
Usages of kBacktrace got dropped.
2013-09-02 13:14:39 +02:00