|  |  | @ -41,6 +41,8 @@ MapRenderer::MapRenderer(const QMapLibre::Settings &settings, bool online) : m_s | 
			
		
	
		
		
			
				
					
					|  |  |  |   QSurfaceFormat fmt; |  |  |  |   QSurfaceFormat fmt; | 
			
		
	
		
		
			
				
					
					|  |  |  |   fmt.setRenderableType(QSurfaceFormat::OpenGLES); |  |  |  |   fmt.setRenderableType(QSurfaceFormat::OpenGLES); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   m_settings.setMapMode(QMapLibre::Settings::MapMode::Static); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   ctx = std::make_unique<QOpenGLContext>(); |  |  |  |   ctx = std::make_unique<QOpenGLContext>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   ctx->setFormat(fmt); |  |  |  |   ctx->setFormat(fmt); | 
			
		
	
		
		
			
				
					
					|  |  |  |   ctx->create(); |  |  |  |   ctx->create(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -87,6 +89,18 @@ MapRenderer::MapRenderer(const QMapLibre::Settings &settings, bool online) : m_s | 
			
		
	
		
		
			
				
					
					|  |  |  |     LOGE("Map loading failed with %d: '%s'\n", err_code, reason.toStdString().c_str()); |  |  |  |     LOGE("Map loading failed with %d: '%s'\n", err_code, reason.toStdString().c_str()); | 
			
		
	
		
		
			
				
					
					|  |  |  |   }); |  |  |  |   }); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   QObject::connect(m_map.data(), &QMapLibre::Map::staticRenderFinished, [=](const QString &error) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     rendering = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (!error.isEmpty()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       LOGE("Static map rendering failed with error: '%s'\n", error.toStdString().c_str()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } else if (vipc_server != nullptr) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       double end_render_t = millis_since_boot(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       publish((end_render_t - start_render_t) / 1000.0, true); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       last_llk_rendered = (*sm)["liveLocationKalman"].getLogMonoTime(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (online) { |  |  |  |   if (online) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     vipc_server.reset(new VisionIpcServer("navd")); |  |  |  |     vipc_server.reset(new VisionIpcServer("navd")); | 
			
		
	
		
		
			
				
					
					|  |  |  |     vipc_server->create_buffers(VisionStreamType::VISION_STREAM_MAP, NUM_VIPC_BUFFERS, false, WIDTH, HEIGHT); |  |  |  |     vipc_server->create_buffers(VisionStreamType::VISION_STREAM_MAP, NUM_VIPC_BUFFERS, false, WIDTH, HEIGHT); | 
			
		
	
	
		
		
			
				
					|  |  | @ -114,22 +128,16 @@ void MapRenderer::msgUpdate() { | 
			
		
	
		
		
			
				
					
					|  |  |  |       float bearing = RAD2DEG(orientation.getValue()[2]); |  |  |  |       float bearing = RAD2DEG(orientation.getValue()[2]); | 
			
		
	
		
		
			
				
					
					|  |  |  |       updatePosition(get_point_along_line(pos.getValue()[0], pos.getValue()[1], bearing, MAP_OFFSET), bearing); |  |  |  |       updatePosition(get_point_along_line(pos.getValue()[0], pos.getValue()[1], bearing, MAP_OFFSET), bearing); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       // TODO: use the static rendering mode instead
 |  |  |  |       if (!rendering) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       // retry render a few times
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       for (int i = 0; i < 5 && !rendered(); i++) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         QApplication::processEvents(QEventLoop::AllEvents, 100); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         update(); |  |  |  |         update(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (rendered()) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |           LOGW("rendered after %d retries", i+1); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |           break; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       // fallback to sending a blank frame
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       if (!rendered()) { |  |  |  |       if (!rendered()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         publish(0, false); |  |  |  |         publish(0, false); | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (sm->updated("navRoute")) { |  |  |  |   if (sm->updated("navRoute")) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -157,24 +165,20 @@ void MapRenderer::updatePosition(QMapLibre::Coordinate position, float bearing) | 
			
		
	
		
		
			
				
					
					|  |  |  |   m_map->setCoordinate(position); |  |  |  |   m_map->setCoordinate(position); | 
			
		
	
		
		
			
				
					
					|  |  |  |   m_map->setBearing(bearing); |  |  |  |   m_map->setBearing(bearing); | 
			
		
	
		
		
			
				
					
					|  |  |  |   m_map->setZoom(zoom); |  |  |  |   m_map->setZoom(zoom); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   if (!rendering) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     update(); |  |  |  |     update(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | bool MapRenderer::loaded() { |  |  |  | bool MapRenderer::loaded() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   return m_map->isFullyLoaded(); |  |  |  |   return m_map->isFullyLoaded(); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void MapRenderer::update() { |  |  |  | void MapRenderer::update() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   double start_t = millis_since_boot(); |  |  |  |   rendering = true; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   gl_functions->glClear(GL_COLOR_BUFFER_BIT); |  |  |  |   gl_functions->glClear(GL_COLOR_BUFFER_BIT); | 
			
		
	
		
		
			
				
					
					|  |  |  |   m_map->render(); |  |  |  |   start_render_t = millis_since_boot(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   gl_functions->glFlush(); |  |  |  |   m_map->startStaticRender(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   double end_t = millis_since_boot(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   if ((vipc_server != nullptr) && loaded()) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     publish((end_t - start_t) / 1000.0, true); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     last_llk_rendered = (*sm)["liveLocationKalman"].getLogMonoTime(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void MapRenderer::sendThumbnail(const uint64_t ts, const kj::Array<capnp::byte> &buf) { |  |  |  | void MapRenderer::sendThumbnail(const uint64_t ts, const kj::Array<capnp::byte> &buf) { | 
			
		
	
	
		
		
			
				
					|  |  | 
 |