A Scene doesn't need to use an X11 Overlay Window

Only the X based Scenes need an overlay window, so the Compositor doesn't
need to check for it in the Wayland case.

OverlayWindow is moved from OpenGLBackend to the sub classes which need
to provide it.
This commit is contained in:
Martin Gräßlin 2013-06-19 12:26:34 +02:00
parent c9779825d1
commit b28effff23
13 changed files with 82 additions and 16 deletions

View file

@ -539,7 +539,7 @@ void Compositor::lastFrameRendered()
void Compositor::performCompositing()
{
if (!isOverlayWindowVisible())
if (m_scene->usesOverlayWindow() && !isOverlayWindowVisible())
return; // nothing is visible anyway
if (!m_scene->isLastFrameRendered()) {
m_waitingForFrameRendered = true;
@ -706,7 +706,7 @@ void Compositor::checkUnredirect()
// force is needed when the list of windows changes (e.g. a window goes away)
void Compositor::checkUnredirect(bool force)
{
if (!hasScene() || m_scene->overlayWindow()->window() == None || !options->isUnredirectFullscreen())
if (!hasScene() || !m_scene->overlayWindow() || m_scene->overlayWindow()->window() == None || !options->isUnredirectFullscreen())
return;
if (force)
forceUnredirectCheck = true;
@ -716,7 +716,7 @@ void Compositor::checkUnredirect(bool force)
void Compositor::delayedCheckUnredirect()
{
if (!hasScene() || m_scene->overlayWindow()->window() == None || !(options->isUnredirectFullscreen() || sender() == options))
if (!hasScene() || !m_scene->overlayWindow() || m_scene->overlayWindow()->window() == None || !(options->isUnredirectFullscreen() || sender() == options))
return;
ToplevelList list;
bool changed = forceUnredirectCheck;

View file

@ -369,6 +369,11 @@ void EglWaylandBackend::lastFrameRendered()
Compositor::self()->lastFrameRendered();
}
bool EglWaylandBackend::usesOverlayWindow() const
{
return false;
}
/************************************************
* EglTexture
************************************************/

View file

@ -69,6 +69,7 @@ public:
virtual bool isLastFrameRendered() const override;
Xcb::Shm *shm();
void lastFrameRendered();
virtual bool usesOverlayWindow() const override;
protected:
virtual void present();

View file

@ -35,6 +35,7 @@ namespace KWin
EglOnXBackend::EglOnXBackend()
: OpenGLBackend()
, m_overlayWindow(new OverlayWindow())
, ctx(EGL_NO_CONTEXT)
, surfaceHasSubPost(0)
, m_bufferAge(0)
@ -46,6 +47,9 @@ EglOnXBackend::EglOnXBackend()
EglOnXBackend::~EglOnXBackend()
{
if (isFailed()) {
m_overlayWindow->destroy();
}
cleanupGL();
doneCurrent();
eglDestroyContext(dpy, ctx);
@ -55,6 +59,7 @@ EglOnXBackend::~EglOnXBackend()
if (overlayWindow()->window()) {
overlayWindow()->destroy();
}
delete m_overlayWindow;
}
static bool gs_tripleBufferUndetected = true;
@ -420,6 +425,16 @@ void EglOnXBackend::doneCurrent()
eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
bool EglOnXBackend::usesOverlayWindow() const
{
return true;
}
OverlayWindow* EglOnXBackend::overlayWindow()
{
return m_overlayWindow;
}
/************************************************
* EglTexture
************************************************/

View file

@ -38,6 +38,8 @@ public:
virtual void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion);
virtual bool makeCurrent() override;
virtual void doneCurrent() override;
virtual OverlayWindow* overlayWindow() override;
virtual bool usesOverlayWindow() const override;
protected:
virtual void present();
@ -46,6 +48,10 @@ private:
void init();
bool initBufferConfigs();
bool initRenderingContext();
/**
* @brief The OverlayWindow used by this Backend.
**/
OverlayWindow *m_overlayWindow;
EGLDisplay dpy;
EGLConfig config;
EGLSurface surface;

View file

@ -42,6 +42,7 @@ namespace KWin
{
GlxBackend::GlxBackend()
: OpenGLBackend()
, m_overlayWindow(new OverlayWindow())
, window(None)
, fbconfig(NULL)
, glxWindow(None)
@ -54,6 +55,9 @@ GlxBackend::GlxBackend()
GlxBackend::~GlxBackend()
{
if (isFailed()) {
m_overlayWindow->destroy();
}
// TODO: cleanup in error case
// do cleanup after initBuffer()
cleanupGL();
@ -70,6 +74,7 @@ GlxBackend::~GlxBackend()
overlayWindow()->destroy();
checkGLError("Cleanup");
delete m_overlayWindow;
}
static bool gs_tripleBufferUndetected = true;
@ -593,6 +598,16 @@ void GlxBackend::doneCurrent()
glXMakeCurrent(display(), None, nullptr);
}
OverlayWindow* GlxBackend::overlayWindow()
{
return m_overlayWindow;
}
bool GlxBackend::usesOverlayWindow() const
{
return true;
}
/********************************************************
* GlxTexture
*******************************************************/

View file

@ -48,6 +48,8 @@ public:
virtual void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion);
virtual bool makeCurrent() override;
virtual void doneCurrent() override;
virtual OverlayWindow* overlayWindow() override;
virtual bool usesOverlayWindow() const override;
protected:
virtual void present();
@ -61,6 +63,10 @@ private:
bool initFbConfig();
void setSwapInterval(int interval);
/**
* @brief The OverlayWindow used by this Backend.
**/
OverlayWindow *m_overlayWindow;
Window window;
FBConfigInfo fbcdrawableinfo[ 32 + 1 ];
GLXFBConfig fbconfig;

View file

@ -619,6 +619,9 @@ bool Scene::syncsToVBlank() const
void Scene::screenGeometryChanged(const QSize &size)
{
if (!overlayWindow()) {
return;
}
overlayWindow()->resize(size);
}

View file

@ -121,6 +121,10 @@ public:
virtual bool makeOpenGLContextCurrent();
virtual void doneOpenGLContextCurrent();
/**
* Whether the Scene uses an X11 overlay window to perform compositing.
*/
virtual bool usesOverlayWindow() const = 0;
/**
* @brief Allows the Compositor to delay the rendering of the next frame until the last one
* has been rendered. This is mostly interesting in case that the system compositor is not able

View file

@ -79,8 +79,7 @@ extern int currentRefreshRate();
// SceneOpenGL
//****************************************
OpenGLBackend::OpenGLBackend()
: m_overlayWindow(new OverlayWindow()) // TODO: maybe create only if needed?
, m_syncsToVBlank(false)
: m_syncsToVBlank(false)
, m_blocksForRetrace(false)
, m_directRendering(false)
, m_haveBufferAge(false)
@ -90,10 +89,6 @@ OpenGLBackend::OpenGLBackend()
OpenGLBackend::~OpenGLBackend()
{
if (isFailed()) {
m_overlayWindow->destroy();
}
delete m_overlayWindow;
}
void OpenGLBackend::setFailed(const QString &reason)
@ -138,6 +133,11 @@ bool OpenGLBackend::isLastFrameRendered() const
return true;
}
OverlayWindow* OpenGLBackend::overlayWindow()
{
return NULL;
}
/************************************************
* SceneOpenGL
***********************************************/

View file

@ -52,6 +52,7 @@ public:
virtual Shadow *createShadow(Toplevel *toplevel);
virtual void screenGeometryChanged(const QSize &size);
virtual OverlayWindow *overlayWindow();
virtual bool usesOverlayWindow() const;
virtual bool blocksForRetrace() const;
virtual bool syncsToVBlank() const;
virtual bool makeOpenGLContextCurrent() override;
@ -483,6 +484,7 @@ public:
* frame got rendered. If a backend needs more control it needs to implement this method.
*/
virtual bool isLastFrameRendered() const;
virtual bool usesOverlayWindow() const = 0;
/**
* @brief Compositor is going into idle mode, flushes any pending paints.
**/
@ -504,9 +506,7 @@ public:
*
* @return :OverlayWindow*
**/
OverlayWindow *overlayWindow() {
return m_overlayWindow;
}
virtual OverlayWindow *overlayWindow();
/**
* @brief Whether the creation of the Backend failed.
*
@ -635,10 +635,6 @@ protected:
SwapProfiler m_swapProfiler;
private:
/**
* @brief The OverlayWindow used by this Backend.
**/
OverlayWindow *m_overlayWindow;
/**
* @brief Whether VSync is available and used, defaults to @c false.
**/
@ -683,6 +679,11 @@ inline bool SceneOpenGL::isLastFrameRendered() const
return m_backend->isLastFrameRendered();
}
inline bool SceneOpenGL::usesOverlayWindow() const
{
return m_backend->usesOverlayWindow();
}
inline SceneOpenGL::Texture* OpenGLWindowPixmap::texture() const
{
return m_texture.data();

View file

@ -243,6 +243,11 @@ void X11XRenderBackend::screenGeometryChanged(const QSize &size)
init(false);
}
bool X11XRenderBackend::usesOverlayWindow() const
{
return true;
}
//****************************************
// SceneXrender
//****************************************

View file

@ -53,6 +53,7 @@ public:
* @return :OverlayWindow*
**/
virtual OverlayWindow *overlayWindow();
virtual bool usesOverlayWindow() const = 0;
/**
* @brief Shows the Overlay Window
*
@ -136,6 +137,7 @@ public:
virtual OverlayWindow* overlayWindow();
virtual void showOverlay();
virtual void screenGeometryChanged(const QSize &size);
virtual bool usesOverlayWindow() const;
private:
void init(bool createOverlay);
void createBuffer();
@ -163,6 +165,9 @@ public:
virtual OverlayWindow *overlayWindow() {
return m_backend->overlayWindow();
}
virtual bool usesOverlayWindow() const {
return m_backend->usesOverlayWindow();
}
virtual bool isLastFrameRendered() const {
return m_backend->isLastFrameRendered();
}