plugins/qpa: use a surfaceless context for offscreen surfaces
According to Qt documentation, offscreen surfaces aren't actually for rendering, so using a surffaceless context is ok
This commit is contained in:
parent
c0e44378ca
commit
9dd236c87b
3 changed files with 3 additions and 49 deletions
|
@ -58,18 +58,9 @@ EGLPlatformContext::~EGLPlatformContext()
|
|||
}
|
||||
}
|
||||
|
||||
static EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
|
||||
{
|
||||
if (surface->surface()->surfaceClass() == QSurface::Window) {
|
||||
return EGL_NO_SURFACE; // EGL_KHR_surfaceless_context is required
|
||||
} else {
|
||||
return static_cast<OffscreenSurface *>(surface)->eglSurface();
|
||||
}
|
||||
}
|
||||
|
||||
bool EGLPlatformContext::makeCurrent(QPlatformSurface *surface)
|
||||
{
|
||||
const bool ok = m_eglContext->makeCurrent(eglSurfaceForPlatformSurface(surface));
|
||||
const bool ok = m_eglContext->makeCurrent();
|
||||
if (!ok) {
|
||||
qCWarning(KWIN_QPA, "eglMakeCurrent failed: %x", eglGetError());
|
||||
return false;
|
||||
|
|
|
@ -22,34 +22,8 @@ namespace QPA
|
|||
|
||||
OffscreenSurface::OffscreenSurface(QOffscreenSurface *surface)
|
||||
: QPlatformOffscreenSurface(surface)
|
||||
, m_eglDisplay(kwinApp()->outputBackend()->sceneEglDisplayObject())
|
||||
, m_format(surface->requestedFormat())
|
||||
{
|
||||
const QSize size = surface->size();
|
||||
|
||||
EGLConfig config = configFromFormat(m_eglDisplay, surface->requestedFormat(), EGL_PBUFFER_BIT);
|
||||
if (config == EGL_NO_CONFIG_KHR) {
|
||||
return;
|
||||
}
|
||||
|
||||
const EGLint attributes[] = {
|
||||
EGL_WIDTH, size.width(),
|
||||
EGL_HEIGHT, size.height(),
|
||||
EGL_NONE};
|
||||
|
||||
m_surface = eglCreatePbufferSurface(m_eglDisplay, config, attributes);
|
||||
if (m_surface == EGL_NO_SURFACE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Requested and actual surface format might be different.
|
||||
m_format = formatFromConfig(m_eglDisplay, config);
|
||||
}
|
||||
|
||||
OffscreenSurface::~OffscreenSurface()
|
||||
{
|
||||
if (m_surface != EGL_NO_SURFACE) {
|
||||
eglDestroySurface(m_eglDisplay, m_surface);
|
||||
}
|
||||
}
|
||||
|
||||
QSurfaceFormat OffscreenSurface::format() const
|
||||
|
@ -59,12 +33,7 @@ QSurfaceFormat OffscreenSurface::format() const
|
|||
|
||||
bool OffscreenSurface::isValid() const
|
||||
{
|
||||
return m_surface != EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
EGLSurface OffscreenSurface::eglSurface() const
|
||||
{
|
||||
return m_surface;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace QPA
|
||||
|
|
|
@ -25,18 +25,12 @@ class OffscreenSurface : public QPlatformOffscreenSurface
|
|||
{
|
||||
public:
|
||||
explicit OffscreenSurface(QOffscreenSurface *surface);
|
||||
~OffscreenSurface() override;
|
||||
|
||||
QSurfaceFormat format() const override;
|
||||
bool isValid() const override;
|
||||
|
||||
EGLSurface eglSurface() const;
|
||||
|
||||
private:
|
||||
QSurfaceFormat m_format;
|
||||
|
||||
EglDisplay *m_eglDisplay = nullptr;
|
||||
EGLSurface m_surface = EGL_NO_SURFACE;
|
||||
};
|
||||
|
||||
} // namespace QPA
|
||||
|
|
Loading…
Reference in a new issue