2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2019-02-21 22:25:19 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
|
2019-02-21 22:25:19 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2019-02-21 22:25:19 +00:00
|
|
|
#include "generic_scene_opengl_test.h"
|
|
|
|
|
|
|
|
#include "composite.h"
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
#include "scene.h"
|
2019-02-21 22:25:19 +00:00
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2019-02-21 22:25:19 +00:00
|
|
|
|
|
|
|
#include <KWayland/Client/subsurface.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_buffer_size_change-0");
|
|
|
|
|
|
|
|
class BufferSizeChangeTest : public GenericSceneOpenGLTest
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2022-03-23 10:13:38 +00:00
|
|
|
BufferSizeChangeTest()
|
|
|
|
: GenericSceneOpenGLTest(QByteArrayLiteral("O2"))
|
|
|
|
{
|
|
|
|
}
|
2019-02-21 22:25:19 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void init();
|
|
|
|
void testShmBufferSizeChange();
|
|
|
|
void testShmBufferSizeChangeOnSubSurface();
|
|
|
|
};
|
|
|
|
|
|
|
|
void BufferSizeChangeTest::init()
|
|
|
|
{
|
|
|
|
QVERIFY(Test::setupWaylandConnection());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BufferSizeChangeTest::testShmBufferSizeChange()
|
|
|
|
{
|
|
|
|
// This test verifies that an SHM buffer size change is handled correctly
|
|
|
|
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2019-02-21 22:25:19 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2019-02-21 22:25:19 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
|
|
|
|
// set buffer size
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
2019-02-21 22:25:19 +00:00
|
|
|
QVERIFY(client);
|
|
|
|
|
|
|
|
// add a first repaint
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
QSignalSpy frameRenderedSpy(Compositor::self()->scene(), &Scene::frameRendered);
|
|
|
|
QVERIFY(frameRenderedSpy.isValid());
|
2021-11-09 10:36:24 +00:00
|
|
|
Compositor::self()->scene()->addRepaintFull();
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
2019-02-21 22:25:19 +00:00
|
|
|
|
|
|
|
// now change buffer size
|
|
|
|
Test::render(surface.data(), QSize(30, 10), Qt::red);
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
QSignalSpy damagedSpy(client, &Window::damaged);
|
2019-02-21 22:25:19 +00:00
|
|
|
QVERIFY(damagedSpy.isValid());
|
|
|
|
QVERIFY(damagedSpy.wait());
|
2021-11-09 10:36:24 +00:00
|
|
|
KWin::Compositor::self()->scene()->addRepaintFull();
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
2019-02-21 22:25:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BufferSizeChangeTest::testShmBufferSizeChangeOnSubSurface()
|
|
|
|
{
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
|
|
|
// setup parent surface
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> parentSurface(Test::createSurface());
|
2019-02-21 22:25:19 +00:00
|
|
|
QVERIFY(!parentSurface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(parentSurface.data()));
|
2019-02-21 22:25:19 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
|
|
|
|
// setup sub surface
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2019-02-21 22:25:19 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
|
|
|
QScopedPointer<SubSurface> subSurface(Test::createSubSurface(surface.data(), parentSurface.data()));
|
|
|
|
QVERIFY(!subSurface.isNull());
|
|
|
|
|
|
|
|
// set buffer sizes
|
|
|
|
Test::render(surface.data(), QSize(30, 10), Qt::red);
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *parent = Test::renderAndWaitForShown(parentSurface.data(), QSize(100, 50), Qt::blue);
|
2019-02-21 22:25:19 +00:00
|
|
|
QVERIFY(parent);
|
|
|
|
|
|
|
|
// add a first repaint
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
QSignalSpy frameRenderedSpy(Compositor::self()->scene(), &Scene::frameRendered);
|
|
|
|
QVERIFY(frameRenderedSpy.isValid());
|
2021-11-09 10:36:24 +00:00
|
|
|
Compositor::self()->scene()->addRepaintFull();
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
2019-02-21 22:25:19 +00:00
|
|
|
|
|
|
|
// change buffer size of sub surface
|
2022-04-22 17:39:12 +00:00
|
|
|
QSignalSpy damagedParentSpy(parent, &Window::damaged);
|
2019-02-21 22:25:19 +00:00
|
|
|
QVERIFY(damagedParentSpy.isValid());
|
|
|
|
Test::render(surface.data(), QSize(20, 10), Qt::red);
|
2021-09-03 17:54:03 +00:00
|
|
|
parentSurface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2019-02-21 22:25:19 +00:00
|
|
|
|
|
|
|
QVERIFY(damagedParentSpy.wait());
|
|
|
|
|
|
|
|
// add a second repaint
|
2021-11-09 10:36:24 +00:00
|
|
|
KWin::Compositor::self()->scene()->addRepaintFull();
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
QVERIFY(frameRenderedSpy.wait());
|
2019-02-21 22:25:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
WAYLANDTEST_MAIN(KWin::BufferSizeChangeTest)
|
|
|
|
#include "buffer_size_change_test.moc"
|