Summary:
The method xRenderBlendPicture created a static XRenderPicture on
first usage. To cleanup a XRenderPicture an xcb_connection_t* is needed.
As it's static the cleanup happens on exit handler and at that time Qt
already destroyed the xcb_connection_t*. With a certain chance this will
crash.
To expose the problem a Q_ASSERT(qApp) is added in the destructor of
XRenderPicture. Using xrenderBlendPicture() will hit this assert on
application exit. This is demonstrated by the added auto test.
The actual fix to the problem is moving the static variable out of
the method and introduce a global cleanup method just like the init
method. This is now called from Workspace dtor, so before application
goes down.
CCBUG: 363251
Reviewers: #plasma
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D1731
XRenderUtils used connection() and rootWindow() provided by kwinglobals.
Those are now kept as static variables in the implementation set through
an init() method from Workspace prior to the first possible usage of any
functionality provided by XRenderUtils.
In order to make the xcb_connection_t* and the root window completely
internal the inline methods which used those are moved to the
implementation.
In case of native graphics system nothing is changed for the moment - the
X11Pixmap-QPixmap bridge is continued to be used.
But in case of graphics system raster (or Qt5) this relationship is no
longer used. Instead the QPixmap is converted to a QImage and the image
bits are put into the created X11Pixmap for this XRenderPicture.
Note: Qt5 uses shm to transfer image data to drawables. This seems
unsuited in this case as it's only a one time transformation.
For Qt5 the native pixmap block needs to be removed and the ctor might be
changed to taking an QImage as argument to make more clear that there is
no mapping from QPixmap to X11Pixmap.
Instead of having a pointer to a QPixmap the offscreen target holds an
xcb_render_picture_t. To make this possible in SceneWindow the tempPixmap
is changed from a QPixmap* to a XRenderPicture*. QPixmap was only used
for convenience.
ScreenShot Effect as only user of the offscreen target is adjusted but
as it needs a QImage, still uses a QPixmap wrapper.
This follows how it is done for OpenGL where the renderRoundBox() got
dropped some time ago.
New implementation implements the box with round corners using xrender
directly instead of using a QPainter on a QPixmap.
Use xcb to create and manage the X11 backend of Outline. In addition the
used background pixmaps are rendered with XRender instead of using a
QPainter on a QPixmap. This is done because QPixmap is no longer bound to
an X Pixmap.
To create the XRender Picture the available functionality from
kwinxrenderutils is used. To be able to use it in KWin core the compile
option to build without XRender is removed for kwinxrenderutils, but
still supported for effects.
Obviously the port to XCB is not complete as xremderutils itself is still
on XLib.
REVIEW: 108642
Second part of cleaning up the lib directory: the effects library
now lives in libkwineffects/ directory.
For existing effects nothing changes as the install path is unchanged.
The change obsoletes the lib/ directory.
As glplatform.h has not yet been exported I dared to export it and
adjust the places where it is used.
CCMAIL: kwin@kde.org