Support software QtQuickRendering in Aurorae

Summary:
For software QtQuick rendering we want to create a pixmap buffer and
render our contents in there.

m_rendercontrol->grab does this, but also covers the GL side in pretty
much the same way that we were currently doing.

In doing so I found a bug in Qt, that's submitted upstream, and also worked round.

Test Plan:
Tested with forced software mode, could see an Aurorae decorations
Tested without (so normal code), could see an Aurorae decorations
Tested wayland on nvidia with software rendering, didn't freeze

Whether we then end up using GL, painter or xrender rendering is irrelevant
(but I tested two of them anyway)

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: graesslin, apol, plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8039
This commit is contained in:
David Edmundson 2017-11-01 15:44:57 +00:00
parent 018afd092a
commit 54b36325f7

View file

@ -324,6 +324,12 @@ void Decoration::init()
m_item->setParentItem(visualParent.value<QQuickItem*>());
visualParent.value<QQuickItem*>()->setProperty("drawBackground", false);
} else {
m_renderControl = new QQuickRenderControl(this);
m_view = new QQuickWindow(m_renderControl);
bool usingGL = m_view->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL;
m_view->setColor(Qt::transparent);
m_view->setFlags(Qt::FramelessWindowHint);
if (usingGL) {
// first create the context
QSurfaceFormat format;
format.setDepthBufferSize(16);
@ -336,17 +342,21 @@ void Decoration::init()
m_offscreenSurface->setFormat(m_context->format());
m_offscreenSurface->create();
m_renderControl = new QQuickRenderControl(this);
m_view = new QQuickWindow(m_renderControl);
m_view->setColor(Qt::transparent);
m_view->setFlags(Qt::FramelessWindowHint);
}
//workaround for https://codereview.qt-project.org/#/c/207198/
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
if (!usingGL) {
m_renderControl->sync();
}
#endif
// delay rendering a little bit for better performance
m_updateTimer.reset(new QTimer);
m_updateTimer->setSingleShot(true);
m_updateTimer->setInterval(5);
connect(m_updateTimer.data(), &QTimer::timeout, this,
[this] {
[this, usingGL] {
if (usingGL) {
if (!m_context->makeCurrent(m_offscreenSurface.data())) {
return;
}
@ -359,12 +369,10 @@ void Decoration::init()
}
}
m_view->setRenderTarget(m_fbo.data());
m_renderControl->polishItems();
m_renderControl->sync();
m_renderControl->render();
m_view->resetOpenGLState();
m_buffer = m_fbo->toImage();
}
m_buffer = m_renderControl->grab();
m_contentRect = QRect(QPoint(0, 0), m_buffer.size());
if (m_padding &&
@ -389,10 +397,12 @@ void Decoration::init()
m_item->setParentItem(m_view->contentItem());
if (usingGL) {
m_context->makeCurrent(m_offscreenSurface.data());
m_renderControl->initialize(m_context.data());
m_context->doneCurrent();
}
}
setupBorders(m_item);
if (m_extendedBorders) {
auto updateExtendedBorders = [this] {