Merge remote-tracking branch 'qt/5.6' into 5.7
Change-Id: Iada0e076ee33e8d39ecc4f40edfd9764ba610c03
This commit is contained in:
commit
29d74ed32e
@ -1,18 +1,9 @@
|
|||||||
TARGET = QtWaylandClient
|
TARGET = QtWaylandClient
|
||||||
|
MODULE = waylandclient
|
||||||
|
|
||||||
QT += core-private gui-private
|
QT += core-private gui-private
|
||||||
QT_FOR_PRIVATE += platformsupport-private
|
QT_FOR_PRIVATE += platformsupport-private
|
||||||
|
|
||||||
MODULE=waylandclient
|
|
||||||
MODULE_PLUGIN_TYPES = \
|
|
||||||
wayland-graphics-integration-client \
|
|
||||||
wayland-inputdevice-integration \
|
|
||||||
wayland-decoration-client \
|
|
||||||
wayland-shell-integration
|
|
||||||
|
|
||||||
CONFIG += generated_privates
|
|
||||||
|
|
||||||
load(qt_module)
|
|
||||||
|
|
||||||
# We have a bunch of C code with casts, so we can't have this option
|
# We have a bunch of C code with casts, so we can't have this option
|
||||||
QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual
|
QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual
|
||||||
|
|
||||||
@ -25,19 +16,19 @@ CONFIG += link_pkgconfig qpa/genericunixfontdatabase wayland-scanner
|
|||||||
|
|
||||||
config_xkbcommon {
|
config_xkbcommon {
|
||||||
!contains(QT_CONFIG, no-pkg-config) {
|
!contains(QT_CONFIG, no-pkg-config) {
|
||||||
PKGCONFIG += xkbcommon
|
PKGCONFIG_PRIVATE += xkbcommon
|
||||||
} else {
|
} else {
|
||||||
LIBS += -lxkbcommon
|
LIBS_PRIVATE += -lxkbcommon
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEFINES += QT_NO_WAYLAND_XKB
|
DEFINES += QT_NO_WAYLAND_XKB
|
||||||
}
|
}
|
||||||
|
|
||||||
!contains(QT_CONFIG, no-pkg-config) {
|
!contains(QT_CONFIG, no-pkg-config) {
|
||||||
PKGCONFIG += wayland-client wayland-cursor
|
PKGCONFIG_PRIVATE += wayland-client wayland-cursor
|
||||||
contains(QT_CONFIG, glib): PKGCONFIG_PRIVATE += glib-2.0
|
contains(QT_CONFIG, glib): PKGCONFIG_PRIVATE += glib-2.0
|
||||||
} else {
|
} else {
|
||||||
LIBS += -lwayland-client -lwayland-cursor $$QT_LIBS_GLIB
|
LIBS_PRIVATE += -lwayland-client -lwayland-cursor $$QT_LIBS_GLIB
|
||||||
}
|
}
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../shared
|
INCLUDEPATH += $$PWD/../shared
|
||||||
@ -82,6 +73,7 @@ SOURCES += qwaylandintegration.cpp \
|
|||||||
qwaylandinputcontext.cpp \
|
qwaylandinputcontext.cpp \
|
||||||
qwaylanddatadevice.cpp \
|
qwaylanddatadevice.cpp \
|
||||||
qwaylandshm.cpp \
|
qwaylandshm.cpp \
|
||||||
|
qwaylandbuffer.cpp \
|
||||||
|
|
||||||
HEADERS += qwaylandintegration_p.h \
|
HEADERS += qwaylandintegration_p.h \
|
||||||
qwaylandnativeinterface_p.h \
|
qwaylandnativeinterface_p.h \
|
||||||
@ -119,3 +111,11 @@ HEADERS += qwaylandintegration_p.h \
|
|||||||
include(hardwareintegration/hardwareintegration.pri)
|
include(hardwareintegration/hardwareintegration.pri)
|
||||||
include(shellintegration/shellintegration.pri)
|
include(shellintegration/shellintegration.pri)
|
||||||
include(inputdeviceintegration/inputdeviceintegration.pri)
|
include(inputdeviceintegration/inputdeviceintegration.pri)
|
||||||
|
|
||||||
|
CONFIG += generated_privates
|
||||||
|
MODULE_PLUGIN_TYPES = \
|
||||||
|
wayland-graphics-integration-client \
|
||||||
|
wayland-inputdevice-integration \
|
||||||
|
wayland-decoration-client \
|
||||||
|
wayland-shell-integration
|
||||||
|
load(qt_module)
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
PLUGIN_TYPE = wayland-decoration-client
|
|
||||||
load(qt_plugin)
|
|
||||||
|
|
||||||
QT += waylandclient-private
|
QT += waylandclient-private
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
@ -15,3 +12,5 @@ contains(QT_CONFIG, no-pkg-config) {
|
|||||||
PKGCONFIG += wayland-client
|
PKGCONFIG += wayland-client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PLUGIN_TYPE = wayland-decoration-client
|
||||||
|
load(qt_plugin)
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
PLUGIN_TYPE = wayland-graphics-integration-client
|
|
||||||
load(qt_plugin)
|
|
||||||
|
|
||||||
QT += waylandclient-private
|
QT += waylandclient-private
|
||||||
|
|
||||||
include(../../../../hardwareintegration/client/brcm-egl/brcm-egl.pri)
|
include(../../../../hardwareintegration/client/brcm-egl/brcm-egl.pri)
|
||||||
@ -10,3 +7,5 @@ OTHER_FILES += \
|
|||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
|
||||||
|
PLUGIN_TYPE = wayland-graphics-integration-client
|
||||||
|
load(qt_plugin)
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
PLUGIN_TYPE = wayland-graphics-integration-client
|
|
||||||
load(qt_plugin)
|
|
||||||
|
|
||||||
# We have a bunch of C code with casts, so we can't have this option
|
# We have a bunch of C code with casts, so we can't have this option
|
||||||
QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual
|
QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual
|
||||||
|
|
||||||
@ -13,3 +10,5 @@ OTHER_FILES += \
|
|||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
|
||||||
|
PLUGIN_TYPE = wayland-graphics-integration-client
|
||||||
|
load(qt_plugin)
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
PLUGIN_TYPE = wayland-graphics-integration-client
|
|
||||||
load(qt_plugin)
|
|
||||||
|
|
||||||
QT += waylandclient-private
|
QT += waylandclient-private
|
||||||
|
|
||||||
include(../../../../hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pri)
|
include(../../../../hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pri)
|
||||||
@ -10,3 +7,5 @@ OTHER_FILES += \
|
|||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
|
||||||
|
PLUGIN_TYPE = wayland-graphics-integration-client
|
||||||
|
load(qt_plugin)
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
PLUGIN_TYPE = wayland-graphics-integration-client
|
|
||||||
load(qt_plugin)
|
|
||||||
|
|
||||||
QT += waylandclient-private
|
QT += waylandclient-private
|
||||||
|
|
||||||
include(../../../../hardwareintegration/client/wayland-egl/wayland-egl.pri)
|
include(../../../../hardwareintegration/client/wayland-egl/wayland-egl.pri)
|
||||||
@ -10,3 +7,5 @@ OTHER_FILES += \
|
|||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
|
||||||
|
PLUGIN_TYPE = wayland-graphics-integration-client
|
||||||
|
load(qt_plugin)
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
PLUGIN_TYPE = wayland-graphics-integration-client
|
|
||||||
load(qt_plugin)
|
|
||||||
|
|
||||||
# We have a bunch of C code with casts, so we can't have this option
|
# We have a bunch of C code with casts, so we can't have this option
|
||||||
QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual
|
QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual
|
||||||
|
|
||||||
@ -13,3 +10,5 @@ OTHER_FILES += xcomposite-egl.json
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|
||||||
|
PLUGIN_TYPE = wayland-graphics-integration-client
|
||||||
|
load(qt_plugin)
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
PLUGIN_TYPE = wayland-graphics-integration-client
|
|
||||||
load(qt_plugin)
|
|
||||||
|
|
||||||
QT += waylandclient-private
|
QT += waylandclient-private
|
||||||
|
|
||||||
include(../../../../hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri)
|
include(../../../../hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri)
|
||||||
@ -10,3 +7,5 @@ OTHER_FILES += xcomposite-glx.json
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|
||||||
|
PLUGIN_TYPE = wayland-graphics-integration-client
|
||||||
|
load(qt_plugin)
|
||||||
|
72
src/plugins/platforms/wayland/qwaylandbuffer.cpp
Normal file
72
src/plugins/platforms/wayland/qwaylandbuffer.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Copyright (C) 2015 Giulio Camuffo.
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qwaylandbuffer_p.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace QtWaylandClient {
|
||||||
|
|
||||||
|
QWaylandBuffer::QWaylandBuffer()
|
||||||
|
: mBuffer(0)
|
||||||
|
, mBusy(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QWaylandBuffer::~QWaylandBuffer()
|
||||||
|
{
|
||||||
|
if (mBuffer)
|
||||||
|
wl_buffer_destroy(mBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QWaylandBuffer::init(wl_buffer *buf)
|
||||||
|
{
|
||||||
|
mBuffer = buf;
|
||||||
|
wl_buffer_add_listener(buf, &listener, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QWaylandBuffer::release(void *data, wl_buffer *)
|
||||||
|
{
|
||||||
|
static_cast<QWaylandBuffer *>(data)->mBusy = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wl_buffer_listener QWaylandBuffer::listener = {
|
||||||
|
QWaylandBuffer::release
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
@ -65,17 +65,25 @@ namespace QtWaylandClient {
|
|||||||
|
|
||||||
class Q_WAYLAND_CLIENT_EXPORT QWaylandBuffer {
|
class Q_WAYLAND_CLIENT_EXPORT QWaylandBuffer {
|
||||||
public:
|
public:
|
||||||
QWaylandBuffer()
|
QWaylandBuffer();
|
||||||
: mBuffer(0)
|
virtual ~QWaylandBuffer();
|
||||||
{
|
void init(wl_buffer *buf);
|
||||||
}
|
|
||||||
virtual ~QWaylandBuffer() { }
|
|
||||||
wl_buffer *buffer() {return mBuffer;}
|
wl_buffer *buffer() {return mBuffer;}
|
||||||
virtual QSize size() const = 0;
|
virtual QSize size() const = 0;
|
||||||
virtual int scale() const { return 1; }
|
virtual int scale() const { return 1; }
|
||||||
|
|
||||||
|
void setBusy() { mBusy = true; }
|
||||||
|
bool busy() const { return mBusy; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct wl_buffer *mBuffer;
|
struct wl_buffer *mBuffer;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool mBusy;
|
||||||
|
|
||||||
|
static void release(void *data, wl_buffer *);
|
||||||
|
static const wl_buffer_listener listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -259,6 +259,8 @@ void QWaylandInputDevice::handleWindowDestroyed(QWaylandWindow *window)
|
|||||||
mKeyboard->mFocus = 0;
|
mKeyboard->mFocus = 0;
|
||||||
mKeyboard->stopRepeat();
|
mKeyboard->stopRepeat();
|
||||||
}
|
}
|
||||||
|
if (mTouch && window == mTouch->mFocus)
|
||||||
|
mTouch->mFocus = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandInputDevice::setDataDevice(QWaylandDataDevice *device)
|
void QWaylandInputDevice::setDataDevice(QWaylandDataDevice *device)
|
||||||
@ -745,6 +747,9 @@ void QWaylandInputDevice::Touch::touch_down(uint32_t serial,
|
|||||||
wl_fixed_t x,
|
wl_fixed_t x,
|
||||||
wl_fixed_t y)
|
wl_fixed_t y)
|
||||||
{
|
{
|
||||||
|
if (!surface)
|
||||||
|
return;
|
||||||
|
|
||||||
mParent->mTime = time;
|
mParent->mTime = time;
|
||||||
mParent->mSerial = serial;
|
mParent->mSerial = serial;
|
||||||
mFocus = QWaylandWindow::fromWlSurface(surface);
|
mFocus = QWaylandWindow::fromWlSurface(surface);
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-client-protocol.h>
|
#include <wayland-client-protocol.h>
|
||||||
@ -59,9 +60,14 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
namespace QtWaylandClient {
|
namespace QtWaylandClient {
|
||||||
|
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(logCategory)
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(logCategory, "qt.qpa.wayland.backingstore")
|
||||||
|
|
||||||
QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
|
QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
|
||||||
const QSize &size, QImage::Format format, int scale)
|
const QSize &size, QImage::Format format, int scale)
|
||||||
: mShmPool(0)
|
: QWaylandBuffer()
|
||||||
|
, mShmPool(0)
|
||||||
, mMarginsImage(0)
|
, mMarginsImage(0)
|
||||||
{
|
{
|
||||||
int stride = size.width() * 4;
|
int stride = size.width() * 4;
|
||||||
@ -97,8 +103,8 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
|
|||||||
mImage.setDevicePixelRatio(qreal(scale));
|
mImage.setDevicePixelRatio(qreal(scale));
|
||||||
|
|
||||||
mShmPool = wl_shm_create_pool(shm->object(), fd, alloc);
|
mShmPool = wl_shm_create_pool(shm->object(), fd, alloc);
|
||||||
mBuffer = wl_shm_pool_create_buffer(mShmPool,0, size.width(), size.height(),
|
init(wl_shm_pool_create_buffer(mShmPool,0, size.width(), size.height(),
|
||||||
stride, wl_format);
|
stride, wl_format));
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,8 +113,6 @@ QWaylandShmBuffer::~QWaylandShmBuffer(void)
|
|||||||
delete mMarginsImage;
|
delete mMarginsImage;
|
||||||
if (mImage.constBits())
|
if (mImage.constBits())
|
||||||
munmap((void *) mImage.constBits(), mImage.byteCount());
|
munmap((void *) mImage.constBits(), mImage.byteCount());
|
||||||
if (mBuffer)
|
|
||||||
wl_buffer_destroy(mBuffer);
|
|
||||||
if (mShmPool)
|
if (mShmPool)
|
||||||
wl_shm_pool_destroy(mShmPool);
|
wl_shm_pool_destroy(mShmPool);
|
||||||
}
|
}
|
||||||
@ -146,9 +150,7 @@ QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window)
|
|||||||
, mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display())
|
, mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display())
|
||||||
, mFrontBuffer(0)
|
, mFrontBuffer(0)
|
||||||
, mBackBuffer(0)
|
, mBackBuffer(0)
|
||||||
, mFrontBufferIsDirty(false)
|
|
||||||
, mPainting(false)
|
, mPainting(false)
|
||||||
, mFrameCallback(0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -158,16 +160,10 @@ QWaylandShmBackingStore::~QWaylandShmBackingStore()
|
|||||||
if (QWaylandWindow *w = waylandWindow())
|
if (QWaylandWindow *w = waylandWindow())
|
||||||
w->setBackingStore(Q_NULLPTR);
|
w->setBackingStore(Q_NULLPTR);
|
||||||
|
|
||||||
if (mFrameCallback)
|
|
||||||
wl_callback_destroy(mFrameCallback);
|
|
||||||
|
|
||||||
// if (mFrontBuffer == waylandWindow()->attached())
|
// if (mFrontBuffer == waylandWindow()->attached())
|
||||||
// waylandWindow()->attach(0);
|
// waylandWindow()->attach(0);
|
||||||
|
|
||||||
if (mFrontBuffer != mBackBuffer)
|
qDeleteAll(mBuffers);
|
||||||
delete mFrontBuffer;
|
|
||||||
|
|
||||||
delete mBackBuffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPaintDevice *QWaylandShmBackingStore::paintDevice()
|
QPaintDevice *QWaylandShmBackingStore::paintDevice()
|
||||||
@ -180,16 +176,7 @@ void QWaylandShmBackingStore::beginPaint(const QRegion &)
|
|||||||
mPainting = true;
|
mPainting = true;
|
||||||
ensureSize();
|
ensureSize();
|
||||||
|
|
||||||
QWaylandWindow *window = waylandWindow();
|
waylandWindow()->setCanResize(false);
|
||||||
QWaylandSubSurface *sub = window->subSurfaceWindow();
|
|
||||||
|
|
||||||
bool waiting = window->attached() && mBackBuffer == window->attached() && mFrameCallback;
|
|
||||||
bool syncSubSurface = sub && sub->isSync();
|
|
||||||
if (waiting && !syncSubSurface) {
|
|
||||||
window->waitForFrameSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
window->setCanResize(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandShmBackingStore::endPaint()
|
void QWaylandShmBackingStore::endPaint()
|
||||||
@ -200,11 +187,6 @@ void QWaylandShmBackingStore::endPaint()
|
|||||||
|
|
||||||
void QWaylandShmBackingStore::hidden()
|
void QWaylandShmBackingStore::hidden()
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&mMutex);
|
|
||||||
if (mFrameCallback) {
|
|
||||||
wl_callback_destroy(mFrameCallback);
|
|
||||||
mFrameCallback = Q_NULLPTR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandShmBackingStore::ensureSize()
|
void QWaylandShmBackingStore::ensureSize()
|
||||||
@ -231,48 +213,15 @@ void QWaylandShmBackingStore::flush(QWindow *window, const QRegion ®ion, cons
|
|||||||
|
|
||||||
mFrontBuffer = mBackBuffer;
|
mFrontBuffer = mBackBuffer;
|
||||||
|
|
||||||
QWaylandWindow *w = waylandWindow();
|
|
||||||
bool synchModeSubSurface = w->subSurfaceWindow() && w->subSurfaceWindow()->isSync();
|
|
||||||
|
|
||||||
if (mFrameCallback) {
|
|
||||||
if (synchModeSubSurface) {
|
|
||||||
wl_callback_destroy(mFrameCallback);
|
|
||||||
mFrameCallback = Q_NULLPTR;
|
|
||||||
} else {
|
|
||||||
mFrontBufferIsDirty = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dont acquire the frame callback as that will cause beginPaint
|
|
||||||
// to block in waiting for frame sync since the damage will trigger
|
|
||||||
// its own sync request
|
|
||||||
if (!synchModeSubSurface) {
|
|
||||||
mFrameCallback = w->frame();
|
|
||||||
wl_callback_add_listener(mFrameCallback, &frameCallbackListener, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
QMargins margins = windowDecorationMargins();
|
QMargins margins = windowDecorationMargins();
|
||||||
bool damageAll = false;
|
|
||||||
if (w->attached() != mFrontBuffer) {
|
|
||||||
delete w->attached();
|
|
||||||
damageAll = true;
|
|
||||||
}
|
|
||||||
w->attachOffset(mFrontBuffer);
|
|
||||||
|
|
||||||
if (damageAll) {
|
waylandWindow()->attachOffset(mFrontBuffer);
|
||||||
//need to damage it all, otherwise the attach offset may screw up
|
mFrontBuffer->setBusy();
|
||||||
w->damage(QRect(QPoint(0,0), window->size()));
|
|
||||||
} else {
|
|
||||||
QVector<QRect> rects = region.rects();
|
QVector<QRect> rects = region.rects();
|
||||||
for (int i = 0; i < rects.size(); i++) {
|
foreach (const QRect &rect, rects)
|
||||||
QRect rect = rects.at(i);
|
waylandWindow()->damage(rect.translated(margins.left(), margins.top()));
|
||||||
rect.translate(margins.left(),margins.top());
|
waylandWindow()->commit();
|
||||||
w->damage(rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
w->commit();
|
|
||||||
mFrontBufferIsDirty = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandShmBackingStore::resize(const QSize &size, const QRegion &)
|
void QWaylandShmBackingStore::resize(const QSize &size, const QRegion &)
|
||||||
@ -280,22 +229,65 @@ void QWaylandShmBackingStore::resize(const QSize &size, const QRegion &)
|
|||||||
mRequestedSize = size;
|
mRequestedSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWaylandShmBuffer *QWaylandShmBackingStore::getBuffer(const QSize &size)
|
||||||
|
{
|
||||||
|
foreach (QWaylandShmBuffer *b, mBuffers) {
|
||||||
|
if (!b->busy()) {
|
||||||
|
if (b->size() == size) {
|
||||||
|
return b;
|
||||||
|
} else {
|
||||||
|
mBuffers.removeOne(b);
|
||||||
|
if (mBackBuffer == b)
|
||||||
|
mBackBuffer = 0;
|
||||||
|
delete b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const int MAX_BUFFERS = 5;
|
||||||
|
if (mBuffers.count() < MAX_BUFFERS) {
|
||||||
|
QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format();
|
||||||
|
QWaylandShmBuffer *b = new QWaylandShmBuffer(mDisplay, size, format, waylandWindow()->scale());
|
||||||
|
mBuffers.prepend(b);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void QWaylandShmBackingStore::resize(const QSize &size)
|
void QWaylandShmBackingStore::resize(const QSize &size)
|
||||||
{
|
{
|
||||||
QMargins margins = windowDecorationMargins();
|
QMargins margins = windowDecorationMargins();
|
||||||
int scale = waylandWindow()->scale();
|
int scale = waylandWindow()->scale();
|
||||||
QSize sizeWithMargins = (size + QSize(margins.left()+margins.right(),margins.top()+margins.bottom())) * scale;
|
QSize sizeWithMargins = (size + QSize(margins.left()+margins.right(),margins.top()+margins.bottom())) * scale;
|
||||||
|
|
||||||
QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format();
|
// We look for a free buffer to draw into. If the buffer is not the last buffer we used,
|
||||||
|
// that is mBackBuffer, and the size is the same we memcpy the old content into the new
|
||||||
|
// buffer so that QPainter is happy to find the stuff it had drawn before. If the new
|
||||||
|
// buffer has a different size it needs to be redrawn completely anyway, and if the buffer
|
||||||
|
// is the same the stuff is there already.
|
||||||
|
// You can exercise the different codepaths with weston, switching between the gl and the
|
||||||
|
// pixman renderer. With the gl renderer release events are sent early so we can effectively
|
||||||
|
// run single buffered, while with the pixman renderer we have to use two.
|
||||||
|
QWaylandShmBuffer *buffer = getBuffer(sizeWithMargins);
|
||||||
|
while (!buffer) {
|
||||||
|
qCDebug(logCategory, "QWaylandShmBackingStore: stalling waiting for a buffer to be released from the compositor...");
|
||||||
|
|
||||||
if (mBackBuffer != NULL && mBackBuffer->size() == sizeWithMargins)
|
mDisplay->blockingReadEvents();
|
||||||
return;
|
buffer = getBuffer(sizeWithMargins);
|
||||||
|
|
||||||
if (mBackBuffer != mFrontBuffer) {
|
|
||||||
delete mBackBuffer; //we delete the attached buffer when we flush
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mBackBuffer = new QWaylandShmBuffer(mDisplay, sizeWithMargins, format, scale);
|
int oldSize = mBackBuffer ? mBackBuffer->image()->byteCount() : 0;
|
||||||
|
// mBackBuffer may have been deleted here but if so it means its size was different so we wouldn't copy it anyway
|
||||||
|
if (mBackBuffer != buffer && oldSize == buffer->image()->byteCount()) {
|
||||||
|
memcpy(buffer->image()->bits(), mBackBuffer->image()->constBits(), buffer->image()->byteCount());
|
||||||
|
}
|
||||||
|
mBackBuffer = buffer;
|
||||||
|
// ensure the new buffer is at the beginning of the list so next time getBuffer() will pick
|
||||||
|
// it if possible
|
||||||
|
if (mBuffers.first() != buffer) {
|
||||||
|
mBuffers.removeOne(buffer);
|
||||||
|
mBuffers.prepend(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
if (windowDecoration() && window()->isVisible())
|
if (windowDecoration() && window()->isVisible())
|
||||||
windowDecoration()->update();
|
windowDecoration()->update();
|
||||||
@ -369,36 +361,6 @@ QImage QWaylandShmBackingStore::toImage() const
|
|||||||
}
|
}
|
||||||
#endif // QT_NO_OPENGL
|
#endif // QT_NO_OPENGL
|
||||||
|
|
||||||
void QWaylandShmBackingStore::done(void *data, wl_callback *callback, uint32_t time)
|
|
||||||
{
|
|
||||||
Q_UNUSED(time);
|
|
||||||
QWaylandShmBackingStore *self =
|
|
||||||
static_cast<QWaylandShmBackingStore *>(data);
|
|
||||||
if (callback != self->mFrameCallback) // others, like QWaylandWindow, may trigger callbacks too
|
|
||||||
return;
|
|
||||||
QMutexLocker lock(&self->mMutex);
|
|
||||||
QWaylandWindow *window = self->waylandWindow();
|
|
||||||
wl_callback_destroy(self->mFrameCallback);
|
|
||||||
self->mFrameCallback = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if (self->mFrontBufferIsDirty && !self->mPainting) {
|
|
||||||
self->mFrontBufferIsDirty = false;
|
|
||||||
self->mFrameCallback = wl_surface_frame(window->object());
|
|
||||||
wl_callback_add_listener(self->mFrameCallback,&self->frameCallbackListener,self);
|
|
||||||
if (self->mFrontBuffer != window->attached()) {
|
|
||||||
delete window->attached();
|
|
||||||
}
|
|
||||||
window->attachOffset(self->mFrontBuffer);
|
|
||||||
window->damage(QRect(QPoint(0,0),window->geometry().size()));
|
|
||||||
window->commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct wl_callback_listener QWaylandShmBackingStore::frameCallbackListener = {
|
|
||||||
QWaylandShmBackingStore::done
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
#include <QtGui/QImage>
|
#include <QtGui/QImage>
|
||||||
#include <qpa/qplatformwindow.h>
|
#include <qpa/qplatformwindow.h>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#include <QLinkedList>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -113,22 +114,17 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void updateDecorations();
|
void updateDecorations();
|
||||||
|
QWaylandShmBuffer *getBuffer(const QSize &size);
|
||||||
|
|
||||||
QWaylandDisplay *mDisplay;
|
QWaylandDisplay *mDisplay;
|
||||||
|
QLinkedList<QWaylandShmBuffer *> mBuffers;
|
||||||
QWaylandShmBuffer *mFrontBuffer;
|
QWaylandShmBuffer *mFrontBuffer;
|
||||||
QWaylandShmBuffer *mBackBuffer;
|
QWaylandShmBuffer *mBackBuffer;
|
||||||
bool mFrontBufferIsDirty;
|
|
||||||
bool mPainting;
|
bool mPainting;
|
||||||
QMutex mMutex;
|
QMutex mMutex;
|
||||||
|
|
||||||
QSize mRequestedSize;
|
QSize mRequestedSize;
|
||||||
Qt::WindowFlags mCurrentWindowFlags;
|
Qt::WindowFlags mCurrentWindowFlags;
|
||||||
|
|
||||||
static const struct wl_callback_listener frameCallbackListener;
|
|
||||||
static void done(void *data,
|
|
||||||
struct wl_callback *callback,
|
|
||||||
uint32_t time);
|
|
||||||
struct wl_callback *mFrameCallback;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
|
|||||||
, mMouseEventsInContentArea(false)
|
, mMouseEventsInContentArea(false)
|
||||||
, mMousePressedInContentArea(Qt::NoButton)
|
, mMousePressedInContentArea(Qt::NoButton)
|
||||||
, m_cursorShape(Qt::ArrowCursor)
|
, m_cursorShape(Qt::ArrowCursor)
|
||||||
, mBuffer(0)
|
|
||||||
, mWaitingForFrameSync(false)
|
, mWaitingForFrameSync(false)
|
||||||
, mFrameCallback(0)
|
, mFrameCallback(0)
|
||||||
, mRequestResizeSent(false)
|
, mRequestResizeSent(false)
|
||||||
@ -432,9 +431,8 @@ void QWaylandWindow::requestResize()
|
|||||||
|
|
||||||
void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
|
void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
|
||||||
{
|
{
|
||||||
mBuffer = buffer;
|
if (buffer)
|
||||||
if (mBuffer)
|
attach(buffer->buffer(), x, y);
|
||||||
attach(mBuffer->buffer(), x, y);
|
|
||||||
else
|
else
|
||||||
QtWayland::wl_surface::attach(0, 0, 0);
|
QtWayland::wl_surface::attach(0, 0, 0);
|
||||||
}
|
}
|
||||||
@ -445,11 +443,6 @@ void QWaylandWindow::attachOffset(QWaylandBuffer *buffer)
|
|||||||
mOffset = QPoint();
|
mOffset = QPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandBuffer *QWaylandWindow::attached() const
|
|
||||||
{
|
|
||||||
return mBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QWaylandWindow::damage(const QRect &rect)
|
void QWaylandWindow::damage(const QRect &rect)
|
||||||
{
|
{
|
||||||
//We have to do sync stuff before calling damage, or we might
|
//We have to do sync stuff before calling damage, or we might
|
||||||
@ -459,10 +452,8 @@ void QWaylandWindow::damage(const QRect &rect)
|
|||||||
wl_callback_add_listener(mFrameCallback,&QWaylandWindow::callbackListener,this);
|
wl_callback_add_listener(mFrameCallback,&QWaylandWindow::callbackListener,this);
|
||||||
mWaitingForFrameSync = true;
|
mWaitingForFrameSync = true;
|
||||||
}
|
}
|
||||||
if (mBuffer) {
|
|
||||||
damage(rect.x(), rect.y(), rect.width(), rect.height());
|
damage(rect.x(), rect.y(), rect.width(), rect.height());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const wl_callback_listener QWaylandWindow::callbackListener = {
|
const wl_callback_listener QWaylandWindow::callbackListener = {
|
||||||
QWaylandWindow::frameCallback
|
QWaylandWindow::frameCallback
|
||||||
|
@ -214,7 +214,6 @@ protected:
|
|||||||
Qt::MouseButtons mMousePressedInContentArea;
|
Qt::MouseButtons mMousePressedInContentArea;
|
||||||
Qt::CursorShape m_cursorShape;
|
Qt::CursorShape m_cursorShape;
|
||||||
|
|
||||||
QWaylandBuffer *mBuffer;
|
|
||||||
WId mWindowId;
|
WId mWindowId;
|
||||||
bool mWaitingForFrameSync;
|
bool mWaitingForFrameSync;
|
||||||
struct wl_callback *mFrameCallback;
|
struct wl_callback *mFrameCallback;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user