2015-05-06 15:47:07 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2015 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#ifndef KWIN_HWCOMPOSER_BACKEND_H
|
|
|
|
#define KWIN_HWCOMPOSER_BACKEND_H
|
|
|
|
#include "abstract_backend.h"
|
|
|
|
|
2015-10-20 11:16:05 +00:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QWaitCondition>
|
|
|
|
|
2015-05-06 15:47:07 +00:00
|
|
|
// libhybris
|
|
|
|
#include <hwcomposer_window.h>
|
|
|
|
// needed as hwcomposer_window.h includes EGL which on non-arm includes Xlib
|
|
|
|
#include <fixx11h.h>
|
|
|
|
|
|
|
|
typedef struct hwc_display_contents_1 hwc_display_contents_1_t;
|
|
|
|
typedef struct hwc_layer_1 hwc_layer_1_t;
|
|
|
|
typedef struct hwc_composer_device_1 hwc_composer_device_1_t;
|
2015-11-16 08:01:48 +00:00
|
|
|
struct light_device_t;
|
2015-05-06 15:47:07 +00:00
|
|
|
|
2015-10-09 11:12:40 +00:00
|
|
|
class HWComposerNativeWindowBuffer;
|
|
|
|
|
2015-05-06 15:47:07 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class HwcomposerWindow;
|
|
|
|
|
|
|
|
class HwcomposerBackend : public AbstractBackend
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_INTERFACES(KWin::AbstractBackend)
|
|
|
|
Q_PLUGIN_METADATA(IID "org.kde.kwin.AbstractBackend" FILE "hwcomposer.json")
|
|
|
|
public:
|
|
|
|
explicit HwcomposerBackend(QObject *parent = nullptr);
|
|
|
|
virtual ~HwcomposerBackend();
|
|
|
|
|
|
|
|
void init() override;
|
|
|
|
Screens *createScreens(QObject *parent = nullptr) override;
|
|
|
|
OpenGLBackend *createOpenGLBackend() override;
|
|
|
|
|
2015-11-17 09:49:09 +00:00
|
|
|
QSize screenSize() const override {
|
|
|
|
return m_displaySize;
|
|
|
|
}
|
|
|
|
|
2015-05-06 15:47:07 +00:00
|
|
|
HwcomposerWindow *createSurface();
|
|
|
|
|
|
|
|
QSize size() const {
|
|
|
|
return m_displaySize;
|
|
|
|
}
|
|
|
|
|
|
|
|
hwc_composer_device_1_t *device() const {
|
|
|
|
return m_device;
|
|
|
|
}
|
2015-06-25 16:04:06 +00:00
|
|
|
int refreshRate() const {
|
|
|
|
return m_refreshRate;
|
|
|
|
}
|
2015-10-19 08:13:04 +00:00
|
|
|
void enableVSync(bool enable);
|
2015-10-20 11:16:05 +00:00
|
|
|
void waitVSync();
|
|
|
|
void wakeVSync();
|
2015-06-26 08:09:16 +00:00
|
|
|
|
2015-05-11 12:43:51 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void toggleBlankOutput();
|
|
|
|
|
2015-05-06 15:47:07 +00:00
|
|
|
private:
|
2015-11-16 08:01:48 +00:00
|
|
|
void initLights();
|
|
|
|
void toggleScreenBrightness();
|
2015-05-06 15:47:07 +00:00
|
|
|
QSize m_displaySize;
|
|
|
|
hwc_composer_device_1_t *m_device = nullptr;
|
2015-11-16 08:01:48 +00:00
|
|
|
light_device_t *m_lights = nullptr;
|
2015-05-11 12:43:51 +00:00
|
|
|
bool m_outputBlank = true;
|
2015-06-25 16:04:06 +00:00
|
|
|
int m_refreshRate = 60000;
|
2015-10-20 11:16:05 +00:00
|
|
|
int m_vsyncInterval = 16;
|
2015-10-19 08:13:04 +00:00
|
|
|
bool m_hasVsync = false;
|
2015-10-20 11:16:05 +00:00
|
|
|
QMutex m_vsyncMutex;
|
|
|
|
QWaitCondition m_vsyncWaitCondition;
|
2015-05-06 15:47:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class HwcomposerWindow : public HWComposerNativeWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~HwcomposerWindow();
|
|
|
|
|
2015-10-09 11:12:40 +00:00
|
|
|
void present(HWComposerNativeWindowBuffer *buffer);
|
2015-05-06 15:47:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend HwcomposerBackend;
|
|
|
|
HwcomposerWindow(HwcomposerBackend *backend);
|
|
|
|
HwcomposerBackend *m_backend;
|
|
|
|
hwc_display_contents_1_t **m_list;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|