Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KWin
Commits
5bd938f0
Commit
5bd938f0
authored
May 02, 2021
by
Xaver Hugl
Committed by
Aleix Pol Gonzalez
May 04, 2021
Browse files
platforms/drm: release gbm buffers before eglDestroySurface
BUG: 436500
parent
49fcadb1
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/plugins/platforms/drm/drm_buffer.h
View file @
5bd938f0
...
...
@@ -25,6 +25,8 @@ public:
virtual
bool
needsModeChange
(
DrmBuffer
*
b
)
const
{
Q_UNUSED
(
b
)
return
false
;}
virtual
void
releaseGbm
()
{}
quint32
bufferId
()
const
{
return
m_bufferId
;
}
...
...
src/plugins/platforms/drm/drm_buffer_gbm.cpp
View file @
5bd938f0
...
...
@@ -45,15 +45,21 @@ GbmBuffer::GbmBuffer(gbm_bo *buffer, KWaylandServer::BufferInterface *bufferInte
}
GbmBuffer
::~
GbmBuffer
()
{
releaseBuffer
();
}
void
GbmBuffer
::
releaseBuffer
()
{
if
(
m_bufferInterface
)
{
clearBufferInterface
();
}
if
(
m_surface
)
{
if
(
m_surface
&&
m_bo
)
{
m_surface
->
releaseBuffer
(
m_bo
);
}
else
if
(
m_bo
)
{
gbm_bo_destroy
(
m_bo
);
}
m_bo
=
nullptr
;
}
void
GbmBuffer
::
clearBufferInterface
()
...
...
@@ -86,6 +92,11 @@ DrmGbmBuffer::~DrmGbmBuffer()
}
}
void
DrmGbmBuffer
::
releaseGbm
()
{
releaseBuffer
();
}
void
DrmGbmBuffer
::
initialize
()
{
m_size
=
QSize
(
gbm_bo_get_width
(
m_bo
),
gbm_bo_get_height
(
m_bo
));
...
...
src/plugins/platforms/drm/drm_buffer_gbm.h
View file @
5bd938f0
...
...
@@ -38,6 +38,8 @@ public:
return
m_bo
;
}
void
releaseBuffer
();
protected:
QSharedPointer
<
GbmSurface
>
m_surface
;
gbm_bo
*
m_bo
=
nullptr
;
...
...
@@ -61,6 +63,8 @@ public:
}
}
void
releaseGbm
()
override
;
bool
hasBo
()
const
{
return
m_bo
!=
nullptr
;
}
...
...
src/plugins/platforms/drm/drm_output.cpp
View file @
5bd938f0
...
...
@@ -75,6 +75,24 @@ void DrmOutput::teardown()
//this is needed so that the pageflipcallback handle isn't deleted
}
void
DrmOutput
::
releaseGbm
()
{
if
(
auto
buffer
=
m_crtc
->
current
())
{
buffer
->
releaseGbm
();
}
if
(
auto
buffer
=
m_crtc
->
next
())
{
buffer
->
releaseGbm
();
}
if
(
m_primaryPlane
)
{
if
(
auto
buffer
=
m_primaryPlane
->
current
())
{
buffer
->
releaseGbm
();
}
if
(
auto
buffer
=
m_primaryPlane
->
next
())
{
buffer
->
releaseGbm
();
}
}
}
bool
DrmOutput
::
hideCursor
()
{
if
(
RenderLoopPrivate
::
get
(
m_renderLoop
)
->
presentMode
==
RenderLoopPrivate
::
SyncMode
::
Adaptive
...
...
src/plugins/platforms/drm/drm_output.h
View file @
5bd938f0
...
...
@@ -44,6 +44,7 @@ public:
///queues deleting the output after a page flip has completed.
void
teardown
();
void
releaseGbm
();
bool
showCursor
(
DrmDumbBuffer
*
buffer
);
bool
showCursor
();
bool
hideCursor
();
...
...
src/plugins/platforms/drm/egl_gbm_backend.cpp
View file @
5bd938f0
...
...
@@ -71,9 +71,9 @@ void EglGbmBackend::cleanupOutput(Output &output)
{
cleanupFramebuffer
(
output
);
output
.
buffer
=
nullptr
;
output
.
secondaryBuffer
=
nullptr
;
if
(
output
.
eglSurface
!=
EGL_NO_SURFACE
)
{
// gbm buffers have to be released before destroying the egl surface
output
.
output
->
releaseGbm
();
eglDestroySurface
(
eglDisplay
(),
output
.
eglSurface
);
}
}
...
...
@@ -200,6 +200,8 @@ bool EglGbmBackend::resetOutput(Output &output, DrmOutput *drmOutput)
// destroy previous surface
if
(
output
.
eglSurface
!=
EGL_NO_SURFACE
)
{
// gbm buffers have to be released before destroying the egl surface
output
.
output
->
releaseGbm
();
eglDestroySurface
(
eglDisplay
(),
output
.
eglSurface
);
}
output
.
eglSurface
=
eglSurface
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment