Make AbstractEglBackend a QObject

Summary:
Several of the subclasses are already derived from QObject.

The main reason is that the class should be moved out of KWin core in
order to move the OpenGL scene into a plugin. As Compositor calls into
the AbstractEglBackend to unbind the wayland display this creates a
problem which is easily solved by turning the AbstractEglBackend into a
QObject and connect to the signal emitted by the Compositor.

Test Plan: Compiles

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7669
This commit is contained in:
Martin Flöser 2017-09-03 10:26:20 +02:00
parent 9381411b91
commit 01ddbe7d75
9 changed files with 16 additions and 19 deletions

View file

@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "abstract_egl_backend.h"
#include "composite.h"
#include "egl_context_attribute_builder.h"
#include "options.h"
#include "platform.h"
@ -54,17 +55,18 @@ eglQueryWaylandBufferWL_func eglQueryWaylandBufferWL = nullptr;
#endif
AbstractEglBackend::AbstractEglBackend()
: OpenGLBackend()
: QObject(nullptr)
, OpenGLBackend()
{
connect(Compositor::self(), &Compositor::aboutToDestroy, this, &AbstractEglBackend::unbindWaylandDisplay);
}
AbstractEglBackend::~AbstractEglBackend() = default;
void AbstractEglBackend::unbindWaylandDisplay()
{
auto display = kwinApp()->platform()->sceneEglDisplay();
if (eglUnbindWaylandDisplayWL && display != EGL_NO_DISPLAY) {
eglUnbindWaylandDisplayWL(display, *(WaylandServer::self()->display()));
if (eglUnbindWaylandDisplayWL && m_display != EGL_NO_DISPLAY) {
eglUnbindWaylandDisplayWL(m_display, *(WaylandServer::self()->display()));
}
}

View file

@ -29,8 +29,9 @@ class QOpenGLFramebufferObject;
namespace KWin
{
class KWIN_EXPORT AbstractEglBackend : public OpenGLBackend
class KWIN_EXPORT AbstractEglBackend : public QObject, public OpenGLBackend
{
Q_OBJECT
public:
virtual ~AbstractEglBackend();
bool makeCurrent() override;
@ -49,8 +50,6 @@ public:
return m_config;
}
static void unbindWaylandDisplay();
protected:
AbstractEglBackend();
void setEglDisplay(const EGLDisplay &display);
@ -69,6 +68,8 @@ protected:
bool createContext();
private:
void unbindWaylandDisplay();
EGLDisplay m_display = EGL_NO_DISPLAY;
EGLSurface m_surface = EGL_NO_SURFACE;
EGLContext m_context = EGL_NO_CONTEXT;

View file

@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "composite.h"
#include "abstract_egl_backend.h"
#include "dbusinterface.h"
#include "utils.h"
#include <QTextStream>
@ -146,7 +145,6 @@ Compositor::Compositor(QObject* workspace)
Compositor::~Compositor()
{
emit aboutToDestroy();
AbstractEglBackend::unbindWaylandDisplay();
finish();
deleteUnusedSupportProperties();
delete cm_selection;

View file

@ -36,8 +36,7 @@ namespace KWin
{
EglGbmBackend::EglGbmBackend(DrmBackend *b)
: QObject(NULL)
, AbstractEglBackend()
: AbstractEglBackend()
, m_backend(b)
{
// Egl is always direct rendering

View file

@ -33,7 +33,7 @@ class DrmOutput;
/**
* @brief OpenGL Backend using Egl on a GBM surface.
**/
class EglGbmBackend : public QObject, public AbstractEglBackend
class EglGbmBackend : public AbstractEglBackend
{
Q_OBJECT
public:

View file

@ -42,8 +42,7 @@ namespace KWin
{
EglGbmBackend::EglGbmBackend(VirtualBackend *b)
: QObject(nullptr)
, AbstractEglBackend()
: AbstractEglBackend()
, m_backend(b)
{
// Egl is always direct rendering

View file

@ -31,9 +31,8 @@ class GLRenderTarget;
/**
* @brief OpenGL Backend using Egl on a GBM surface.
**/
class EglGbmBackend : public QObject, public AbstractEglBackend
class EglGbmBackend : public AbstractEglBackend
{
Q_OBJECT
public:
EglGbmBackend(VirtualBackend *b);
virtual ~EglGbmBackend();

View file

@ -39,8 +39,7 @@ namespace KWin
{
EglWaylandBackend::EglWaylandBackend(Wayland::WaylandBackend *b)
: QObject(NULL)
, AbstractEglBackend()
: AbstractEglBackend()
, m_bufferAge(0)
, m_wayland(b)
, m_overlay(NULL)

View file

@ -47,7 +47,7 @@ namespace Wayland {
* repaints, which is obviously not optimal. Best solution is probably to go for buffer_age extension
* and make it the only available solution next to fullscreen repaints.
**/
class EglWaylandBackend : public QObject, public AbstractEglBackend
class EglWaylandBackend : public AbstractEglBackend
{
Q_OBJECT
public: