Use consistent naming for begin/end frame hooks

Currently, the OpenGLBackend and the QPainterBackend have hooks to
indicate the start and the end of compositing cycle, but in both cases,
the hooks have different names. This change fixes that inconsistency.
This commit is contained in:
Vlad Zahorodnii 2020-11-09 16:31:26 +02:00
parent 76303888ab
commit f26eeb9706
31 changed files with 61 additions and 75 deletions

View file

@ -74,19 +74,6 @@ OverlayWindow* OpenGLBackend::overlayWindow() const
return nullptr;
}
QRegion OpenGLBackend::prepareRenderingForScreen(int screenId)
{
// fallback to repaint complete screen
return screens()->geometry(screenId);
}
void OpenGLBackend::endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion)
{
Q_UNUSED(screenId)
Q_UNUSED(damage)
Q_UNUSED(damagedRegion)
}
bool OpenGLBackend::perScreenRendering() const
{
return false;

View file

@ -56,7 +56,6 @@ public:
* @p damage contains the reported damage as suggested by windows and effects on prepaint calls.
*/
virtual void aboutToStartPainting(int screenId, const QRegion &damage);
virtual void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion);
virtual bool makeCurrent() = 0;
virtual void doneCurrent() = 0;
virtual bool usesOverlayWindow() const = 0;
@ -65,7 +64,8 @@ public:
* Default implementation returns @c false.
*/
virtual bool perScreenRendering() const;
virtual QRegion prepareRenderingForScreen(int screenId);
virtual QRegion beginFrame(int screenId) = 0;
virtual void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) = 0;
/**
* @brief Compositor is going into idle mode, flushes any pending paints.
*/

View file

@ -21,8 +21,8 @@ class QPainterBackend
{
public:
virtual ~QPainterBackend();
virtual void present(int screenId, int mask, const QRegion &damage) = 0;
virtual void prepareRenderingFrame(int screenId) = 0;
virtual void endFrame(int screenId, int mask, const QRegion &damage) = 0;
virtual void beginFrame(int screenId) = 0;
/**
* @brief React on screen geometry changes.
*

View file

@ -521,7 +521,7 @@ void EglGbmBackend::setViewport(const Output &output) const
overall.width() * scale, overall.height() * scale);
}
QRegion EglGbmBackend::prepareRenderingForScreen(int screenId)
QRegion EglGbmBackend::beginFrame(int screenId)
{
const Output &output = m_outputs.at(screenId);
@ -545,9 +545,8 @@ QRegion EglGbmBackend::prepareRenderingForScreen(int screenId)
return output.output->geometry();
}
void EglGbmBackend::endRenderingFrameForScreen(int screenId,
const QRegion &renderedRegion,
const QRegion &damagedRegion)
void EglGbmBackend::endFrame(int screenId, const QRegion &renderedRegion,
const QRegion &damagedRegion)
{
Output &output = m_outputs[screenId];
renderFramebufferToSurface(output);

View file

@ -35,10 +35,10 @@ public:
~EglGbmBackend() override;
void screenGeometryChanged(const QSize &size) override;
SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override;
void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
bool usesOverlayWindow() const override;
bool perScreenRendering() const override;
QRegion prepareRenderingForScreen(int screenId) override;
QRegion beginFrame(int screenId) override;
void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
void init() override;
QSharedPointer<GLTexture> textureForOutput(AbstractOutput *requestedOutput) const override;

View file

@ -475,14 +475,14 @@ SceneOpenGLTexturePrivate *EglStreamBackend::createBackendTexture(SceneOpenGLTex
return new EglStreamTexture(texture, this);
}
QRegion EglStreamBackend::prepareRenderingForScreen(int screenId)
QRegion EglStreamBackend::beginFrame(int screenId)
{
const Output &o = m_outputs.at(screenId);
makeContextCurrent(o);
return o.output->geometry();
}
void EglStreamBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
void EglStreamBackend::endFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
{
Q_UNUSED(renderedRegion);
Q_UNUSED(damagedRegion);

View file

@ -32,10 +32,10 @@ public:
~EglStreamBackend() override;
void screenGeometryChanged(const QSize &size) override;
SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override;
void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
bool usesOverlayWindow() const override;
bool perScreenRendering() const override;
QRegion prepareRenderingForScreen(int screenId) override;
QRegion beginFrame(int screenId) override;
void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
void init() override;
protected:

View file

@ -100,13 +100,13 @@ bool DrmQPainterBackend::needsFullRepaint(int screenId) const
return true;
}
void DrmQPainterBackend::prepareRenderingFrame(int screenId)
void DrmQPainterBackend::beginFrame(int screenId)
{
Output &rendererOutput = m_outputs[screenId];
rendererOutput.index = (rendererOutput.index + 1) % 2;
}
void DrmQPainterBackend::present(int screenId, int mask, const QRegion &damage)
void DrmQPainterBackend::endFrame(int screenId, int mask, const QRegion &damage)
{
Q_UNUSED(mask)
Q_UNUSED(damage)

View file

@ -29,8 +29,8 @@ public:
QImage *bufferForScreen(int screenId) override;
bool needsFullRepaint(int screenId) const override;
void prepareRenderingFrame(int screenId) override;
void present(int screenId, int mask, const QRegion &damage) override;
void beginFrame(int screenId) override;
void endFrame(int screenId, int mask, const QRegion &damage) override;
bool perScreenRendering() const override;
private:

View file

@ -59,13 +59,13 @@ bool FramebufferQPainterBackend::needsFullRepaint(int screenId) const
return m_needsFullRepaint;
}
void FramebufferQPainterBackend::prepareRenderingFrame(int screenId)
void FramebufferQPainterBackend::beginFrame(int screenId)
{
Q_UNUSED(screenId)
m_needsFullRepaint = true;
}
void FramebufferQPainterBackend::present(int screenId, int mask, const QRegion &damage)
void FramebufferQPainterBackend::endFrame(int screenId, int mask, const QRegion &damage)
{
Q_UNUSED(screenId)
Q_UNUSED(mask)

View file

@ -26,8 +26,8 @@ public:
QImage *bufferForScreen(int screenId) override;
bool needsFullRepaint(int screenId) const override;
void prepareRenderingFrame(int screenId) override;
void present(int screenId, int mask, const QRegion &damage) override;
void beginFrame(int screenId) override;
void endFrame(int screenId, int mask, const QRegion &damage) override;
bool perScreenRendering() const override;
private:

View file

@ -140,7 +140,7 @@ void EglHwcomposerBackend::screenGeometryChanged(const QSize &size)
Q_UNUSED(size)
}
QRegion EglHwcomposerBackend::prepareRenderingFrame(int screenId)
QRegion EglHwcomposerBackend::beginFrame(int screenId)
{
Q_UNUSED(screenId)
present();
@ -150,7 +150,7 @@ QRegion EglHwcomposerBackend::prepareRenderingFrame(int screenId)
return QRegion(QRect(QPoint(0, 0), m_backend->size()));
}
void EglHwcomposerBackend::endRenderingFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
void EglHwcomposerBackend::endFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
{
Q_UNUSED(screenId)
Q_UNUSED(damagedRegion)

View file

@ -24,8 +24,8 @@ public:
bool usesOverlayWindow() const override;
SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override;
void screenGeometryChanged(const QSize &size) override;
QRegion prepareRenderingFrame(int screenId) override;
void endRenderingFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) override;
QRegion beginFrame(int screenId) override;
void endFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) override;
void init() override;
protected:

View file

@ -162,7 +162,7 @@ SceneOpenGLTexturePrivate *EglGbmBackend::createBackendTexture(SceneOpenGLTextur
return new EglGbmTexture(texture, this);
}
QRegion EglGbmBackend::prepareRenderingForScreen(int screenId)
QRegion EglGbmBackend::beginFrame(int screenId)
{
Q_UNUSED(screenId)
if (!lastDamage().isEmpty()) {
@ -205,7 +205,7 @@ static void convertFromGLImage(QImage &img, int w, int h)
img = img.mirrored();
}
void EglGbmBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
void EglGbmBackend::endFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
{
Q_UNUSED(screenId)
Q_UNUSED(damagedRegion)

View file

@ -26,8 +26,8 @@ public:
~EglGbmBackend() override;
void screenGeometryChanged(const QSize &size) override;
SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override;
QRegion prepareRenderingForScreen(int screenId) override;
void endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) override;
QRegion beginFrame(int screenId) override;
void endFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion) override;
bool usesOverlayWindow() const override;
void init() override;

View file

@ -36,7 +36,7 @@ bool VirtualQPainterBackend::needsFullRepaint(int screenId) const
return true;
}
void VirtualQPainterBackend::prepareRenderingFrame(int screenId)
void VirtualQPainterBackend::beginFrame(int screenId)
{
Q_UNUSED(screenId)
}
@ -51,7 +51,7 @@ void VirtualQPainterBackend::createOutputs()
}
}
void VirtualQPainterBackend::present(int screenId, int mask, const QRegion &damage)
void VirtualQPainterBackend::endFrame(int screenId, int mask, const QRegion &damage)
{
Q_UNUSED(mask)
Q_UNUSED(damage)

View file

@ -28,8 +28,8 @@ public:
QImage *bufferForScreen(int screenId) override;
bool needsFullRepaint(int screenId) const override;
void prepareRenderingFrame(int screenId) override;
void present(int screenId, int mask, const QRegion &damage) override;
void beginFrame(int screenId) override;
void endFrame(int screenId, int mask, const QRegion &damage) override;
bool perScreenRendering() const override;
private:

View file

@ -360,7 +360,7 @@ SceneOpenGLTexturePrivate *EglWaylandBackend::createBackendTexture(SceneOpenGLTe
return new EglWaylandTexture(texture, this);
}
QRegion EglWaylandBackend::prepareRenderingForScreen(int screenId)
QRegion EglWaylandBackend::beginFrame(int screenId)
{
eglWaitNative(EGL_CORE_NATIVE_ENGINE);
@ -382,7 +382,7 @@ QRegion EglWaylandBackend::prepareRenderingForScreen(int screenId)
return QRegion();
}
void EglWaylandBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
void EglWaylandBackend::endFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
{
EglWaylandOutput *output = m_outputs[screenId];
QRegion damage = damagedRegion.intersected(output->m_waylandOutput->geometry());

View file

@ -70,8 +70,8 @@ public:
~EglWaylandBackend() override;
void screenGeometryChanged(const QSize &size) override;
SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override;
QRegion prepareRenderingForScreen(int screenId) override;
void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
QRegion beginFrame(int screenId) override;
void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
bool usesOverlayWindow() const override;
bool perScreenRendering() const override;
void init() override;

View file

@ -168,7 +168,7 @@ void WaylandQPainterBackend::createOutput(WaylandOutput *waylandOutput)
m_outputs << output;
}
void WaylandQPainterBackend::present(int screenId, int mask, const QRegion &damage)
void WaylandQPainterBackend::endFrame(int screenId, int mask, const QRegion &damage)
{
Q_UNUSED(mask)
@ -187,7 +187,7 @@ QImage *WaylandQPainterBackend::bufferForScreen(int screenId)
return &output->m_backBuffer;
}
void WaylandQPainterBackend::prepareRenderingFrame(int screenId)
void WaylandQPainterBackend::beginFrame(int screenId)
{
WaylandQPainterOutput *rendererOutput = m_outputs.value(screenId);
Q_ASSERT(rendererOutput);

View file

@ -72,8 +72,8 @@ public:
QImage *bufferForScreen(int screenId) override;
void present(int screenId, int mask, const QRegion& damage) override;
void prepareRenderingFrame(int screenId) override;
void endFrame(int screenId, int mask, const QRegion& damage) override;
void beginFrame(int screenId) override;
bool needsFullRepaint(int screenId) const override;
bool perScreenRendering() const override;

View file

@ -384,7 +384,7 @@ SceneOpenGLTexturePrivate *EglOnXBackend::createBackendTexture(SceneOpenGLTextur
return new EglTexture(texture, this);
}
QRegion EglOnXBackend::prepareRenderingForScreen(int screenId)
QRegion EglOnXBackend::beginFrame(int screenId)
{
Q_UNUSED(screenId)
QRegion repaint;
@ -408,7 +408,7 @@ QRegion EglOnXBackend::prepareRenderingForScreen(int screenId)
return repaint;
}
void EglOnXBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
void EglOnXBackend::endFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
{
Q_UNUSED(screenId)

View file

@ -27,8 +27,8 @@ public:
~EglOnXBackend() override;
void screenGeometryChanged(const QSize &size) override;
SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override;
QRegion prepareRenderingForScreen(int screenId) override;
void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
QRegion beginFrame(int screenId) override;
void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
OverlayWindow* overlayWindow() const override;
bool usesOverlayWindow() const override;
void init() override;

View file

@ -781,7 +781,7 @@ SceneOpenGLTexturePrivate *GlxBackend::createBackendTexture(SceneOpenGLTexture *
return new GlxTexture(texture, this);
}
QRegion GlxBackend::prepareRenderingForScreen(int screenId)
QRegion GlxBackend::beginFrame(int screenId)
{
Q_UNUSED(screenId)
QRegion repaint;
@ -806,7 +806,7 @@ QRegion GlxBackend::prepareRenderingForScreen(int screenId)
return repaint;
}
void GlxBackend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
void GlxBackend::endFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
{
Q_UNUSED(screenId)

View file

@ -61,8 +61,8 @@ public:
~GlxBackend() override;
void screenGeometryChanged(const QSize &size) override;
SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override;
QRegion prepareRenderingForScreen(int screenId) override;
void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
QRegion beginFrame(int screenId) override;
void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
bool makeCurrent() override;
void doneCurrent() override;
OverlayWindow* overlayWindow() const override;

View file

@ -70,7 +70,7 @@ bool EglX11Backend::perScreenRendering() const
return true;
}
QRegion EglX11Backend::prepareRenderingForScreen(int screenId)
QRegion EglX11Backend::beginFrame(int screenId)
{
makeContextCurrent(m_surfaces.at(screenId));
setupViewport(screenId);
@ -88,7 +88,7 @@ void EglX11Backend::setupViewport(int screenId)
glViewport(-v.x(), v.height() - overall.height() + v.y(), overall.width() * scale, overall.height() * scale);
}
void EglX11Backend::endRenderingFrameForScreen(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
void EglX11Backend::endFrame(int screenId, const QRegion &renderedRegion, const QRegion &damagedRegion)
{
Q_UNUSED(damagedRegion)
const QRect &outputGeometry = screens()->geometry(screenId);

View file

@ -25,8 +25,8 @@ public:
~EglX11Backend() override;
bool usesOverlayWindow() const override;
bool perScreenRendering() const override;
QRegion prepareRenderingForScreen(int screenId) override;
void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
QRegion beginFrame(int screenId) override;
void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) override;
protected:
void present() override;

View file

@ -53,12 +53,12 @@ bool X11WindowedQPainterBackend::needsFullRepaint(int screenId) const
return rendererOutput->needsFullRepaint;
}
void X11WindowedQPainterBackend::prepareRenderingFrame(int screenId)
void X11WindowedQPainterBackend::beginFrame(int screenId)
{
Q_UNUSED(screenId)
}
void X11WindowedQPainterBackend::present(int screenId, int mask, const QRegion &damage)
void X11WindowedQPainterBackend::endFrame(int screenId, int mask, const QRegion &damage)
{
Q_UNUSED(mask)
Q_UNUSED(damage)

View file

@ -31,8 +31,8 @@ public:
QImage *bufferForScreen(int screenId) override;
bool needsFullRepaint(int screenId) const override;
void prepareRenderingFrame(int screenId) override;
void present(int screenId, int mask, const QRegion &damage) override;
void beginFrame(int screenId) override;
void endFrame(int screenId, int mask, const QRegion &damage) override;
bool perScreenRendering() const override;
private:

View file

@ -639,7 +639,7 @@ void SceneOpenGL::paint(int screenId, const QRegion &damage, const QList<Topleve
qreal scaling;
// prepare rendering makes context current on the output
repaint = m_backend->prepareRenderingForScreen(screenId);
repaint = m_backend->beginFrame(screenId);
if (screenId != -1) {
geo = screens()->geometry(screenId);
scaling = screens()->scale(screenId);
@ -679,7 +679,7 @@ void SceneOpenGL::paint(int screenId, const QRegion &damage, const QList<Topleve
}
GLVertexBuffer::streamingBuffer()->endOfFrame();
m_backend->endRenderingFrameForScreen(screenId, valid, update);
m_backend->endFrame(screenId, valid, update);
GLVertexBuffer::streamingBuffer()->framePosted();
if (m_currentFence) {

View file

@ -91,7 +91,7 @@ void SceneQPainter::paint(int screenId, const QRegion &_damage, const QList<Topl
int mask = 0;
m_backend->prepareRenderingFrame(screenId);
m_backend->beginFrame(screenId);
const bool needsFullRepaint = m_backend->needsFullRepaint(screenId);
if (needsFullRepaint) {
mask |= Scene::PAINT_SCREEN_BACKGROUND_FIRST;
@ -108,7 +108,7 @@ void SceneQPainter::paint(int screenId, const QRegion &_damage, const QList<Topl
paintCursor(updateRegion);
m_painter->end();
m_backend->present(screenId, mask, updateRegion);
m_backend->endFrame(screenId, mask, updateRegion);
}
// do cleanup