Commit Graph

196 Commits (master)

Author SHA1 Message Date
Martin Gräßlin 359224a5dc Pass the current output geometry to ScreenPaintData
Summary:
On Wayland per output rendering is performed and paintScreen is invoked
for every output. Some effects need the information which output is
currently being rendered as otherwise e.g. FBO access could fail.

This change adds the current output geometry to ScreenPaintData. On X11
(all outputs one geometry) this information is not set and a null rect
is returned. That way the effects can also easily check which rendering
mode is used.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3058
2016-10-17 09:02:30 +02:00
Martin Gräßlin 0bb1f2e7bf Make WindowPixmap::isValid virtual and override in concrete implementation
Summary:
If a buffer gets destroyed the texture created from it is still valid.
In such a situation the OpenGLWindowPixmap should return true for isValid
and not false as it did. Similar in QPainter compositor the pixmap is
valid if there is an image copied from the buffer.

This change ensures that for example minimizing an XWayland window
still has a texture during the minimize animation.

BUG: 368440

Test Plan:
Minimize animation plays for X windows and minimized windows
are shown in present windows.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2724
2016-09-14 10:23:35 +02:00
Martin Gräßlin d03a50c6e1 Merge branch 'Plasma/5.7' 2016-08-19 07:46:46 +02:00
Martin Gräßlin fe8fc6f83d Ensure to directly delete old Shadow on update
Summary:
So far when deleting a Shadow we used deleteLater which caused it
to be deleted in the next event cycle. This could in worst case result
in the Shadow being deleted after compositing got suspended. Thus the
Shadow not getting removed from the DecorationShadowCache which in
turn would mess up rendering on resume of compositing as the cache
returns a texture created for a different context.

BUG: 361154
FIXED-IN: 5.7.4

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2483
2016-08-18 16:08:42 +02:00
Martin Gräßlin 142aab2e24 Introduce an EffectsHandler::animationsSupported -> bool
Summary:
A new method to tell the effects system whether the compositor scene
is able to drive animations. E.g. on software emulation (llvmpipe) it's
better to not do any animations at all.

This information can be used by effects to adjust their behavior, e.g.
PresentWindows could skip transitions or effects can use it in their
supported check to completely disable themselves.

As a first step all scripted effects are considered to be unsupported
if animations are not supported. They inherit AnimationEffect and are
all about driving animations.

The information whether animations are supported comes from the Scene.
It's implemented in the following way:
 * XRender: animations are always supported
 * QPainter: animations are never supported
 * OpenGL: animations are supported, except for software emulation

In addition - for easier testing - there is a new env variable
KWIN_EFFECTS_FORCE_ANIMATIONS to overwrite the selection.

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2386
2016-08-15 17:38:33 +02:00
Martin Gräßlin 996ee34e14 Remove the unredirect fullscreen windows functionality
Summary:
Rational: unredirect fullscreen windows is a weird beast. It's intended
to make fullscreen windows "faster" by not compositing that screen. But
that doesn't really work as KWin jumps out of that condition pretty
quickly. E.g. whenever a tooltip window is shown. KWin itself has a
better functionality by supporting to block compositing completely.
The complete code was full of hacks around it to try to ensure that
things don't break.

Overall unredirect fullscreen has always been the odd one. We had it
because a compositor needs to have it, but it never got truly integrated.
E.g. effects don't interact with it properly so that some things randomly
work, others don't. Will it trigger the screenedge, probably yes, but
will it show the highlight: properly no.

By removing the functionality we finally acknowledge that this mode is
not maintained and has not been maintained for years and that we do not
intend to support it better in future. Over the years we tried to make
it more and more hidden: it's disabled for Intel GPUs, because it used
to crash KWin. It's marked as an "expert" option, etc.

It's clearly something we tried to hide from the user that it exists.

For Wayland the whole unredirect infrastructure doesn't make sense
either. There is no such thing as "unredirecting". We might make use
of passing buffers directly to the underlying stack, but that will be
done automatically when we know it can be done, not by some magic is
this a window of specific size.

Test Plan:
Compiles, cannot really test as I am an Intel user who never
had that working.

Reviewers: #kwin, #plasma, #vdg

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2180
2016-08-04 14:48:35 +02:00
Martin Gräßlin 055e2b3bb6 [autotests] Add a new test case which can verify the rendering of QPainter Scene
Summary:
The idea behind this autotest is inspired by bug 356328 which produced
incorrect rendering results. Also it's inspired by openQA which performs
image reference comparisons.

This test case tries to go further. It creates reference images which
must match the rendering result exactly. So far the test case verifies
the start condition - kwin started and one frame is rendered with default
cursor in the middle of the screen. And it verifies the moving of the
cursor without any windows shown. Whenever the cursor moves a repaint
should be triggered and the old and new area should be properly
repainted.

To support this the test needs some minor changes in KWin:
* Scene provides a frameRendered signal - needed for waiting on frame
* Scene and SceneQPainter are exported
* SceneQPainter provides access to it's Backend, so that we get to the
 backbuffer
* ScriptedEffectLoader is exported for getting a list of all scripted
 effects - (we don't want fade to manipulate the rendering)

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2046
2016-07-01 09:00:19 +02:00
Martin Gräßlin 354defe499 Add a SurfaceInterface *WindowPixmap::surface() const
Convenience method to get the Surface for a WindowPixmap which is either
the toplevel's surface or a SubSurface.
2016-04-07 07:59:28 +02:00
Martin Gräßlin ebbb82906d Add support for SubSurface to WindowPixmap
This change introduces a tree for WindowPixmap. A WindowPixmap can
have a parent WindowPixmap and children. Each child represents a
SubSurface and references the buffer of that SubSurface.

The tree of WindowPixmaps is updated each time updateBuffer is called.
If there are new SubSurfaces new WindowPixmaps are created, for removed
SubSurfaces the old WindowPixmap gets removed. Also the ordering is
updated to reflect the current state.

This is currently rather expensive and should be changed to only rebuild
the tree if it actually changed.
2016-04-07 07:59:28 +02:00
Martin Gräßlin 952122dbe1 Make Scene::Window::window() and WindowPixmap::toplevel() const
No need to have them not const.
2016-04-07 07:59:28 +02:00
Kevin Funk 43bd3e44e1 Scene: Fix memory leak
Detected by ASAN

```
Indirect leak of 2080 byte(s) in 10 object(s) allocated from:
    #0 0x4dc922 in operator new(unsigned long)
(/home/kfunk/devel/install/kf5/bin/kwin_x11+0x4dc922)
    #1 0x7f43db47efd6 in
QList<KWin::WindowQuad>::node_construct(QList<KWin::WindowQuad>::Node*,
KWin::WindowQuad const&)
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:404:65
    #2 0x7f43db47e51c in
QList<KWin::WindowQuad>::append(KWin::WindowQuad const&)
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:553:13
    #3 0x7f43db72787d in
KWin::Scene::Window::makeQuads(KWin::WindowQuadType, QRegion const&,
QPoint const&) const /home/kfunk/devel/src/kf5/kwin/scene.cpp:927:9
    #4 0x7f43db725817 in KWin::Scene::Window::buildQuads(bool) const
/home/kfunk/devel/src/kf5/kwin/scene.cpp:834:15
    #5 0x7f43db899c79 in KWin::EffectWindowImpl::buildQuads(bool) const
/home/kfunk/devel/src/kf5/kwin/effects.cpp:1700:12
    #6 0x7f43db4666d6 in KWin::Shadow::createShadow(KWin::Toplevel*)
/home/kfunk/devel/src/kf5/kwin/shadow.cpp:69:17
    #7 0x7f43db6fb825 in KWin::Toplevel::getShadow()
/home/kfunk/devel/src/kf5/kwin/toplevel.cpp:318:9
    #8 0x7f43db7197dc in KWin::Scene::windowAdded(KWin::Toplevel*)
/home/kfunk/devel/src/kf5/kwin/scene.cpp:408:5
    #9 0x7f43db6d6b71 in KWin::Toplevel::setupCompositing()
/home/kfunk/devel/src/kf5/kwin/composite.cpp:981:5
    #10 0x7f43db6db215 in KWin::Client::setupCompositing()
/home/kfunk/devel/src/kf5/kwin/composite.cpp:1248:10
    #11 0x7f43db6c4517 in KWin::Compositor::startupWithWorkspace()
/home/kfunk/devel/src/kf5/kwin/composite.cpp:329:9
    #12 0x7f43db6c28db in
KWin::Compositor::slotCompositingOptionsInitialized()
/home/kfunk/devel/src/kf5/kwin/composite.cpp:283:9
    #13 0x7f43db6beda4 in KWin::Compositor::setup()
/home/kfunk/devel/src/kf5/kwin/composite.cpp:184:9
    #14 0x7f43dbef60af in KWin::Compositor::qt_static_metacall(QObject*,
QMetaObject::Call, int, void**)
/home/kfunk/devel/build/kf5/kwin/moc_composite.cpp:263:18
    #15 0x7f43d54de7b0 in QObject::event(QEvent*)
(/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b67b0)
    #16 0x7f43d5da39db in QApplicationPrivate::notify_helper(QObject*,
QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x15b9db)
```
2016-02-15 17:42:32 +01:00
Martin Gräßlin 3be6ff9f12 [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.
2016-01-25 14:11:54 +01:00
Martin Gräßlin f284ef814c 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.
2016-01-25 14:11:54 +01:00
Martin Gräßlin 827486ff36 Introduce a Toplevel::clientContentPos() -> QPoint
This describes an additional offset for the client content. On X11
our client content position matches with the window - the window
decoration is part of the overall content coordinate system.

On Wayland the content is an own texture starting at 0/0. Thus a
mapping to texture coordinates will be required when server side
decorations are provided. The new information is used in the scene's
to adjust the rendering and generating of quads.
2015-12-18 16:41:49 +01:00
Martin Gräßlin c56bbc0ddf Composite windows from a QOpenGLFramebufferObject
This change introduces a mechanism for internal windows to be rendered
to a QOpenGLFramebufferObject to be composited using the texture bound
to the FBO. This is useful for in-process rendering (e.g. QtQuick) and
at the same time bypassing the windowing system.

The OpenGL context of the QOpenGLFramebufferObject needs to be sharing
with the compositing OpenGL context.
2015-08-25 14:33:50 +02:00
Martin Gräßlin 3139dcd3b9 Drop cmakedefine HAVE_WAYLAND
Now a required build dependency.
2015-08-12 11:39:20 +02:00
Martin Gräßlin 147af71f8a Drop Workspace dependency from Scene
Only used for one connect which can also be done outside of Scene.
Subclasses got the singleton pointer and just passed to the parent.
2015-03-17 10:20:19 +01:00
Martin Gräßlin a0b2a938aa [wayland] Support creating Texture from Wayland shm buffer
EglWaylandBackend gains support for creating textures from a
BufferInterface. At the same time it loses the possibility to use
the Xcb shm extension to load the texture. That is Xwayland is
required.

In order to support it in a better way the WindowPixmap is passed
to the Texture for loading and updating. Which is then passed to the
backend specific implementation.
2015-03-17 10:08:27 +01:00
Martin Gräßlin 19d90e4e0e [scene] Add basic support for Wayland Buffer in WindowPixmap
The concept of Buffers do not match WindowPixmap perfectly. With X11
we had a pixmap as long as the size was the sime, then it got discarded.
With Wayland we get a new Buffer whenever the window gets damaged.
Furthermore the Buffer might get destroyed any time (especially if the
client disconnects) or the data becomes invalid (it's a shm section after
all).

This adds some constraints on how the Buffer can be used. It's suggested
that the implementing sub-classes do a deep copy of the Buffer's data
when accessing it. For OpenGL that's rather obvious, for QPainter it
needs a dedicated QImage::copy.

WindowPixmap holds a pointer to the currently used Buffer, but doesn't
guarantee that it stays valid. Every time the window gets damaged, the
pointer needs to be updated.

The QPainter based scene is the first to implement support for Buffers:
on creation a deep copy is performed, on damage the changed parts are
painted into the deep copy.
2015-03-17 10:08:27 +01:00
Martin Gräßlin e32da9d9e0 Merge branch 'master' into kdecorations2
Conflicts:
	CMakeLists.txt
	paintredirector.cpp
	scene_opengl.h
	scene_qpainter.h
	scene_xrender.h
2014-10-20 16:04:52 +02: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
Martin Gräßlin 0030eb7f84 Initial import of support for new KDecoration2 based decorations
NOTE: this is not working completely yet, lots of code is still ifdefed
other parts are still broken.

The main difference for the new decoration API is that it is neither
QWidget nor QWindow based. It's just a QObject which processes input
events and has a paint method to render the decoration. This means all
the workarounds for the QWidget interception are removed. Also the paint
redirector is removed. Instead each compositor has now its own renderer
which can be optimized for the specific case. E.g. the OpenGL compositor
renders to a scratch image which gets copied into the combined texture,
the XRender compositor copies into the XPixmaps.

Input events are also changed. The events are composed into QMouseEvents
and passed through the decoration, which might accept them. If they are
not accpted we assume that it's a press on the decoration area allowing
us to resize/move the window. Input events are not completely working
yet, e.g. wheel events are not yet processed and double click on deco
is not yet working.

Overall KDecoration2 is way more stateful and KWin core needs more
adjustments for it. E.g. borders are allowed to be disabled at any time.
2014-07-25 14:02:26 +02: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
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
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 69b109b5b9 Adjust the ThumbnailItems to QtQuick2
AbstractThumbnailItem inherits from QQuickPaintedItem using QPainter to
do the fallback painting of icons.

The scene is adjusted to get the information from QQuickItem instead of
QDeclarativeItem. Clipping got a little bit more complex as the clip
path does not exist any more. To get it right the ThumbnailItem needs to
specify the parent it wants to be clipped to with the clipTo property.
E.g.:
clipTo: listView

The scene uses this clipTo parent item to correctly calculate the clip
region. Also the ThumbnailItem needs to have clipping enabled.

Note: this commit currently breaks TabBox as the qml and view are not
yet adjusted. In scripting the export of the item is disabled, but any
qml script using a ThumbnailItem would obviously also fail.
2013-08-09 11:47:17 +02:00
Martin Gräßlin 941c02a60f Introduce cross-fading with previous pixmap
Cross fading with previous pixmap is achieved by referencing the old
window pixmap. WindowPaintData has a cross-fade-factor which interpolates
between 0.0 (completely old pixmap) to 1.0 (completely new pixmap).

If a cross fading factor is set and a previous pixmap is valid this one
is rendered on top of the current pixmap with opacity adjusted. This
results in a smoother fading.

To simplify the setup the AnimationEffect is extended and also takes care
about correctly (un)referencing the previous window pixmap. The maximize
effect is adjusted to make use of this new capabilities.

Unfortunately this setup has a huge problem with the case that the window
decoration gets smaller (e.g. from normal to maximized state). In this
situation it can happen that the old window is rendered with parts outside
the content resulting in video garbage being shown. To prevent this a set
of new WindowQuads is generated with normalized texture coordinates in
the safe area which contains real content.

For OpenGL2Window a PreviousContentLeaf is added which is only set up in
case the crass fading factor is set.

REVIEW: 110578
2013-06-05 08:18:28 +02:00
Martin Gräßlin e7ab3adafd New class to encapsulate a Window's Pixmap
The behavior for creating a pixmap for a window is moved from Toplevel
into a dedicated class WindowPixmap. Scene::Window holds a reference to
this class and creates a new WindowPixmap whenever the pixmap needs to be
discarded. In addition it also keeps the old WindowPixmap around for the
case that creating the new pixmap fails. The compositor can in that case
use the previous pixmap which reduces possible flickering. Also this
referencing can be used to improve transition effects like the maximize
windows effect which would benefit from starting with the old pixmap.

For XRender and OpenGL a dedicated sub-class of the WindowPixmap is
created which provides the additional mapping to an XRender picture and
OpenGL texture respectively.

BUG: 319563
FIXED-IN: 4.11
REVIEW: 110577
2013-06-05 08:18:11 +02:00
Fredrik Höglund 5b445b1706 kwin: Set the texcoords in the decoration quads
This way we don't have to compute them in makeDecorationArrays().
2013-05-29 18:17:57 +02:00
Thomas Lübking b7e6a334da rebase measuring to nano res + fix vsync padding
REVIEW: 109784
2013-05-20 16:09:27 +02:00
Thomas Lübking 9446abc696 hasWaitSync -> blocksForRetrace and syncsToVBlank
since that's not the same.
also autodetect triple buffering

REVIEW: 109783
2013-05-20 16:09:27 +02:00
Martin Gräßlin 4351d6ce44 Cleanup and reorder includes in toplevel.h
REVIEW: 110202
2013-04-26 12:33:44 +02:00
Martin Gräßlin 466bef3a6d Adding a DesktopThumbnailItem declarative item
Similar to WindowThumbnailItem for rendering a desktop thumbnail.
Uses the new paintDesktop hook.

FEATURE: 296067
FIXED-IN: 4.11.0
REVIEW: 104441
2013-04-24 11:45:47 +02:00
Thomas Lübking 9aef5b85a0 support a permanent glSwapBuffer
either by
- forcing fullrepaints unconditionally
- turning a repaint to a full one beyond a threshhold
- completing the the backbuffer from the frontbuffer after the paint

BUG: 307965
FIXED-IN: 4.10
REVIEW: 107198
2013-03-05 19:24:30 +01:00
Martin Gräßlin 533d57da60 Mark most ctors as explicit as reported by Krazy2 checker 2013-01-02 18:35:46 +01:00
Casian Andrei 01adbe6dc5 Implement color correction (per output)
Add an option to kcmcompositing in the 'Advanced' tab, to enable or
disable color correction. It is specified that it's experimental and it
needs Kolor Manager.

Before painting for a particular screen, ColorCorrection::setupForOutput
should be called.

A screen property is added for WindowPaintData.

In kwinglutils, The fragment shaders are intercepted before being
compiled and they get a couple of lines of code inserted in order to do
the color correction. This happens only when color correction is enabled, of
course.

For D-Bus communication with KolorServer, everything is async.

The implementation basically manages a set of color lookup tables for
different outputs and for different window regions. These are taken via
D-Bus. Each lookup table has around 700 KB.

This commit reintroduces the changes from the former merge with the
"color2" branch. In this form, it can be easily reverted.

REVIEW: 106141
2012-11-13 22:47:09 +02:00
Casian Andrei a46d247702 Revert "Merge branch 'color2'"
This merge is incomplete and it does not include the review number of
the associated review request. It should have been pushed as a single
commit, because the merged commits were not intended to be published in
their form.

This reverts commit dcba90263069a221a5489b1915c5cf1ca39d090c, reversing
changes made to 50ae07525c7fde07794e7548c3d6e5a69cb1a89d.

Conflicts:
	kwin/scene_opengl.cpp
	kwin/scene_opengl.h
2012-11-13 22:19:32 +02:00
Casian Andrei 8341d4406b Merge remote-tracking branch 'origin/master' into color2
Results in cleaner changes.
Put all the color correction stuff from SceneOpenGL in SceneOpenGL2.

Conflicts:
	kwin/eglonxbackend.cpp
	kwin/glxbackend.cpp
	kwin/scene.h
	kwin/scene_opengl.cpp
	kwin/scene_opengl.h
2012-09-23 11:57:38 +03:00
Martin Gräßlin 22dd2ca2c9 Merge branch 'KDE/4.9'
Conflicts:
	plasma/generic/scriptengines/python/plasma_importer.py
2012-09-16 21:34:04 +02:00
Martin Gräßlin 967be8b95a Improve performance of Scene::Window
Replace dynamic_casts to check the type for for Toplevel by isFoo()
calls and use static_casts in such blocks.

Furthermore method shape() returns now a constant reference instead of a
copy of the QRegion.

REVIEW: 106364
2012-09-16 21:31:20 +02:00
Martin Gräßlin 6152cc4fa5 Split out the windowing system related part of SceneOpenGL
The handling for creating and managing the OpenGL context is
split out of the SceneOpenGL into the abstract OpenGLBackend
and it's two subclasses GlxBackend and EglOnXBackend.

The backends take care of creating the OpenGL context on the
windowing system, e.g. on glx an OpenGL context on the overlay
window is created and in the egl case an EGL context is created.
This means that the SceneOpenGL itself does not have to care
about the specific underlying infrastructure.

Furthermore the backend provides the Textures for the specific
texture from pixmap operations. For that in each of the backend
files an additional subclass of the TexturePrivate is defined.
These subclasses hold the EglImage and GLXPixmap respectively.

The backend is able to create such a private texture and for
that the ctor of the Texture is changed to take the backend as
a parameter and the Scene provides a factory method for
creating Textures. To make this work inside Window the Textures
are now hold as pointers which seems a better choice anyway as
to the member functions pointers are passed.
2012-09-16 21:28:05 +02:00
Casian Andrei 59d2fa7a10 Merge branch 'master' into color2
Conflicts:
	kwin/scene_opengl.cpp
	kwin/workspace.cpp
2012-09-04 21:55:21 +03:00
Thomas Lübking ad2059bdbe fix flicker with fullscreen effects
BUG: 304375
FIXED-IN: 4.9.1
REVIEW: 106142
2012-08-28 21:29:12 +02:00
Thomas Lübking f82fffdd71 fix flicker with fullscreen effects
BUG: 304375
FIXED-IN: 4.9.1
REVIEW: 106142
2012-08-28 15:35:35 +02:00
Casian Andrei 1fbb413daf CC: Tweak lanczos filter member 2012-08-27 15:53:40 +03:00
Martin Gräßlin 2d954a6bf3 Make the Scene owned by the Compositor
The Scene has always been created and destroyed inside what is
now the split out compositor. Which means it is actually owned
by the Compositor. The static pointer has never been needed
inside KWin core. Access to the Scene is not required for the
Window Manager. The only real usage is in the EffectsHandlerImpl
and in utils.h to provide a convenient way to figure out whether
compositing is currently active (scene != NULL).

The EffectsHandlerImpl gets also created by the Compositor after
the Scene is created and gets deleted just before the Scene gets
deleted. This allows to inject the Scene into the EffectsHandlerImpl
to resolve the static access in this class.

The convenient way to access the compositing() in utils.h had
to go. To provide the same feature the Compositor provides a
hasScene() access which has the same behavior as the old method.
In order to keep the code changes small in Workspace and Toplevel
a new method compositing() is defined which properly resolves
the state. A disadvantage is that this can no longer be inlined
and consists of several method calls and pointer checks.
2012-08-26 20:43:57 +02:00
Casian Andrei a417888b0e Implement color correction support
The implementation consists of a class in libkwineffects.

There are some slight modifications in the compositor. Regions for
different outputs are drawn at different times.

Currently only per output color correction is implemented. However, the
grounds are prepared for implementing per window color correction
easily.

The ColorCorrection class needs to communicate via D-Bus with a KDED
module, KolorServer, which is a part of KolorManager.

The only visible part for the user consists of a check box in the
advanced tab for the compositing KCM.

The actual correction is done by injecting a piece of code in the
fragment shader, code that does a 3D lookup into a special color lookup
texture. The data for these textures is obtained from KolorServer. All
D-Bus calls are async.
2012-08-20 20:37:25 +03:00
Martin Gräßlin 3746e4d7d8 Recreate lanczos filter whenever the screen size changes
The LanczosFilter has a FBO in screen size. When the screen
geometry changes this FBO has to be recreated. To go completely
sure the lanczos filter gets deleted on screen changes.

To achieve this the LanczosFilter is wrapped inside a
QWeakPointer so that we can track when it got deleted. This
brings an additional advantage by delaying the creation of the
shader till it is really needed, that is when for the first
time a window thumbnail with lanczos is rendered.

BUG: 296065
FIXED-IN: 4.9.0
REVIEW: 105479
2012-07-09 06:32:57 +02:00
Thomas Lübking fc665106c9 Swap vsync order, trade in 1frame lag
REVIEW: 103058
2012-05-17 11:41:26 +02:00
Montel Laurent 329bd03f6b Fix warning 2012-03-02 14:03:05 +01:00
Thomas Lübking 85635dd485 fix tabbing
BUG: 290959
BUG: 265160
BUG: 229292
BUG: 238279
BUG: 290758
BUG: 222831
BUG: 278275
BUG: 245747
BUG: 230000

BUG: 253697
BUG: 230570
BUG: 265977
BUG: 225337
BUG: 225339

REVIEW: 103855
2012-02-11 16:30:22 +01:00
Thomas Lübking bf88ec09ac Revert "fix tabbing"
pushed out of branch, not master - leading to absent revision, found hash collision??

This reverts commit 94b2ad7b85801e37e2df4671cdc4f26b6d7e5506.
2012-02-11 16:29:14 +01:00
Thomas Lübking d245035a17 fix tabbing
BUG: 290959
BUG: 265160
BUG: 229292
BUG: 238279
BUG: 290758
BUG: 222831
BUG: 278275
BUG: 245747
BUG: 230000

BUG: 253697
BUG: 230570
BUG: 265977
BUG: 225337
BUG: 225339

REVIEW: 103855
2012-02-11 16:01:41 +01:00
Philipp Knechtges ba39d1f917 kwin:remove PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS
paintSimpleScreen can handle the affected effects now.

REVIEW: 103827
2012-02-09 14:52:25 +01:00
Thomas Lübking d845b60c6c change geometry w/o compositor restart
This possibly fails on some (older?) ati chip/driver combos
-> Waiting for bugreports

REVIEW: 103246
2012-01-24 22:27:15 +01:00
Philipp Knechtges 050d991cb1 kwin: simplifying paintSimpleScreen
This patch reduces the number of QRegion and WindowQuadList operations
by drawing the opaque and translucent parts of the window within the
same bottom to top pass.

REVIEW: 103671
2012-01-11 18:04:28 +01:00
Fredrik Höglund eb9988b788 kwin: Make Scene::m_renderTimer a non-member
It's only used in Scene::paint(), and its value is not valid
between calls.
2011-10-29 17:41:16 +02:00
Martin Gräßlin 6e15c0c208 Change timers to QElapsedTimers
Instead of calculating the elapsed time from epoch clock, using
a QElapsedTimer as well as reusing the timer object instead of
creating a new one in the scene each frame.

REVIEW: 102473
2011-08-29 06:48:44 +02:00
Philipp Knechtges 85c5181a81 kwin: Avoid painting damaged areas which are occluded by another opaque window.
So far we have not used the information that damage events are window-specific, resulting in the
behavior that we repainted the damaged area although it might be hidden behind another window.
E.g. the CPU-Monitor plasmoid is almost all day occluded by a browser etc. and before this patch
we have been repainting the appropiate area every time the plasmoid has been updated.

Thx to Thomas Lübking for optimizing the patch.

REVIEW: 101846
2011-07-11 19:35:29 +02:00
Arthur Arlt d8072be54d Move OverlayWindow from Workspace to its own class
All the functionality of Overlay Window is moved to its own class
OverlayWindow. It is created and owned by class Scene, since almost
all function calls are called from this class.

REVIEW: 101866
2011-07-09 19:08:48 +02:00
Arthur Arlt 859dacb8b5 Make Scene::windowClosed() a Q_SLOT
This commit just makes the declaration of windowClosed() in Class Scene be a Q_SLOT.
The inheriting classes SceneOpenGL and SceneXRender are updated as well.
2011-07-05 11:46:13 +02:00
Arthur Arlt 14af45cc04 Make Q slots public in class Scene
This commit just makes the slots public that are used in Scene class and its inheriting subclasses.
2011-07-05 11:34:12 +02:00
Arthur Arlt b63c9c1af8 Make mothod windowGeometryShapeChanged() a slot
The method windowGeometryShapeChanged() from the class Scene is now a slot. It is now connected to the signal geometryShapeChanged() which is sent from Toplevel instances Client and Unmanaged.
All direct method calls were deleted.
2011-07-05 11:34:12 +02:00
Arthur Arlt 59a8aac752 Make windowOpacityChanged() a slot
The method windowOpacityChanged is now a protected slot in class Scene. The implementations in the subclasses SceneOpenGL and SceneXRender are the same. The slots are connected to the singal opacityChanged() from Toplevel. The connection is done in the method windowAdded() in both SceneOpenGL and SceneXRender.
2011-07-05 11:34:12 +02:00
Arthur Arlt d88cb00b0b Make class Scene inherit from QObject
The class Scene now inherits from QObject and has the Q_OBJECT macro. The inheriting classes SceneOpenGL and SceneXRender are provided with the Q_OBJECT macro. Now it is possible to use signals and slots and replace direct method calls.
2011-07-05 11:34:12 +02:00
Martin Gräßlin 6cfdbfe1dc Remove compositing self-check
Removes the last bits of the self-check at compositing startup.
It seems like they were only added to XRender because they were
in OpenGL and there they are not available for quite some time.

Also removes the now obsolete disable functionality checks from UI.

REVIEW: 101756
2011-06-26 09:19:22 +02:00
Martin Gräßlin 38e9ab9a4e Move ownership on Shadow from Toplevel to Scene::Window
The Shadow is clearly an aspect of the compositor. Therefore the
Shadow has to be owned and controlled by the Scene::Window.
Nevertheless Toplevel needs to know about the Shadow cause of reading
the property.
2011-04-03 11:31:33 +02:00
Martin Gräßlin 0a7e48f7aa KWin uses kdelibs coding style. 2011-01-31 20:07:03 +01:00
Thomas Lübking 337e1eac18 revert vsync strategy, fix timeouts
differecens to patch atteched to 258971:
- removed debug statements
- fixed indention...
- NON vsync strategy does not rely on the estimation, but on the time passed since the last repaint trigger, allowing a precise framerate

CCBUG: 258971


svn path=/trunk/KDE/kdebase/workspace/; revision=1210445
2010-12-31 13:14:11 +00:00
Martin Gräßlin eabad32cfb Add cross fade support for text and icon to EffectFrame.
This allows an effect to fade between old and new text/icon. As an example it's added to CoverSwitch.
Currently only supported in OpenGL. XRender might be added, but I'm missing an idea for an effect to add it.
Most effects using EffectFrame require OpenGL anyway.

svn path=/trunk/KDE/kdebase/workspace/; revision=1160252
2010-08-07 14:08:34 +00:00
Martin Gräßlin 6e31461039 Adding a new rendering flag for painting the screen with transformed windows but without triggering full repaints.
It is not always required to do a full repaint in each frame. E.g. in sliding popups the repaint areas are known and tracked.
This change reduces the painting overhead to just the window area.
Nevertheless I consider this change as experimental and will revert the commit in case it introduces rendering glitches.
Other effects which are good candidates for this flag is wobbly windows, magic lamp, minimize or in general all effects which transform just one window.

svn path=/trunk/KDE/kdebase/workspace/; revision=1158838
2010-08-03 21:33:27 +00:00
Martin Gräßlin ef79d4c443 Use the normal Plasma selection to highlight the selected window in boxswitch.
So it is more consistent (in KDE newspeak "elegant") with other selections and as a plus we get rid of all the custom rendering code in boxswitch.

svn path=/trunk/KDE/kdebase/workspace/; revision=1155051
2010-07-26 20:00:04 +00:00
Martin Gräßlin fa832b7aa7 Cache the icon texture/picture in EffectFrame and use texture from pixmap to load the data in OpenGL mode. Yeah for less pixmap to image to gltexture conversations.
Some effects (boxswitch and flipswitch) still need to be changed to not set the icon in each frame.

svn path=/trunk/KDE/kdebase/workspace/; revision=1152367
2010-07-20 21:11:03 +00:00
Martin Gräßlin e2eebb6503 Refactoring of EffectFrame: EffectFrame becomes an interface just like EffectsHandler and EffectWindow and a concrete EffectFrameImpl in core.
Rendering of the EffectFrame is moved into the scene as Scene::EffectFrame with a concrete implementation in SceneXrender and SceneOpenGL.
A factory method for an EffectFrame is added to the EffectsHandler, which is used by the effects.
Next step: pass the EffectFrame through all effects, so that effects can transform, blur, invert whatever it.

svn path=/trunk/KDE/kdebase/workspace/; revision=1151271
2010-07-18 16:32:37 +00:00
Martin Gräßlin 191435d425 Move Lanczos filter from taskbarthumbnail effect into the scene and use it also in boxswitch, presentwindows and thumbnailaside effects.
svn path=/trunk/KDE/kdebase/workspace/; revision=1133901
2010-06-02 20:04:54 +00:00
Fredrik Höglund e1161c2525 Don't paint windows that are not on the current activity.
svn path=/trunk/KDE/kdebase/workspace/; revision=1127193
2010-05-15 20:18:57 +00:00
Hugo Pereira Da Costa df712a4802 reverting r1121187
on developpers request.
CCBUG: 235821

svn path=/trunk/KDE/kdebase/workspace/; revision=1121252
2010-04-30 23:06:02 +00:00
Hugo Pereira Da Costa 7e28b26173 renamed toplevelDecorationHasAlpha into decorationHasAlpha
svn path=/trunk/KDE/kdebase/workspace/; revision=1121192
2010-04-30 19:13:46 +00:00
Hugo Pereira Da Costa 9f8bbd1d6c Take decorationUseAlpha decoration flag when setting the PAINT_WINDOW_TRANSLUCENT bit mask.
BUG: 235821

svn path=/trunk/KDE/kdebase/workspace/; revision=1121187
2010-04-30 18:34:08 +00:00
Lucas Murray 7d897b7d3f Added PAINT_DISABLED_BY_CLIENT_GROUP. Allow highlighting of inactive tab
windows in box switch.

svn path=/trunk/KDE/kdebase/workspace/; revision=1065321
2009-12-23 01:44:23 +00:00
Fredrik Höglund f81485d868 Fix shaded and shaped windows not being clipped correctly.
BUG: 193808

svn path=/trunk/KDE/kdebase/workspace/; revision=973673
2009-05-27 16:04:58 +00:00
Fredrik Höglund e92aab0518 Implement initial support for ARGB window decorations.
Based on earlier work done by Lubos Lunak and ideas by Lucas Murray.

svn path=/trunk/KDE/kdebase/workspace/; revision=957680
2009-04-22 17:29:56 +00:00
Luboš Luňák 7249ca2cfb Do self-check immediatelly during compositing setup only when it's not KWin startup
at the same time (in other words, only when activating compositing using the kcm).
Currently selfcheck causes bad flicker (due to X mapping the overlay window
for too long?) which looks bad during KDE startup. With this patch, KDE startup
is without any flicker.


svn path=/trunk/KDE/kdebase/workspace/; revision=923842
2009-02-09 14:51:11 +00:00
Lucas Murray c07ba30b63 Fixed shadow effect losing its shadows after making changes to the settings.
Added force mode to buildQuads() to allow refreshing the cache.
Made EffectWindow::buildQuads() no longer internal.

svn path=/trunk/KDE/kdebase/workspace/; revision=872836
2008-10-18 10:31:59 +00:00
Luboš Luňák 6796c1225f Self-check also for XRender.
svn path=/trunk/KDE/kdebase/workspace/; revision=862312
2008-09-18 15:27:13 +00:00
Luboš Luňák 14ae8d2dc9 Support for unredirecting fullscreen windows, i.e. games etc. can paint directly
and not be slowed down by going through compositing. Turned on and no UI option
in the naive hope that it won't cause any real problems. Maybe effects doing
window previews should get API to suspend unredirect though.


svn path=/trunk/KDE/kdebase/workspace/; revision=851742
2008-08-24 13:32:57 +00:00
Luboš Luňák 1927a283b3 Cache window quads since they usually don't change and this gives
few fps.


svn path=/trunk/KDE/kdebase/workspace/; revision=787978
2008-03-20 11:17:50 +00:00
Luboš Luňák cff2b0e6cd Abstract paint clipping into PaintClipper helper class that allows
stacking of clipping regions.
(http://lists.kde.org/?l=kwin&m=120138051215450&w=2)
BUG: 156798


svn path=/trunk/KDE/kdebase/workspace/; revision=779045
2008-02-25 11:32:21 +00:00
Adriaan de Groot 214d575aa3 Qt3 -> Qt4 style includes.
qdrawutil.h doesn't seem to have a purely Qt4-style equivalent, so including the directory there disambiguates it from the Qt3 header.

svn path=/trunk/KDE/kdebase/workspace/; revision=770116
2008-02-02 20:54:19 +00:00
Rivo Laks be3271c8e0 Fix problem with partial repaints when effect's prePaintWindow() expands paint region.
Also rework the code a bit to simplify it and make it more comprehensible (IMHO).

svn path=/trunk/KDE/kdebase/workspace/; revision=746050
2007-12-07 17:03:59 +00:00
Luboš Luňák 01bf6cbb4c License cleanup - add headers where missing, be explicit about GPL
being v2+ (right now it says just GPL, which according to GPL itself
means any GPL). Decoration clients will come later.
CCMAIL: kwin@kde.org


svn path=/trunk/KDE/kdebase/workspace/; revision=742302
2007-11-27 19:40:25 +00:00
Luboš Luňák 5a50381e1f Move the shader used for painting to WindowPaintData, as it's
more related to one painting than to a window.


svn path=/trunk/KDE/kdebase/workspace/; revision=698576
2007-08-10 11:26:58 +00:00