From 0a9b8f2a32f11c38a211cc1678d8dd7a4fa36ca7 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Sat, 4 Jul 2020 10:42:26 +0800 Subject: [PATCH] paint.cc: Simplify drawing line (#1643) * simplify drawing line * remove space old-commit-hash: ff4f432f0fd2ca5cf592082914e3a3a7b091a3db --- selfdrive/ui/paint.cc | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index d0b0425e8..b577d78be 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -128,20 +128,12 @@ static void draw_lead(UIState *s, const cereal::RadarState::LeadData::Reader &le } static void ui_draw_lane_line(UIState *s, const model_path_vertices_data *pvd, NVGcolor color) { + if (pvd->cnt == 0) return; + nvgBeginPath(s->vg); - bool started = false; - for (int i=0; icnt; i++) { - float x = pvd->v[i].x; - float y = pvd->v[i].y; - if (x < 0 || y < 0.) { - continue; - } - if (!started) { - nvgMoveTo(s->vg, x, y); - started = true; - } else { - nvgLineTo(s->vg, x, y); - } + nvgMoveTo(s->vg, pvd->v[0].x, pvd->v[0].y); + for (int i=1; icnt; i++) { + nvgLineTo(s->vg, pvd->v[i].x, pvd->v[i].y); } nvgClosePath(s->vg); nvgFillColor(s->vg, color); @@ -214,20 +206,12 @@ static void update_all_track_data(UIState *s) { static void ui_draw_track(UIState *s, bool is_mpc, track_vertices_data *pvd) { + if (pvd->cnt == 0) return; + nvgBeginPath(s->vg); - bool started = false; - for(int i = 0;i < pvd->cnt;i++) { - float x = pvd->v[i].x; - float y = pvd->v[i].y; - if (x < 0 || y < 0) { - continue; - } - if (!started) { - nvgMoveTo(s->vg, x, y); - started = true; - } else { - nvgLineTo(s->vg, x, y); - } + nvgMoveTo(s->vg, pvd->v[0].x, pvd->v[0].y); + for (int i=1; icnt; i++) { + nvgLineTo(s->vg, pvd->v[i].x, pvd->v[i].y); } nvgClosePath(s->vg);