AbstractEglBackend: Share initBufferConfigs among its children

The only one that does it differently is the DRM backend and it's just
an extension that takes GBM into account, otherwise it's effectively
copy-pasted code.
remotes/origin/work/vrr-cursor
Aleix Pol 3 years ago committed by Aleix Pol Gonzalez
parent c0d87e0139
commit d203d3b370
  1. 2
      src/backends/drm/drm_egl_backend.h
  2. 33
      src/backends/virtual/virtual_egl_backend.cpp
  3. 1
      src/backends/virtual/virtual_egl_backend.h
  4. 35
      src/backends/wayland/wayland_egl_backend.cpp
  5. 1
      src/backends/wayland/wayland_egl_backend.h
  6. 35
      src/platformsupport/scenes/opengl/abstract_egl_backend.cpp
  7. 1
      src/platformsupport/scenes/opengl/abstract_egl_backend.h

@ -86,7 +86,7 @@ public:
private:
bool initializeEgl();
bool initBufferConfigs();
bool initBufferConfigs() override;
bool initRenderingContext();
DrmBackend *m_backend;

@ -150,39 +150,6 @@ void VirtualEglBackend::removeOutput(Output *output)
m_outputs.erase(output);
}
bool VirtualEglBackend::initBufferConfigs()
{
const EGLint config_attribs[] = {
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_RED_SIZE,
1,
EGL_GREEN_SIZE,
1,
EGL_BLUE_SIZE,
1,
EGL_ALPHA_SIZE,
0,
EGL_RENDERABLE_TYPE,
isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
EGL_CONFIG_CAVEAT,
EGL_NONE,
EGL_NONE,
};
EGLint count;
EGLConfig configs[1024];
if (eglChooseConfig(eglDisplay(), config_attribs, configs, 1, &count) == EGL_FALSE) {
return false;
}
if (count != 1) {
return false;
}
setConfig(configs[0]);
return true;
}
std::unique_ptr<SurfaceTexture> VirtualEglBackend::createSurfaceTextureInternal(SurfacePixmapInternal *pixmap)
{
return std::make_unique<BasicEGLSurfaceTextureInternal>(this, pixmap);

@ -56,7 +56,6 @@ public:
private:
bool initializeEgl();
bool initBufferConfigs();
bool initRenderingContext();
void addOutput(Output *output);

@ -384,41 +384,6 @@ bool WaylandEglBackend::initRenderingContext()
return makeCurrent();
}
bool WaylandEglBackend::initBufferConfigs()
{
const EGLint config_attribs[] = {
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_RED_SIZE,
1,
EGL_GREEN_SIZE,
1,
EGL_BLUE_SIZE,
1,
EGL_ALPHA_SIZE,
0,
EGL_RENDERABLE_TYPE,
isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
EGL_CONFIG_CAVEAT,
EGL_NONE,
EGL_NONE,
};
EGLint count;
EGLConfig configs[1024];
if (eglChooseConfig(eglDisplay(), config_attribs, configs, 1, &count) == EGL_FALSE) {
qCCritical(KWIN_WAYLAND_BACKEND) << "choose config failed";
return false;
}
if (count != 1) {
qCCritical(KWIN_WAYLAND_BACKEND) << "choose config did not return a config" << count;
return false;
}
setConfig(configs[0]);
return true;
}
std::shared_ptr<KWin::GLTexture> WaylandEglBackend::textureForOutput(KWin::Output *output) const
{
auto texture = std::make_unique<GLTexture>(GL_RGBA8, output->pixelSize());

@ -143,7 +143,6 @@ public:
private:
bool initializeEgl();
bool initBufferConfigs();
bool initRenderingContext();
bool createEglWaylandOutput(Output *output);
void cleanupSurfaces() override;

@ -477,4 +477,39 @@ QHash<uint32_t, QVector<uint64_t>> AbstractEglBackend::supportedFormats() const
return RenderBackend::supportedFormats();
}
}
bool AbstractEglBackend::initBufferConfigs()
{
const EGLint config_attribs[] = {
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_RED_SIZE,
1,
EGL_GREEN_SIZE,
1,
EGL_BLUE_SIZE,
1,
EGL_ALPHA_SIZE,
0,
EGL_RENDERABLE_TYPE,
isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
EGL_CONFIG_CAVEAT,
EGL_NONE,
EGL_NONE,
};
EGLint count;
EGLConfig configs[1024];
if (eglChooseConfig(eglDisplay(), config_attribs, configs, 1, &count) == EGL_FALSE) {
qCCritical(KWIN_OPENGL) << "choose config failed";
return false;
}
if (count != 1) {
qCCritical(KWIN_OPENGL) << "choose config did not return a config" << count;
return false;
}
setConfig(configs[0]);
return true;
}
}

@ -87,6 +87,7 @@ protected:
bool hasClientExtension(const QByteArray &ext) const;
bool isOpenGLES() const;
bool createContext();
virtual bool initBufferConfigs();
private:
EGLContext ensureGlobalShareContext();

Loading…
Cancel
Save