Commit 419aa73b authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/components/camera/Camera): clean video context

parent 74311876
...@@ -49,6 +49,19 @@ CameraRenderer::CameraRenderer () { ...@@ -49,6 +49,19 @@ CameraRenderer::CameraRenderer () {
} }
CameraRenderer::~CameraRenderer () { CameraRenderer::~CameraRenderer () {
qInfo() << QStringLiteral("Delete context info:") << m_context_info;
CoreManager *core = CoreManager::getInstance();
core->lockVideoRender();
memset(m_context_info, 0, sizeof *m_context_info);
m_update_context_info = true;
updateWindowId();
core->unlockVideoRender();
delete m_context_info; delete m_context_info;
} }
...@@ -60,14 +73,16 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize & ...@@ -60,14 +73,16 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
CoreManager *core = CoreManager::getInstance(); CoreManager *core = CoreManager::getInstance();
// It's not the same thread as render.
core->lockVideoRender();
m_context_info->width = size.width(); m_context_info->width = size.width();
m_context_info->height = size.height(); m_context_info->height = size.height();
m_context_info->functions = MSFunctions::getInstance()->getFunctions(); m_context_info->functions = MSFunctions::getInstance()->getFunctions();
m_update_context_info = true; m_update_context_info = true;
// It's not the same thread as render.
core->lockVideoRender();
updateWindowId(); updateWindowId();
core->unlockVideoRender(); core->unlockVideoRender();
return new QOpenGLFramebufferObject(size, format); return new QOpenGLFramebufferObject(size, format);
...@@ -120,8 +135,8 @@ void CameraRenderer::updateWindowId () { ...@@ -120,8 +135,8 @@ void CameraRenderer::updateWindowId () {
m_update_context_info = false; m_update_context_info = false;
qInfo() << "Thread" << QThread::currentThread() << QStringLiteral("Set context info (width: %1, height: %2, is_preview: %3).") qInfo() << "Thread" << QThread::currentThread() << QStringLiteral("Set context info (width: %1, height: %2, is_preview: %3):")
.arg(m_context_info->width).arg(m_context_info->height).arg(m_is_preview); .arg(m_context_info->width).arg(m_context_info->height).arg(m_is_preview) << m_context_info;
if (m_is_preview) if (m_is_preview)
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(m_context_info); CoreManager::getInstance()->getCore()->setNativePreviewWindowId(m_context_info);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment