diff --git a/platformsupport/scenes/opengl/backend.h b/platformsupport/scenes/opengl/backend.h index 5f3991fce7..d2499a0ec2 100644 --- a/platformsupport/scenes/opengl/backend.h +++ b/platformsupport/scenes/opengl/backend.h @@ -50,28 +50,12 @@ public: virtual void screenGeometryChanged(const QSize &size) = 0; virtual SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) = 0; - /** - * @brief Backend specific code to prepare the rendering of a frame including flushing the - * previously rendered frame to the screen if the backend works this way. - * - * @return A region that if not empty will be repainted in addition to the damaged region - */ - virtual QRegion prepareRenderingFrame() = 0; - /** * Notifies about starting to paint. * * @p damage contains the reported damage as suggested by windows and effects on prepaint calls. */ virtual void aboutToStartPainting(int screenId, const QRegion &damage); - - /** - * @brief Backend specific code to handle the end of rendering a frame. - * - * @param renderedRegion The possibly larger region that has been rendered - * @param damagedRegion The damaged region that should be posted - */ - virtual void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) = 0; virtual void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion); virtual bool makeCurrent() = 0; virtual void doneCurrent() = 0; diff --git a/plugins/platforms/drm/egl_gbm_backend.cpp b/plugins/platforms/drm/egl_gbm_backend.cpp index 58bc1aee45..24e9f6903e 100644 --- a/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/plugins/platforms/drm/egl_gbm_backend.cpp @@ -511,11 +511,6 @@ SceneOpenGLTexturePrivate *EglGbmBackend::createBackendTexture(SceneOpenGLTextur return new EglGbmTexture(texture, this); } -QRegion EglGbmBackend::prepareRenderingFrame() -{ - return QRegion(); -} - void EglGbmBackend::setViewport(const Output &output) const { const QSize &overall = screens()->size(); @@ -550,12 +545,6 @@ QRegion EglGbmBackend::prepareRenderingForScreen(int screenId) return output.output->geometry(); } -void EglGbmBackend::endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) -{ - Q_UNUSED(renderedRegion) - Q_UNUSED(damagedRegion) -} - void EglGbmBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) diff --git a/plugins/platforms/drm/egl_gbm_backend.h b/plugins/platforms/drm/egl_gbm_backend.h index e64c39feb1..8a21bda8f7 100644 --- a/plugins/platforms/drm/egl_gbm_backend.h +++ b/plugins/platforms/drm/egl_gbm_backend.h @@ -35,8 +35,6 @@ public: ~EglGbmBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; - QRegion prepareRenderingFrame() override; - void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; bool usesOverlayWindow() const override; bool perScreenRendering() const override; diff --git a/plugins/platforms/drm/egl_stream_backend.cpp b/plugins/platforms/drm/egl_stream_backend.cpp index 29205f6277..10b2cb9444 100644 --- a/plugins/platforms/drm/egl_stream_backend.cpp +++ b/plugins/platforms/drm/egl_stream_backend.cpp @@ -475,11 +475,6 @@ SceneOpenGLTexturePrivate *EglStreamBackend::createBackendTexture(SceneOpenGLTex return new EglStreamTexture(texture, this); } -QRegion EglStreamBackend::prepareRenderingFrame() -{ - return QRegion(); -} - QRegion EglStreamBackend::prepareRenderingForScreen(int screenId) { const Output &o = m_outputs.at(screenId); @@ -487,12 +482,6 @@ QRegion EglStreamBackend::prepareRenderingForScreen(int screenId) return o.output->geometry(); } -void EglStreamBackend::endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) -{ - Q_UNUSED(renderedRegion) - Q_UNUSED(damagedRegion) -} - void EglStreamBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) { Q_UNUSED(renderedRegion); diff --git a/plugins/platforms/drm/egl_stream_backend.h b/plugins/platforms/drm/egl_stream_backend.h index 9d99bc743a..8013078757 100644 --- a/plugins/platforms/drm/egl_stream_backend.h +++ b/plugins/platforms/drm/egl_stream_backend.h @@ -32,8 +32,6 @@ public: ~EglStreamBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; - QRegion prepareRenderingFrame() override; - void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; bool usesOverlayWindow() const override; bool perScreenRendering() const override; diff --git a/plugins/platforms/hwcomposer/egl_hwcomposer_backend.cpp b/plugins/platforms/hwcomposer/egl_hwcomposer_backend.cpp index 74dc036317..8ac642f827 100644 --- a/plugins/platforms/hwcomposer/egl_hwcomposer_backend.cpp +++ b/plugins/platforms/hwcomposer/egl_hwcomposer_backend.cpp @@ -140,8 +140,9 @@ void EglHwcomposerBackend::screenGeometryChanged(const QSize &size) Q_UNUSED(size) } -QRegion EglHwcomposerBackend::prepareRenderingFrame() +QRegion EglHwcomposerBackend::prepareRenderingFrame(int screenId) { + Q_UNUSED(screenId) present(); // TODO: buffer age? @@ -149,8 +150,9 @@ QRegion EglHwcomposerBackend::prepareRenderingFrame() return QRegion(QRect(QPoint(0, 0), m_backend->size())); } -void EglHwcomposerBackend::endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) +void EglHwcomposerBackend::endRenderingFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) { + Q_UNUSED(screenId) Q_UNUSED(damagedRegion) setLastDamage(renderedRegion); } diff --git a/plugins/platforms/hwcomposer/egl_hwcomposer_backend.h b/plugins/platforms/hwcomposer/egl_hwcomposer_backend.h index db0ba4d655..5a361f6d27 100644 --- a/plugins/platforms/hwcomposer/egl_hwcomposer_backend.h +++ b/plugins/platforms/hwcomposer/egl_hwcomposer_backend.h @@ -24,8 +24,8 @@ public: bool usesOverlayWindow() const override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; void screenGeometryChanged(const QSize &size) override; - QRegion prepareRenderingFrame() override; - void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; + QRegion prepareRenderingFrame(int screenId) override; + void endRenderingFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) override; void init() override; protected: diff --git a/plugins/platforms/virtual/egl_gbm_backend.cpp b/plugins/platforms/virtual/egl_gbm_backend.cpp index c3b08956ff..597192fb43 100644 --- a/plugins/platforms/virtual/egl_gbm_backend.cpp +++ b/plugins/platforms/virtual/egl_gbm_backend.cpp @@ -162,8 +162,9 @@ SceneOpenGLTexturePrivate *EglGbmBackend::createBackendTexture(SceneOpenGLTextur return new EglGbmTexture(texture, this); } -QRegion EglGbmBackend::prepareRenderingFrame() +QRegion EglGbmBackend::prepareRenderingForScreen(int screenId) { + Q_UNUSED(screenId) if (!lastDamage().isEmpty()) { present(); } @@ -204,8 +205,9 @@ static void convertFromGLImage(QImage &img, int w, int h) img = img.mirrored(); } -void EglGbmBackend::endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) +void EglGbmBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) { + Q_UNUSED(screenId) Q_UNUSED(damagedRegion) glFlush(); if (m_backend->saveFrames()) { diff --git a/plugins/platforms/virtual/egl_gbm_backend.h b/plugins/platforms/virtual/egl_gbm_backend.h index 350b8b08db..608be626c1 100644 --- a/plugins/platforms/virtual/egl_gbm_backend.h +++ b/plugins/platforms/virtual/egl_gbm_backend.h @@ -26,8 +26,8 @@ public: ~EglGbmBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; - QRegion prepareRenderingFrame() override; - void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; + QRegion prepareRenderingForScreen(int screenId) override; + void endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) override; bool usesOverlayWindow() const override; void init() override; diff --git a/plugins/platforms/wayland/egl_wayland_backend.cpp b/plugins/platforms/wayland/egl_wayland_backend.cpp index ef7001a9cd..34bb53c1eb 100644 --- a/plugins/platforms/wayland/egl_wayland_backend.cpp +++ b/plugins/platforms/wayland/egl_wayland_backend.cpp @@ -325,10 +325,7 @@ void EglWaylandBackend::aboutToStartPainting(int screenId, const QRegion &damage void EglWaylandBackend::presentOnSurface(EglWaylandOutput *output, const QRegion &damage) { output->m_waylandOutput->surface()->setupFrameCallback(); - if (!m_swapping) { - m_swapping = true; - Compositor::self()->aboutToSwapBuffers(); - } + Compositor::self()->aboutToSwapBuffers(); Q_EMIT output->m_waylandOutput->outputChange(damage); @@ -363,15 +360,10 @@ SceneOpenGLTexturePrivate *EglWaylandBackend::createBackendTexture(SceneOpenGLTe return new EglWaylandTexture(texture, this); } -QRegion EglWaylandBackend::prepareRenderingFrame() -{ - eglWaitNative(EGL_CORE_NATIVE_ENGINE); - m_swapping = false; - return QRegion(); -} - QRegion EglWaylandBackend::prepareRenderingForScreen(int screenId) { + eglWaitNative(EGL_CORE_NATIVE_ENGINE); + auto *output = m_outputs.at(screenId); makeContextCurrent(output); if (supportsBufferAge()) { @@ -390,12 +382,6 @@ QRegion EglWaylandBackend::prepareRenderingForScreen(int screenId) return QRegion(); } -void EglWaylandBackend::endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) -{ - Q_UNUSED(renderedRegion) - Q_UNUSED(damagedRegion) -} - void EglWaylandBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) { EglWaylandOutput *output = m_outputs[screenId]; diff --git a/plugins/platforms/wayland/egl_wayland_backend.h b/plugins/platforms/wayland/egl_wayland_backend.h index 3aa82c47d2..183be589a3 100644 --- a/plugins/platforms/wayland/egl_wayland_backend.h +++ b/plugins/platforms/wayland/egl_wayland_backend.h @@ -70,9 +70,7 @@ public: ~EglWaylandBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; - QRegion prepareRenderingFrame() override; QRegion prepareRenderingForScreen(int screenId) override; - void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; bool usesOverlayWindow() const override; bool perScreenRendering() const override; @@ -101,7 +99,6 @@ private: WaylandBackend *m_backend; QVector m_outputs; bool m_havePlatformBase; - bool m_swapping = false; friend class EglWaylandTexture; }; diff --git a/plugins/platforms/wayland/scene_qpainter_wayland_backend.cpp b/plugins/platforms/wayland/scene_qpainter_wayland_backend.cpp index 2adc7f0d9e..df1608d569 100644 --- a/plugins/platforms/wayland/scene_qpainter_wayland_backend.cpp +++ b/plugins/platforms/wayland/scene_qpainter_wayland_backend.cpp @@ -175,9 +175,7 @@ void WaylandQPainterBackend::present(int screenId, int mask, const QRegion &dama WaylandQPainterOutput *rendererOutput = m_outputs.value(screenId); Q_ASSERT(rendererOutput); - if (screenId == 0) { - Compositor::self()->aboutToSwapBuffers(); - } + Compositor::self()->aboutToSwapBuffers(); rendererOutput->setNeedsFullRepaint(false); rendererOutput->present(rendererOutput->mapToLocal(damage)); diff --git a/plugins/platforms/x11/common/eglonxbackend.cpp b/plugins/platforms/x11/common/eglonxbackend.cpp index aecf064f95..9c1ca1aec4 100644 --- a/plugins/platforms/x11/common/eglonxbackend.cpp +++ b/plugins/platforms/x11/common/eglonxbackend.cpp @@ -384,8 +384,9 @@ SceneOpenGLTexturePrivate *EglOnXBackend::createBackendTexture(SceneOpenGLTextur return new EglTexture(texture, this); } -QRegion EglOnXBackend::prepareRenderingFrame() +QRegion EglOnXBackend::prepareRenderingForScreen(int screenId) { + Q_UNUSED(screenId) QRegion repaint; if (gs_tripleBufferNeedsDetection) { @@ -407,8 +408,10 @@ QRegion EglOnXBackend::prepareRenderingFrame() return repaint; } -void EglOnXBackend::endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) +void EglOnXBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) { + Q_UNUSED(screenId) + if (damagedRegion.isEmpty()) { setLastDamage(QRegion()); diff --git a/plugins/platforms/x11/common/eglonxbackend.h b/plugins/platforms/x11/common/eglonxbackend.h index 34cc1f3da0..88c5bacfc7 100644 --- a/plugins/platforms/x11/common/eglonxbackend.h +++ b/plugins/platforms/x11/common/eglonxbackend.h @@ -27,8 +27,8 @@ public: ~EglOnXBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; - QRegion prepareRenderingFrame() override; - void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) override; + QRegion prepareRenderingForScreen(int screenId) override; + void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; OverlayWindow* overlayWindow() const override; bool usesOverlayWindow() const override; void init() override; diff --git a/plugins/platforms/x11/standalone/glxbackend.cpp b/plugins/platforms/x11/standalone/glxbackend.cpp index e6b09a61b4..2e94c7dec4 100644 --- a/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/plugins/platforms/x11/standalone/glxbackend.cpp @@ -781,8 +781,9 @@ SceneOpenGLTexturePrivate *GlxBackend::createBackendTexture(SceneOpenGLTexture * return new GlxTexture(texture, this); } -QRegion GlxBackend::prepareRenderingFrame() +QRegion GlxBackend::prepareRenderingForScreen(int screenId) { + Q_UNUSED(screenId) QRegion repaint; if (gs_tripleBufferNeedsDetection) { @@ -794,6 +795,7 @@ QRegion GlxBackend::prepareRenderingFrame() usleep(1000); } + makeCurrent(); present(); if (supportsBufferAge()) @@ -804,8 +806,10 @@ QRegion GlxBackend::prepareRenderingFrame() return repaint; } -void GlxBackend::endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) +void GlxBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) { + Q_UNUSED(screenId) + if (damagedRegion.isEmpty()) { setLastDamage(QRegion()); diff --git a/plugins/platforms/x11/standalone/glxbackend.h b/plugins/platforms/x11/standalone/glxbackend.h index 321108e928..b2803332cf 100644 --- a/plugins/platforms/x11/standalone/glxbackend.h +++ b/plugins/platforms/x11/standalone/glxbackend.h @@ -61,8 +61,8 @@ public: ~GlxBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; - QRegion prepareRenderingFrame() override; - void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) override; + QRegion prepareRenderingForScreen(int screenId) override; + void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; bool makeCurrent() override; void doneCurrent() override; OverlayWindow* overlayWindow() const override; diff --git a/plugins/platforms/x11/windowed/egl_x11_backend.cpp b/plugins/platforms/x11/windowed/egl_x11_backend.cpp index c7237c4209..b0d6daa49f 100644 --- a/plugins/platforms/x11/windowed/egl_x11_backend.cpp +++ b/plugins/platforms/x11/windowed/egl_x11_backend.cpp @@ -60,17 +60,6 @@ void EglX11Backend::present() xcb_flush(m_backend->connection()); } -QRegion EglX11Backend::prepareRenderingFrame() -{ - return QRegion(); -} - -void EglX11Backend::endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) -{ - Q_UNUSED(renderedRegion) - Q_UNUSED(damagedRegion) -} - bool EglX11Backend::usesOverlayWindow() const { return false; diff --git a/plugins/platforms/x11/windowed/egl_x11_backend.h b/plugins/platforms/x11/windowed/egl_x11_backend.h index 9d87149940..d8b337b66a 100644 --- a/plugins/platforms/x11/windowed/egl_x11_backend.h +++ b/plugins/platforms/x11/windowed/egl_x11_backend.h @@ -23,8 +23,6 @@ class EglX11Backend : public EglOnXBackend public: explicit EglX11Backend(X11WindowedBackend *backend); ~EglX11Backend() override; - QRegion prepareRenderingFrame() override; - void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) override; bool usesOverlayWindow() const override; bool perScreenRendering() const override; QRegion prepareRenderingForScreen(int screenId) override; diff --git a/plugins/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp index 2694b432de..a4523500fb 100644 --- a/plugins/scenes/opengl/scene_opengl.cpp +++ b/plugins/scenes/opengl/scene_opengl.cpp @@ -639,12 +639,11 @@ void SceneOpenGL::paint(int screenId, const QRegion &damage, const QListprepareRenderingForScreen(screenId); if (screenId != -1) { - repaint = m_backend->prepareRenderingForScreen(screenId); geo = screens()->geometry(screenId); scaling = screens()->scale(screenId); } else { - repaint = m_backend->prepareRenderingFrame(); geo = screens()->geometry(); scaling = 1; } @@ -680,11 +679,7 @@ void SceneOpenGL::paint(int screenId, const QRegion &damage, const QListendOfFrame(); - if (screenId != -1) { - m_backend->endRenderingFrameForScreen(screenId, valid, update); - } else { - m_backend->endRenderingFrame(valid, update); - } + m_backend->endRenderingFrameForScreen(screenId, valid, update); GLVertexBuffer::streamingBuffer()->framePosted(); if (m_currentFence) {