Commit 5a57eeaf authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

platforms/drm: Fix crash in EglGbmBackend::presentOnOutput()

If the damage history is empty and EGL_KHR_partial_update is supported,
kwin may crash.

(cherry picked from commit 913d242b)
parent d214bebc
......@@ -572,7 +572,7 @@ bool EglGbmBackend::presentOnOutput(Output &output, const QRegion &damagedRegion
{
if (isPrimary()) {
if (supportsSwapBuffersWithDamage()) {
QVector<EGLint> rects = regionToRects(output.damageHistory.constFirst(), output.output);
QVector<EGLint> rects = regionToRects(damagedRegion, output.output);
if (!eglSwapBuffersWithDamageEXT(eglDisplay(), output.eglSurface,
rects.data(), rects.count() / 4)) {
qCCritical(KWIN_DRM, "eglSwapBuffersWithDamageEXT() failed: %x", eglGetError());
......@@ -659,7 +659,8 @@ void EglGbmBackend::endFrame(int screenId, const QRegion &renderedRegion,
renderFramebufferToSurface(output);
if (!presentOnOutput(output, damagedRegion)) {
const QRegion dirty = damagedRegion.intersected(output.output->geometry());
if (!presentOnOutput(output, dirty)) {
output.damageHistory.clear();
RenderLoopPrivate *renderLoopPrivate = RenderLoopPrivate::get(drmOutput->renderLoop());
renderLoopPrivate->notifyFrameFailed();
......@@ -667,7 +668,6 @@ void EglGbmBackend::endFrame(int screenId, const QRegion &renderedRegion,
}
if (supportsBufferAge()) {
const QRegion dirty = damagedRegion.intersected(output.output->geometry());
if (output.damageHistory.count() > 10) {
output.damageHistory.removeLast();
}
......
Markdown is supported
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