fix(camera): fix OpenGL preview rendering and frame ownership - #511
Conversation
…2435) Manage YUV frame lifetime with shared_ptr for thread-safe rendering, add core-profile shaders with legacy fallback and one-time texture setup. 使用 shared_ptr 管理 YUV 帧生命周期实现跨线程安全渲染,新增 core-profile 着色器并保留 legacy 回退,纹理参数改为初始化时一次性设置。 Log: 修复相机预览OpenGL渲染异常与YUV帧生命周期管理问题 PMS: BUG-372435 Influence: 修复预览画面渲染异常及潜在崩溃,提升OpenGL渲染稳定性与兼容性。
Reviewer's GuideRefactors camera preview OpenGL rendering to use shared_ptr-managed YUV frames for safe cross-thread ownership, introduces core-profile compatible shaders with legacy fallbacks, adds VAO usage, and moves texture parameter setup to initialization for performance and stability. Sequence diagram for shared_ptr-based YUV frame rendering pipelinesequenceDiagram
participant MajorImageProcessingThread
participant PreviewOpenglWidget
participant QtEventLoop
MajorImageProcessingThread->>PreviewOpenglWidget: sigYUVFrame(shared_ptr<uchar[]> yuv, uint width, uint height)
PreviewOpenglWidget->>PreviewOpenglWidget: slotShowYuv(shared_ptr<uchar[]> frame, uint width, uint height)
PreviewOpenglWidget->>PreviewOpenglWidget: update()
QtEventLoop->>PreviewOpenglWidget: paintGL()
PreviewOpenglWidget->>PreviewOpenglWidget: lock(m_Rendermutex)
PreviewOpenglWidget->>PreviewOpenglWidget: localFrame = m_yuvFrame
PreviewOpenglWidget->>PreviewOpenglWidget: glTexSubImage2D(..., localFrame.get())
PreviewOpenglWidget->>PreviewOpenglWidget: glDrawArrays(GL_TRIANGLE_FAN, 0, 4)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 代码已达到优秀标准,无需额外修复,以下为当前优秀的实现片段展示:
void PreviewOpenglWidget::slotShowYuv(std::shared_ptr<uchar[]> frame, uint width, uint height)
{
if (!frame) {
return;
}
{
QMutexLocker locker(&m_Rendermutex);
m_videoWidth = width;
m_videoHeight = height;
m_yuvFrame = std::move(frame);
}
update();
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Manage YUV frame lifetime with shared_ptr for thread-safe rendering, add core-profile shaders with legacy fallback and one-time texture setup.
使用 shared_ptr 管理 YUV 帧生命周期实现跨线程安全渲染,新增
core-profile 着色器并保留 legacy 回退,纹理参数改为初始化时一次性设置。
Log: 修复相机预览OpenGL渲染异常与YUV帧生命周期管理问题
PMS: BUG-372435
Influence: 修复预览画面渲染异常及潜在崩溃,提升OpenGL渲染稳定性与兼容性。
Summary by Sourcery
Stabilize OpenGL-based camera preview rendering by introducing safer YUV frame ownership and modern/legacy shader handling.
New Features:
Bug Fixes:
Enhancements:
Chores: