Remove excessive damage region clipping

We already try to ensure that the surface damage is within render target
bounds. Avoid clipping surface damage in render backend, which is a bit
excessive task and perhaps it should be done an abstraction level above.
This commit is contained in:
Vlad Zahorodnii 2022-02-21 13:45:46 +02:00
parent 05de198c41
commit e27ecfe88d
4 changed files with 7 additions and 14 deletions

View file

@ -254,9 +254,7 @@ void EglGbmBackend::aboutToStartPainting(AbstractOutput *output, const QRegion &
Q_ASSERT(m_surfaces.contains(output)); Q_ASSERT(m_surfaces.contains(output));
const auto &surface = m_surfaces[output]; const auto &surface = m_surfaces[output];
if (surface->bufferAge() > 0 && !damagedRegion.isEmpty() && supportsPartialUpdate()) { if (surface->bufferAge() > 0 && !damagedRegion.isEmpty() && supportsPartialUpdate()) {
const QRegion region = damagedRegion & output->geometry(); QVector<EGLint> rects = regionToRects(damagedRegion, static_cast<DrmAbstractOutput*>(output));
QVector<EGLint> rects = regionToRects(region, static_cast<DrmAbstractOutput*>(output));
const bool correct = eglSetDamageRegionKHR(eglDisplay(), surface->eglSurface(), rects.data(), rects.count()/4); const bool correct = eglSetDamageRegionKHR(eglDisplay(), surface->eglSurface(), rects.data(), rects.count()/4);
if (!correct) { if (!correct) {
qCWarning(KWIN_DRM) << "eglSetDamageRegionKHR failed:" << getEglErrorString(); qCWarning(KWIN_DRM) << "eglSetDamageRegionKHR failed:" << getEglErrorString();
@ -287,7 +285,7 @@ void EglGbmBackend::endFrame(AbstractOutput *output, const QRegion &renderedRegi
Q_UNUSED(renderedRegion) Q_UNUSED(renderedRegion)
m_surfaces[output]->endRendering(damagedRegion); m_surfaces[output]->endRendering(damagedRegion);
static_cast<DrmAbstractOutput*>(output)->present(m_surfaces[output]->currentBuffer(), damagedRegion & output->geometry()); static_cast<DrmAbstractOutput*>(output)->present(m_surfaces[output]->currentBuffer(), damagedRegion);
} }
bool EglGbmBackend::scanout(AbstractOutput *output, SurfaceItem *surfaceItem) bool EglGbmBackend::scanout(AbstractOutput *output, SurfaceItem *surfaceItem)

View file

@ -114,7 +114,7 @@ bool EglGbmLayer::endRendering(const QRegion &damagedRegion)
m_shadowBuffer->render(m_output); m_shadowBuffer->render(m_output);
} }
GLRenderTarget::popRenderTarget(); GLRenderTarget::popRenderTarget();
const auto buffer = m_gbmSurface->swapBuffersForDrm(damagedRegion.intersected(m_output->geometry())); const auto buffer = m_gbmSurface->swapBuffersForDrm(damagedRegion);
if (buffer) { if (buffer) {
m_currentBuffer = buffer; m_currentBuffer = buffer;
} }

View file

@ -315,9 +315,7 @@ void EglWaylandBackend::aboutToStartPainting(AbstractOutput *output, const QRegi
Q_ASSERT(m_outputs.contains(output)); Q_ASSERT(m_outputs.contains(output));
const auto &eglOutput = m_outputs[output]; const auto &eglOutput = m_outputs[output];
if (eglOutput->m_bufferAge > 0 && !damagedRegion.isEmpty() && supportsPartialUpdate()) { if (eglOutput->m_bufferAge > 0 && !damagedRegion.isEmpty() && supportsPartialUpdate()) {
const QRegion region = damagedRegion & eglOutput->m_waylandOutput->geometry(); QVector<EGLint> rects = regionToRects(damagedRegion, eglOutput->m_waylandOutput);
QVector<EGLint> rects = regionToRects(region, eglOutput->m_waylandOutput);
const bool correct = eglSetDamageRegionKHR(eglDisplay(), eglOutput->m_eglSurface, const bool correct = eglSetDamageRegionKHR(eglDisplay(), eglOutput->m_eglSurface,
rects.data(), rects.count()/4); rects.data(), rects.count()/4);
if (!correct) { if (!correct) {
@ -387,11 +385,10 @@ void EglWaylandBackend::endFrame(AbstractOutput *output, const QRegion &rendered
GLRenderTarget::popRenderTarget(); GLRenderTarget::popRenderTarget();
const auto &eglOutput = m_outputs[output]; const auto &eglOutput = m_outputs[output];
QRegion damage = damagedRegion.intersected(eglOutput->m_waylandOutput->geometry()); presentOnSurface(eglOutput, damagedRegion);
presentOnSurface(eglOutput, damage);
if (supportsBufferAge()) { if (supportsBufferAge()) {
eglOutput->m_damageJournal.add(damage); eglOutput->m_damageJournal.add(damagedRegion);
} }
} }

View file

@ -719,10 +719,8 @@ void Scene::clearStackingOrder()
stacking_order.clear(); stacking_order.clear();
} }
void Scene::paintWindow(Window* w, int mask, const QRegion &_region) void Scene::paintWindow(Window *w, int mask, const QRegion &region)
{ {
// no painting outside visible screen (and no transformations)
const QRegion region = _region & renderTargetRect();
if (region.isEmpty()) // completely clipped if (region.isEmpty()) // completely clipped
return; return;