Add pure virtual OpenGLBackend::init() method
All backends already have an init method so far called from the ctor. This change moves the call to init out of the OpenGL backends and makes it the responsibility of the creating code to also call init on the backend. This change makes it easier to have virtual methods being called during the initialization.
This commit is contained in:
parent
8b4d1a2f3f
commit
b1914b4b2c
14 changed files with 31 additions and 20 deletions
|
@ -39,8 +39,6 @@ EglGbmBackend::EglGbmBackend(DrmBackend *b)
|
|||
, AbstractEglBackend()
|
||||
, m_backend(b)
|
||||
{
|
||||
initializeEgl();
|
||||
init();
|
||||
// Egl is always direct rendering
|
||||
setIsDirectRendering(true);
|
||||
setSyncsToVBlank(true);
|
||||
|
@ -117,6 +115,10 @@ bool EglGbmBackend::initializeEgl()
|
|||
|
||||
void EglGbmBackend::init()
|
||||
{
|
||||
if (!initializeEgl()) {
|
||||
setFailed("Could not initialize egl");
|
||||
return;
|
||||
}
|
||||
if (!initRenderingContext()) {
|
||||
setFailed("Could not initialize rendering context");
|
||||
return;
|
||||
|
|
|
@ -48,13 +48,13 @@ public:
|
|||
bool usesOverlayWindow() const override;
|
||||
bool perScreenRendering() const override;
|
||||
QRegion prepareRenderingForScreen(int screenId) override;
|
||||
void init() override;
|
||||
|
||||
protected:
|
||||
void present() override;
|
||||
void cleanupSurfaces() override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
bool initializeEgl();
|
||||
bool initBufferConfigs();
|
||||
bool initRenderingContext();
|
||||
|
|
|
@ -28,11 +28,6 @@ EglHwcomposerBackend::EglHwcomposerBackend(HwcomposerBackend *backend)
|
|||
: AbstractEglBackend()
|
||||
, m_backend(backend)
|
||||
{
|
||||
if (!initializeEgl()) {
|
||||
setFailed("Failed to initialize egl");
|
||||
return;
|
||||
}
|
||||
init();
|
||||
// EGL is always direct rendering
|
||||
setIsDirectRendering(true);
|
||||
setSyncsToVBlank(true);
|
||||
|
@ -60,6 +55,10 @@ bool EglHwcomposerBackend::initializeEgl()
|
|||
|
||||
void EglHwcomposerBackend::init()
|
||||
{
|
||||
if (!initializeEgl()) {
|
||||
setFailed("Failed to initialize egl");
|
||||
return;
|
||||
}
|
||||
if (!initRenderingContext()) {
|
||||
setFailed("Could not initialize rendering context");
|
||||
return;
|
||||
|
|
|
@ -37,12 +37,12 @@ public:
|
|||
void screenGeometryChanged(const QSize &size) override;
|
||||
QRegion prepareRenderingFrame() override;
|
||||
void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override;
|
||||
void init() override;
|
||||
|
||||
protected:
|
||||
void present() override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
bool initializeEgl();
|
||||
bool initRenderingContext();
|
||||
bool initBufferConfigs();
|
||||
|
|
|
@ -36,8 +36,6 @@ EglGbmBackend::EglGbmBackend(VirtualBackend *b)
|
|||
, AbstractEglBackend()
|
||||
, m_backend(b)
|
||||
{
|
||||
initializeEgl();
|
||||
init();
|
||||
// Egl is always direct rendering
|
||||
setIsDirectRendering(true);
|
||||
}
|
||||
|
@ -75,6 +73,10 @@ bool EglGbmBackend::initializeEgl()
|
|||
|
||||
void EglGbmBackend::init()
|
||||
{
|
||||
if (!initializeEgl()) {
|
||||
setFailed("Could not initialize egl");
|
||||
return;
|
||||
}
|
||||
if (!initRenderingContext()) {
|
||||
setFailed("Could not initialize rendering context");
|
||||
return;
|
||||
|
|
|
@ -42,12 +42,12 @@ public:
|
|||
QRegion prepareRenderingFrame() override;
|
||||
void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override;
|
||||
bool usesOverlayWindow() const override;
|
||||
void init() override;
|
||||
|
||||
protected:
|
||||
void present() override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
bool initializeEgl();
|
||||
bool initBufferConfigs();
|
||||
bool initRenderingContext();
|
||||
|
|
|
@ -55,8 +55,6 @@ EglWaylandBackend::EglWaylandBackend(Wayland::WaylandBackend *b)
|
|||
return;
|
||||
}
|
||||
connect(m_wayland, SIGNAL(shellSurfaceSizeChanged(QSize)), SLOT(overlaySizeChanged(QSize)));
|
||||
initializeEgl();
|
||||
init();
|
||||
// Egl is always direct rendering
|
||||
setIsDirectRendering(true);
|
||||
}
|
||||
|
@ -95,6 +93,10 @@ bool EglWaylandBackend::initializeEgl()
|
|||
|
||||
void EglWaylandBackend::init()
|
||||
{
|
||||
if (!initializeEgl()) {
|
||||
setFailed("Could not initialize egl");
|
||||
return;
|
||||
}
|
||||
if (!initRenderingContext()) {
|
||||
setFailed("Could not initialize rendering context");
|
||||
return;
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
virtual QRegion prepareRenderingFrame();
|
||||
virtual void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion);
|
||||
virtual bool usesOverlayWindow() const override;
|
||||
void init() override;
|
||||
|
||||
protected:
|
||||
virtual void present();
|
||||
|
@ -66,7 +67,6 @@ private Q_SLOTS:
|
|||
void overlaySizeChanged(const QSize &size);
|
||||
|
||||
private:
|
||||
void init();
|
||||
bool initializeEgl();
|
||||
bool initBufferConfigs();
|
||||
bool initRenderingContext();
|
||||
|
|
|
@ -63,7 +63,6 @@ EglOnXBackend::EglOnXBackend(xcb_connection_t *connection, Display *display, xcb
|
|||
, m_x11ScreenNumber(screenNumber)
|
||||
, m_renderingWindow(renderingWindow)
|
||||
{
|
||||
init();
|
||||
// Egl is always direct rendering
|
||||
setIsDirectRendering(true);
|
||||
}
|
||||
|
|
|
@ -40,12 +40,12 @@ public:
|
|||
virtual void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion);
|
||||
virtual OverlayWindow* overlayWindow() override;
|
||||
virtual bool usesOverlayWindow() const override;
|
||||
void init() override;
|
||||
|
||||
protected:
|
||||
virtual void present();
|
||||
|
||||
private:
|
||||
void init();
|
||||
bool initBufferConfigs();
|
||||
bool initRenderingContext();
|
||||
/**
|
||||
|
|
|
@ -114,7 +114,6 @@ GlxBackend::GlxBackend()
|
|||
, m_bufferAge(0)
|
||||
, haveSwapInterval(false)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
static bool gs_tripleBufferUndetected = true;
|
||||
|
|
|
@ -71,12 +71,12 @@ public:
|
|||
virtual void doneCurrent() override;
|
||||
virtual OverlayWindow* overlayWindow() override;
|
||||
virtual bool usesOverlayWindow() const override;
|
||||
void init() override;
|
||||
|
||||
protected:
|
||||
virtual void present();
|
||||
|
||||
private:
|
||||
void init();
|
||||
bool initBuffer();
|
||||
void waitSync();
|
||||
bool initRenderingContext();
|
||||
|
|
|
@ -578,7 +578,13 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
|
|||
// no backend available
|
||||
return NULL;
|
||||
}
|
||||
if (!backend || backend->isFailed()) {
|
||||
if (!backend) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!backend->isFailed()) {
|
||||
backend->init();
|
||||
}
|
||||
if (backend->isFailed()) {
|
||||
delete backend;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -377,6 +377,8 @@ class KWIN_EXPORT OpenGLBackend
|
|||
public:
|
||||
OpenGLBackend();
|
||||
virtual ~OpenGLBackend();
|
||||
|
||||
virtual void init() = 0;
|
||||
/**
|
||||
* @return Time passes since start of rendering current frame.
|
||||
* @see startRenderTimer
|
||||
|
|
Loading…
Reference in a new issue