Changeset View
Changeset View
Standalone View
Standalone View
platformsupport/scenes/opengl/abstract_egl_backend.cpp
Show All 26 Lines | |||||
27 | #include "scene.h" | 27 | #include "scene.h" | ||
28 | #include "wayland_server.h" | 28 | #include "wayland_server.h" | ||
29 | #include <KWayland/Server/buffer_interface.h> | 29 | #include <KWayland/Server/buffer_interface.h> | ||
30 | #include <KWayland/Server/display.h> | 30 | #include <KWayland/Server/display.h> | ||
31 | #include <KWayland/Server/surface_interface.h> | 31 | #include <KWayland/Server/surface_interface.h> | ||
32 | // kwin libs | 32 | // kwin libs | ||
33 | #include <logging.h> | 33 | #include <logging.h> | ||
34 | #include <kwinglplatform.h> | 34 | #include <kwinglplatform.h> | ||
35 | #include <kwineffectquickview.h> | ||||
35 | #include <kwinglutils.h> | 36 | #include <kwinglutils.h> | ||
36 | // Qt | 37 | // Qt | ||
37 | #include <QOpenGLContext> | 38 | #include <QOpenGLContext> | ||
38 | #include <QOpenGLFramebufferObject> | 39 | #include <QOpenGLFramebufferObject> | ||
40 | #include <QtPlatformHeaders/QEGLNativeContext> | ||||
39 | 41 | | |||
40 | #include <memory> | 42 | #include <memory> | ||
41 | 43 | | |||
42 | namespace KWin | 44 | namespace KWin | ||
43 | { | 45 | { | ||
44 | 46 | | |||
45 | typedef GLboolean(*eglBindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display); | 47 | typedef GLboolean(*eglBindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display); | ||
46 | typedef GLboolean(*eglUnbindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display); | 48 | typedef GLboolean(*eglUnbindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display); | ||
Show All 26 Lines | 74 | { | |||
73 | if (eglUnbindWaylandDisplayWL && m_display != EGL_NO_DISPLAY) { | 75 | if (eglUnbindWaylandDisplayWL && m_display != EGL_NO_DISPLAY) { | ||
74 | eglUnbindWaylandDisplayWL(m_display, *(WaylandServer::self()->display())); | 76 | eglUnbindWaylandDisplayWL(m_display, *(WaylandServer::self()->display())); | ||
75 | } | 77 | } | ||
76 | } | 78 | } | ||
77 | 79 | | |||
78 | void AbstractEglBackend::cleanup() | 80 | void AbstractEglBackend::cleanup() | ||
79 | { | 81 | { | ||
80 | cleanupGL(); | 82 | cleanupGL(); | ||
83 | EffectQuickView::setShareContext(nullptr); | ||||
81 | doneCurrent(); | 84 | doneCurrent(); | ||
82 | eglDestroyContext(m_display, m_context); | 85 | eglDestroyContext(m_display, m_context); | ||
83 | cleanupSurfaces(); | 86 | cleanupSurfaces(); | ||
84 | eglReleaseThread(); | 87 | eglReleaseThread(); | ||
85 | kwinApp()->platform()->setSceneEglContext(EGL_NO_CONTEXT); | 88 | kwinApp()->platform()->setSceneEglContext(EGL_NO_CONTEXT); | ||
86 | kwinApp()->platform()->setSceneEglSurface(EGL_NO_SURFACE); | 89 | kwinApp()->platform()->setSceneEglSurface(EGL_NO_SURFACE); | ||
87 | kwinApp()->platform()->setSceneEglConfig(nullptr); | 90 | kwinApp()->platform()->setSceneEglConfig(nullptr); | ||
88 | } | 91 | } | ||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Line(s) | 223 | { | |||
296 | } | 299 | } | ||
297 | 300 | | |||
298 | if (ctx == EGL_NO_CONTEXT) { | 301 | if (ctx == EGL_NO_CONTEXT) { | ||
299 | qCCritical(KWIN_OPENGL) << "Create Context failed"; | 302 | qCCritical(KWIN_OPENGL) << "Create Context failed"; | ||
300 | return false; | 303 | return false; | ||
301 | } | 304 | } | ||
302 | m_context = ctx; | 305 | m_context = ctx; | ||
303 | kwinApp()->platform()->setSceneEglContext(m_context); | 306 | kwinApp()->platform()->setSceneEglContext(m_context); | ||
307 | | ||||
308 | auto qtContext = new QOpenGLContext; | ||||
309 | QEGLNativeContext native(ctx, m_display); | ||||
310 | qtContext->setNativeHandle(QVariant::fromValue(native)); | ||||
311 | qtContext->create(); | ||||
312 | EffectQuickView::setShareContext(std::unique_ptr<QOpenGLContext>(qtContext)); | ||||
313 | | ||||
304 | return true; | 314 | return true; | ||
305 | } | 315 | } | ||
306 | 316 | | |||
307 | void AbstractEglBackend::setEglDisplay(const EGLDisplay &display) { | 317 | void AbstractEglBackend::setEglDisplay(const EGLDisplay &display) { | ||
308 | m_display = display; | 318 | m_display = display; | ||
309 | kwinApp()->platform()->setSceneEglDisplay(display); | 319 | kwinApp()->platform()->setSceneEglDisplay(display); | ||
310 | } | 320 | } | ||
311 | 321 | | |||
▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines |