ui: fix HUD drawing order (#24419)

old-commit-hash: e8892481ab
taco
Willem Melching 3 years ago committed by GitHub
parent 44a92a53d0
commit 1ccab5f034
  1. 12
      selfdrive/ui/qt/onroad.cc

@ -294,6 +294,8 @@ void NvgWindow::updateFrameMat(int w, int h) {
} }
void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) { void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) {
painter.save();
const UIScene &scene = s->scene; const UIScene &scene = s->scene;
// lanelines // lanelines
for (int i = 0; i < std::size(scene.lane_line_vertices); ++i) { for (int i = 0; i < std::size(scene.lane_line_vertices); ++i) {
@ -329,9 +331,13 @@ void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) {
} }
painter.setBrush(bg); painter.setBrush(bg);
painter.drawPolygon(scene.track_vertices.v, scene.track_vertices.cnt); painter.drawPolygon(scene.track_vertices.v, scene.track_vertices.cnt);
painter.restore();
} }
void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd) { void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd) {
painter.save();
const float speedBuff = 10.; const float speedBuff = 10.;
const float leadBuff = 40.; const float leadBuff = 40.;
const float d_rel = lead_data.getX()[0]; const float d_rel = lead_data.getX()[0];
@ -361,6 +367,8 @@ void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV
QPointF chevron[] = {{x + (sz * 1.25), y + sz}, {x, y}, {x - (sz * 1.25), y + sz}}; QPointF chevron[] = {{x + (sz * 1.25), y + sz}, {x, y}, {x - (sz * 1.25), y + sz}};
painter.setBrush(redColor(fillAlpha)); painter.setBrush(redColor(fillAlpha));
painter.drawPolygon(chevron, std::size(chevron)); painter.drawPolygon(chevron, std::size(chevron));
painter.restore();
} }
void NvgWindow::paintGL() { void NvgWindow::paintGL() {
@ -370,8 +378,6 @@ void NvgWindow::paintGL() {
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
drawHud(painter);
UIState *s = uiState(); UIState *s = uiState();
if (s->worldObjectsVisible()) { if (s->worldObjectsVisible()) {
@ -388,6 +394,8 @@ void NvgWindow::paintGL() {
} }
} }
drawHud(painter);
double cur_draw_t = millis_since_boot(); double cur_draw_t = millis_since_boot();
double dt = cur_draw_t - prev_draw_t; double dt = cur_draw_t - prev_draw_t;
double fps = fps_filter.update(1. / dt * 1000); double fps = fps_filter.update(1. / dt * 1000);

Loading…
Cancel
Save