Commit 3ea14d6e authored by Xaver Hugl's avatar Xaver Hugl
Browse files

backends: use std::unique_ptr for RenderLoop

parent a38a44cb
Pipeline #193901 passed with stage
in 14 minutes and 12 seconds
......@@ -16,24 +16,24 @@ namespace KWin
DrmAbstractOutput::DrmAbstractOutput(DrmGpu *gpu)
: Output(gpu->platform())
, m_renderLoop(new RenderLoop(this))
, m_renderLoop(std::make_unique<RenderLoop>())
, m_gpu(gpu)
{
}
RenderLoop *DrmAbstractOutput::renderLoop() const
{
return m_renderLoop;
return m_renderLoop.get();
}
void DrmAbstractOutput::frameFailed() const
{
RenderLoopPrivate::get(m_renderLoop)->notifyFrameFailed();
RenderLoopPrivate::get(m_renderLoop.get())->notifyFrameFailed();
}
void DrmAbstractOutput::pageFlipped(std::chrono::nanoseconds timestamp) const
{
RenderLoopPrivate::get(m_renderLoop)->notifyFrameCompleted(timestamp);
RenderLoopPrivate::get(m_renderLoop.get())->notifyFrameCompleted(timestamp);
}
QVector<int32_t> DrmAbstractOutput::regionToRects(const QRegion &region) const
......
......@@ -35,7 +35,7 @@ public:
protected:
friend class DrmGpu;
RenderLoop *m_renderLoop;
std::unique_ptr<RenderLoop> m_renderLoop;
DrmGpu *const m_gpu;
};
......
......@@ -309,7 +309,7 @@ void DrmOutput::updateModes()
bool DrmOutput::present()
{
RenderLoopPrivate *renderLoopPrivate = RenderLoopPrivate::get(m_renderLoop);
RenderLoopPrivate *renderLoopPrivate = RenderLoopPrivate::get(m_renderLoop.get());
if (m_pipeline->syncMode() != renderLoopPrivate->presentMode) {
m_pipeline->setSyncMode(renderLoopPrivate->presentMode);
if (DrmPipeline::commitPipelines({m_pipeline}, DrmPipeline::CommitMode::Test)) {
......
......@@ -54,8 +54,7 @@ bool DrmVirtualOutput::present()
void DrmVirtualOutput::vblank(std::chrono::nanoseconds timestamp)
{
if (m_pageFlipPending) {
RenderLoopPrivate *renderLoopPrivate = RenderLoopPrivate::get(m_renderLoop);
renderLoopPrivate->notifyFrameCompleted(timestamp);
DrmAbstractOutput::pageFlipped(timestamp);
}
}
......
......@@ -18,7 +18,7 @@ namespace KWin
VirtualOutput::VirtualOutput(VirtualBackend *parent)
: Output(parent)
, m_backend(parent)
, m_renderLoop(new RenderLoop(this))
, m_renderLoop(std::make_unique<RenderLoop>())
, m_vsyncMonitor(SoftwareVsyncMonitor::create())
{
connect(m_vsyncMonitor.get(), &VsyncMonitor::vblankOccurred, this, &VirtualOutput::vblank);
......@@ -36,7 +36,7 @@ VirtualOutput::~VirtualOutput()
RenderLoop *VirtualOutput::renderLoop() const
{
return m_renderLoop;
return m_renderLoop.get();
}
SoftwareVsyncMonitor *VirtualOutput::vsyncMonitor() const
......@@ -62,7 +62,7 @@ void VirtualOutput::setGeometry(const QRect &geo)
void VirtualOutput::vblank(std::chrono::nanoseconds timestamp)
{
RenderLoopPrivate *renderLoopPrivate = RenderLoopPrivate::get(m_renderLoop);
RenderLoopPrivate *renderLoopPrivate = RenderLoopPrivate::get(m_renderLoop.get());
renderLoopPrivate->notifyFrameCompleted(timestamp);
}
......
......@@ -42,7 +42,7 @@ private:
friend class VirtualBackend;
VirtualBackend *m_backend;
RenderLoop *m_renderLoop;
std::unique_ptr<RenderLoop> m_renderLoop;
std::unique_ptr<SoftwareVsyncMonitor> m_vsyncMonitor;
int m_gammaSize = 200;
bool m_gammaResult = true;
......
......@@ -26,7 +26,7 @@ static const int s_refreshRate = 60000; // TODO: can we get refresh rate data fr
WaylandOutput::WaylandOutput(const QString &name, Surface *surface, WaylandBackend *backend)
: Output(backend)
, m_renderLoop(new RenderLoop(this))
, m_renderLoop(std::make_unique<RenderLoop>())
, m_surface(surface)
, m_backend(backend)
{
......@@ -54,7 +54,7 @@ WaylandOutput::~WaylandOutput()
RenderLoop *WaylandOutput::renderLoop() const
{
return m_renderLoop;
return m_renderLoop.get();
}
void WaylandOutput::init(const QPoint &logicalPosition, const QSize &pixelSize)
......
......@@ -93,7 +93,7 @@ protected:
}
private:
RenderLoop *m_renderLoop;
std::unique_ptr<RenderLoop> m_renderLoop;
KWayland::Client::Surface *m_surface;
WaylandBackend *m_backend;
QTimer m_turnOffTimer;
......
......@@ -101,7 +101,7 @@ X11StandalonePlatform::X11StandalonePlatform(QObject *parent)
, m_session(Session::create(Session::Type::Noop))
, m_updateOutputsTimer(new QTimer(this))
, m_x11Display(QX11Info::display())
, m_renderLoop(new RenderLoop(this))
, m_renderLoop(std::make_unique<RenderLoop>())
{
#if HAVE_X11_XINPUT
if (!qEnvironmentVariableIsSet("KWIN_NO_XI2")) {
......@@ -546,7 +546,7 @@ void X11StandalonePlatform::doUpdateOutputs()
// drm platform do this.
Xcb::RandR::CrtcGamma gamma(crtcs[i]);
output->setRenderLoop(m_renderLoop);
output->setRenderLoop(m_renderLoop.get());
output->setCrtc(crtcs[i]);
output->setGammaRampSize(gamma.isNull() ? 0 : gamma->size);
output->setMode(geometry.size(), refreshRate * 1000);
......@@ -580,7 +580,7 @@ void X11StandalonePlatform::doUpdateOutputs()
// The workspace handles having no outputs poorly. If the last output is about to be
// removed, create a dummy output to avoid crashing.
if (changed.isEmpty() && added.isEmpty()) {
auto dummyOutput = new X11PlaceholderOutput(m_renderLoop);
auto dummyOutput = new X11PlaceholderOutput(m_renderLoop.get());
m_outputs << dummyOutput;
Q_EMIT outputAdded(dummyOutput);
Q_EMIT outputEnabled(dummyOutput);
......@@ -640,7 +640,7 @@ Outputs X11StandalonePlatform::enabledOutputs() const
RenderLoop *X11StandalonePlatform::renderLoop() const
{
return m_renderLoop;
return m_renderLoop.get();
}
static bool refreshRate_compare(const Output *first, const Output *smallest)
......
......@@ -96,7 +96,7 @@ private:
std::unique_ptr<WindowSelector> m_windowSelector;
std::unique_ptr<X11EventFilter> m_screenEdgesFilter;
std::unique_ptr<X11EventFilter> m_randrEventFilter;
RenderLoop *m_renderLoop;
std::unique_ptr<RenderLoop> m_renderLoop;
QVector<Output *> m_outputs;
};
......
......@@ -27,7 +27,7 @@ namespace KWin
X11WindowedOutput::X11WindowedOutput(X11WindowedBackend *backend)
: Output(backend)
, m_renderLoop(new RenderLoop(this))
, m_renderLoop(std::make_unique<RenderLoop>())
, m_vsyncMonitor(SoftwareVsyncMonitor::create())
, m_backend(backend)
{
......@@ -51,7 +51,7 @@ X11WindowedOutput::~X11WindowedOutput()
RenderLoop *X11WindowedOutput::renderLoop() const
{
return m_renderLoop;
return m_renderLoop.get();
}
SoftwareVsyncMonitor *X11WindowedOutput::vsyncMonitor() const
......@@ -172,7 +172,7 @@ QPointF X11WindowedOutput::mapFromGlobal(const QPointF &pos) const
void X11WindowedOutput::vblank(std::chrono::nanoseconds timestamp)
{
RenderLoopPrivate *renderLoopPrivate = RenderLoopPrivate::get(m_renderLoop);
RenderLoopPrivate *renderLoopPrivate = RenderLoopPrivate::get(m_renderLoop.get());
renderLoopPrivate->notifyFrameCompleted(timestamp);
}
......
......@@ -75,7 +75,7 @@ private:
xcb_window_t m_window = XCB_WINDOW_NONE;
std::unique_ptr<NETWinInfo> m_winInfo;
RenderLoop *m_renderLoop;
std::unique_ptr<RenderLoop> m_renderLoop;
std::unique_ptr<SoftwareVsyncMonitor> m_vsyncMonitor;
QPoint m_hostPosition;
......
......@@ -20,7 +20,7 @@ T alignTimestamp(const T &timestamp, const T &alignment)
RenderLoopPrivate *RenderLoopPrivate::get(RenderLoop *loop)
{
return loop->d.data();
return loop->d.get();
}
RenderLoopPrivate::RenderLoopPrivate(RenderLoop *q)
......@@ -162,9 +162,8 @@ void RenderLoopPrivate::invalidate()
compositeTimer.stop();
}
RenderLoop::RenderLoop(QObject *parent)
: QObject(parent)
, d(new RenderLoopPrivate(this))
RenderLoop::RenderLoop()
: d(std::make_unique<RenderLoopPrivate>(this))
{
}
......
......@@ -30,7 +30,7 @@ class KWIN_EXPORT RenderLoop : public QObject
Q_OBJECT
public:
explicit RenderLoop(QObject *parent = nullptr);
explicit RenderLoop();
~RenderLoop() override;
/**
......@@ -145,7 +145,7 @@ Q_SIGNALS:
void frameRequested(RenderLoop *loop);
private:
QScopedPointer<RenderLoopPrivate> d;
std::unique_ptr<RenderLoopPrivate> d;
friend class RenderLoopPrivate;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment