From cef3163c7ccdd55c10750123c2fcc7cb5ad4563d Mon Sep 17 00:00:00 2001 From: royjr Date: Tue, 23 Sep 2025 06:54:46 -0400 Subject: [PATCH] more more more cached params --- selfdrive/ui/qt/widgets/cameraview.cc | 13 ++++++++++++- selfdrive/ui/qt/widgets/cameraview.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc index 3a10c9584a..9def51675a 100644 --- a/selfdrive/ui/qt/widgets/cameraview.cc +++ b/selfdrive/ui/qt/widgets/cameraview.cc @@ -62,6 +62,10 @@ const char frame_fragment_shader[] = } // namespace +void CameraWidget::updateParams() { + visual_style_ = QString::fromStdString(Params().get("VisualStyle")).toInt(); +} + CameraWidget::CameraWidget(std::string stream_name, VisionStreamType type, QWidget* parent) : stream_name(stream_name), active_stream_type(type), requested_stream_type(type), QOpenGLWidget(parent) { setAttribute(Qt::WA_OpaquePaintEvent); @@ -196,6 +200,13 @@ mat4 CameraWidget::calcFrameMatrix() { } void CameraWidget::paintGL() { + static double last_params_t = 0.0; + double now = millis_since_boot(); + if (now - last_params_t > 1000.0) { + updateParams(); + last_params_t = now; + } + glClearColor(bg.redF(), bg.greenF(), bg.blueF(), bg.alphaF()); glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); @@ -248,7 +259,7 @@ void CameraWidget::paintGL() { glUniformMatrix4fv(program->uniformLocation("uTransform"), 1, GL_TRUE, frame_mat.v); glEnableVertexAttribArray(0); - if (QString::fromStdString(Params().get("VisualStyle")).toInt() == 0) { + if (visual_style_ == 0) { glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, (const void *)0); } glDisableVertexAttribArray(0); diff --git a/selfdrive/ui/qt/widgets/cameraview.h b/selfdrive/ui/qt/widgets/cameraview.h index e446ef5987..c4a74bb8bf 100644 --- a/selfdrive/ui/qt/widgets/cameraview.h +++ b/selfdrive/ui/qt/widgets/cameraview.h @@ -60,6 +60,9 @@ protected: void vipcThread(); void clearFrames(); + void updateParams(); + int visual_style_ = 0; + int glWidth(); int glHeight();