platforms/drm: simplify deleted output handling
This commit is contained in:
parent
c89961a4e2
commit
92726372f4
5 changed files with 39 additions and 41 deletions
|
@ -687,4 +687,14 @@ DrmGpu *DrmBackend::findGpu(dev_t deviceId) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
DrmGpu *DrmBackend::findGpuByFd(int fd) const
|
||||
{
|
||||
for (DrmGpu *gpu : qAsConst(m_gpus)) {
|
||||
if (gpu->fd() == fd) {
|
||||
return gpu;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
|
||||
DrmGpu *primaryGpu() const;
|
||||
DrmGpu *findGpu(dev_t deviceId) const;
|
||||
DrmGpu *findGpuByFd(int fd) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void turnOutputsOn();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "logging.h"
|
||||
#include "session.h"
|
||||
#include "renderloop_p.h"
|
||||
#include "main.h"
|
||||
|
||||
#if HAVE_GBM
|
||||
#include "egl_gbm_backend.h"
|
||||
|
@ -390,7 +391,19 @@ static void pageFlipHandler(int fd, unsigned int frame, unsigned int sec, unsign
|
|||
Q_UNUSED(fd)
|
||||
Q_UNUSED(frame)
|
||||
|
||||
auto backend = dynamic_cast<DrmBackend*>(kwinApp()->platform());
|
||||
if (!backend) {
|
||||
return;
|
||||
}
|
||||
auto gpu = backend->findGpuByFd(fd);
|
||||
if (!gpu) {
|
||||
return;
|
||||
}
|
||||
auto output = static_cast<DrmOutput *>(data);
|
||||
if (!gpu->outputs().contains(output)) {
|
||||
// output already got deleted
|
||||
return;
|
||||
}
|
||||
|
||||
// The static_cast<> here are for a 32-bit environment where
|
||||
// sizeof(time_t) == sizeof(unsigned int) == 4 . Putting @p sec
|
||||
|
@ -426,13 +439,13 @@ void DrmGpu::removeOutput(DrmOutput *output)
|
|||
{
|
||||
m_outputs.removeOne(output);
|
||||
Q_EMIT outputRemoved(output);
|
||||
output->teardown();
|
||||
output->m_crtc = nullptr;
|
||||
m_connectors.removeOne(output->m_conn);
|
||||
delete output->m_conn;
|
||||
output->m_conn = nullptr;
|
||||
if (output->m_primaryPlane) {
|
||||
m_unusedPlanes << output->m_primaryPlane;
|
||||
auto connector = output->m_conn;
|
||||
auto primary = output->m_primaryPlane;
|
||||
delete output;
|
||||
m_connectors.removeOne(connector);
|
||||
delete connector;
|
||||
if (primary) {
|
||||
m_unusedPlanes << primary;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,21 +49,6 @@ DrmOutput::DrmOutput(DrmBackend *backend, DrmGpu *gpu)
|
|||
|
||||
DrmOutput::~DrmOutput()
|
||||
{
|
||||
Q_ASSERT(!m_pageFlipPending);
|
||||
teardown();
|
||||
}
|
||||
|
||||
RenderLoop *DrmOutput::renderLoop() const
|
||||
{
|
||||
return m_renderLoop;
|
||||
}
|
||||
|
||||
void DrmOutput::teardown()
|
||||
{
|
||||
if (m_deleted) {
|
||||
return;
|
||||
}
|
||||
m_deleted = true;
|
||||
hideCursor();
|
||||
m_crtc->blank(this);
|
||||
|
||||
|
@ -74,10 +59,14 @@ void DrmOutput::teardown()
|
|||
|
||||
m_cursor[0].reset(nullptr);
|
||||
m_cursor[1].reset(nullptr);
|
||||
if (!m_pageFlipPending) {
|
||||
deleteLater();
|
||||
} //else will be deleted in the page flip handler
|
||||
//this is needed so that the pageflipcallback handle isn't deleted
|
||||
if (m_pageFlipPending) {
|
||||
pageFlipped();
|
||||
}
|
||||
}
|
||||
|
||||
RenderLoop *DrmOutput::renderLoop() const
|
||||
{
|
||||
return m_renderLoop;
|
||||
}
|
||||
|
||||
bool DrmOutput::hideCursor()
|
||||
|
@ -105,10 +94,6 @@ bool DrmOutput::showCursor(DrmDumbBuffer *c)
|
|||
|
||||
bool DrmOutput::showCursor()
|
||||
{
|
||||
if (m_deleted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool ret = showCursor(m_cursor[m_cursorIndex].data());
|
||||
if (!ret) {
|
||||
qCDebug(KWIN_DRM) << "DrmOutput::showCursor(DrmDumbBuffer) failed";
|
||||
|
@ -141,9 +126,6 @@ static bool isCursorSpriteCompatible(const QImage *buffer, const QImage *sprite)
|
|||
|
||||
bool DrmOutput::updateCursor()
|
||||
{
|
||||
if (m_deleted) {
|
||||
return false;
|
||||
}
|
||||
const Cursor *cursor = Cursors::self()->currentCursor();
|
||||
const QImage cursorImage = cursor->image();
|
||||
if (cursorImage.isNull()) {
|
||||
|
@ -526,11 +508,6 @@ void DrmOutput::pageFlipped()
|
|||
Q_ASSERT(m_pageFlipPending || !m_gpu->atomicModeSetting());
|
||||
m_pageFlipPending = false;
|
||||
|
||||
if (m_deleted) {
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_crtc) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ public:
|
|||
|
||||
RenderLoop *renderLoop() const override;
|
||||
|
||||
///queues deleting the output after a page flip has completed.
|
||||
void teardown();
|
||||
bool showCursor(DrmDumbBuffer *buffer);
|
||||
bool showCursor();
|
||||
bool hideCursor();
|
||||
|
@ -161,7 +159,6 @@ private:
|
|||
QScopedPointer<DrmDumbBuffer> m_cursor[2];
|
||||
int m_cursorIndex = 0;
|
||||
bool m_hasNewCursor = false;
|
||||
bool m_deleted = false;
|
||||
QTimer m_turnOffTimer;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue