@@ -103,6 +103,7 @@ public:
~eGL();
int initEGLContext();
+ void resetEGLContext();
static EGLDisplay probeDisplay();
int createInputDMABufTexture2D(eGLImage &eglImage, int fd);
@@ -71,14 +71,13 @@ eGL::eGL(EGLDisplay display)
}
/**
- * \brief Destroy the EGL helper
+ * \brief Release all EGL resources
*
- * Destroys the EGL context and surface if they were successfully created.
+ * Equivalent to calling resetEGLContext().
*/
eGL::~eGL()
{
- if (context_ != EGL_NO_CONTEXT)
- eglDestroyContext(display_, context_);
+ resetEGLContext();
}
/**
@@ -436,6 +435,20 @@ fail:
return -ENODEV;
}
+/**
+ * \brief Destroy the EGL context
+ *
+ * This function destroys the EGL context created by initEGLContext().
+ */
+void eGL::resetEGLContext()
+{
+ if (context_ != EGL_NO_CONTEXT)
+ eglDestroyContext(display_, std::exchange(context_, EGL_NO_CONTEXT));
+
+ tid_ = -1;
+ vtable_ = {};
+}
+
/**
* \brief Make the EGL context current for the calling thread
*
Add a function that undoes the effects of `initEGLContext()`. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- include/libcamera/internal/egl.h | 1 + src/libcamera/egl.cpp | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-)