summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/winrt/qwinrtwindow.cpp
diff options
context:
space:
mode:
authorSamuel Nevala <samuel.nevala@intopalo.com>2015-09-10 13:14:57 +0300
committerAndrew Knight <andrew.knight@intopalo.com>2015-09-14 19:20:02 +0000
commitf3fd7b3d961ffed480e5851e594f6981f558f486 (patch)
tree8acc33a2a5d706a48d893c78d3be35e8a5303955 /src/plugins/platforms/winrt/qwinrtwindow.cpp
parentfe1ba879610c73075b10f274bba338af53a6bd43 (diff)
winrt: Move EGL surface to window.
Fixes GPU memory leak when window is created/deleted dynamically and repeatedly. EGL context used to own EGL surface, but the context outlives the surface if window is created/deleted dynamically. The EGL surface is now owned by the window and destroyed with it. Change-Id: Ib949261ef6e77217018e60aad3e36e4a6d2eaba0 Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
Diffstat (limited to 'src/plugins/platforms/winrt/qwinrtwindow.cpp')
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp
index 5ff1c8bd19..c5b06a5d8a 100644
--- a/src/plugins/platforms/winrt/qwinrtwindow.cpp
+++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp
@@ -88,6 +88,8 @@ public:
QSurfaceFormat surfaceFormat;
QString windowTitle;
Qt::WindowState state;
+ EGLDisplay display;
+ EGLSurface surface;
ComPtr<ISwapChainPanel> swapChainPanel;
ComPtr<ICanvasStatics> canvas;
@@ -100,6 +102,8 @@ QWinRTWindow::QWinRTWindow(QWindow *window)
{
Q_D(QWinRTWindow);
+ d->surface = EGL_NO_SURFACE;
+ d->display = EGL_NO_DISPLAY;
d->screen = static_cast<QWinRTScreen *>(screen());
setWindowFlags(window->flags());
setWindowState(window->windowState());
@@ -170,6 +174,11 @@ QWinRTWindow::~QWinRTWindow()
return S_OK;
});
RETURN_VOID_IF_FAILED("Failed to completely destroy window resources, likely because the application is shutting down");
+
+ EGLBoolean value = eglDestroySurface(d->display, d->surface);
+ d->surface = EGL_NO_SURFACE;
+ if (value == EGL_FALSE)
+ qCritical("Failed to destroy EGL window surface: 0x%x", eglGetError());
}
QSurfaceFormat QWinRTWindow::format() const
@@ -293,4 +302,26 @@ void QWinRTWindow::setWindowState(Qt::WindowState state)
d->state = state;
}
+EGLSurface QWinRTWindow::eglSurface() const
+{
+ Q_D(const QWinRTWindow);
+ return d->surface;
+}
+
+void QWinRTWindow::createEglSurface(EGLDisplay display, EGLConfig config)
+{
+ Q_D(QWinRTWindow);
+ if (d->surface == EGL_NO_SURFACE) {
+ d->display = display;
+ QEventDispatcherWinRT::runOnXamlThread([this, d, display, config]() {
+ d->surface = eglCreateWindowSurface(display, config,
+ reinterpret_cast<EGLNativeWindowType>(winId()),
+ nullptr);
+ if (d->surface == EGL_NO_SURFACE)
+ qCritical("Failed to create EGL window surface: 0x%x", eglGetError());
+ return S_OK;
+ });
+ }
+}
+
QT_END_NAMESPACE