The QPainterDRMBackend uses a double buffered setup. Thus we know which parts changed in last frame and don't need to repaint the complete buffer, but just the changes.
Description
Hey
I've been looking at this and wanted to make sure if I understood this correctly before writing a patch.
In order to implement this, we would need to adjust DrmQPainterBackend::needsFullRepaint to return false and then just adjust DrmQPainterBackend::present to use the damage region? Or is there more to this?
Oh, after reading the code a bit more, would it be more sensible to simply skip presenting the buffer if it hasn't changed? Something like so ( I couldn't quite figure out how else to compare two DrmDumbBuffers ) :
diff --git a/plugins/platforms/drm/scene_qpainter_drm_backend.cpp b/plugins/platforms/drm/scene_qpainter_drm_backend.cpp index bf5a000a3..624fe42e6 100644 --- a/plugins/platforms/drm/scene_qpainter_drm_backend.cpp +++ b/plugins/platforms/drm/scene_qpainter_drm_backend.cpp @@ -106,6 +106,13 @@ void DrmQPainterBackend::present(int mask, const QRegion &damage) } for (auto it = m_outputs.begin(); it != m_outputs.end(); ++it) { const Output &o = *it; + + auto *old_buffer = o.buffer[o.index - 1]->image(); + auto *new_buffer = o.buffer[o.index]->image(); + if (*old_buffer == *new_buffer) { + continue; + } + m_backend->present(o.buffer[o.index], o.output); } }
Not really you're doing a full pixel by pixel image comparison, that'll take more time than you'll save.
If you want to see if nothing changed you can check if damage is empty.
So I was thinking of somehow clipping the buffer that we present to the backend to only represent the damaged region. I'm not quite sure yet how to clip the QImage to the damaged QRegion we have, but does that sound sensible?