mapsd: release MapRenderer on exit (#28988)

old-commit-hash: 70b2a5220f
beeps
Dean Lee 2 years ago committed by GitHub
parent ac33a1208e
commit cb8cc55d01
  1. 4
      selfdrive/navd/main.cc
  2. 9
      selfdrive/navd/map_renderer.cc
  3. 1
      selfdrive/navd/map_renderer.h

@ -14,8 +14,6 @@ int main(int argc, char *argv[]) {
std::signal(SIGINT, sigTermHandler); std::signal(SIGINT, sigTermHandler);
std::signal(SIGTERM, sigTermHandler); std::signal(SIGTERM, sigTermHandler);
MapRenderer * m = new MapRenderer(get_mapbox_settings()); MapRenderer m(get_mapbox_settings());
assert(m);
return app.exec(); return app.exec();
} }

@ -53,8 +53,7 @@ MapRenderer::MapRenderer(const QMapboxGLSettings &settings, bool online) : m_set
ctx->makeCurrent(surface.get()); ctx->makeCurrent(surface.get());
assert(QOpenGLContext::currentContext() == ctx.get()); assert(QOpenGLContext::currentContext() == ctx.get());
gl_functions.reset(ctx->functions()); ctx->functions()->initializeOpenGLFunctions();
gl_functions->initializeOpenGLFunctions();
QOpenGLFramebufferObjectFormat fbo_format; QOpenGLFramebufferObjectFormat fbo_format;
fbo.reset(new QOpenGLFramebufferObject(WIDTH, HEIGHT, fbo_format)); fbo.reset(new QOpenGLFramebufferObject(WIDTH, HEIGHT, fbo_format));
@ -67,7 +66,7 @@ MapRenderer::MapRenderer(const QMapboxGLSettings &settings, bool online) : m_set
m_map->resize(fbo->size()); m_map->resize(fbo->size());
m_map->setFramebufferObject(fbo->handle(), fbo->size()); m_map->setFramebufferObject(fbo->handle(), fbo->size());
gl_functions->glViewport(0, 0, WIDTH, HEIGHT); ctx->functions()->glViewport(0, 0, WIDTH, HEIGHT);
QObject::connect(m_map.data(), &QMapboxGL::mapChanged, [=](QMapboxGL::MapChange change) { QObject::connect(m_map.data(), &QMapboxGL::mapChanged, [=](QMapboxGL::MapChange change) {
// https://github.com/mapbox/mapbox-gl-native/blob/cf734a2fec960025350d8de0d01ad38aeae155a0/platform/qt/include/qmapboxgl.hpp#L116 // https://github.com/mapbox/mapbox-gl-native/blob/cf734a2fec960025350d8de0d01ad38aeae155a0/platform/qt/include/qmapboxgl.hpp#L116
@ -157,9 +156,9 @@ bool MapRenderer::loaded() {
void MapRenderer::update() { void MapRenderer::update() {
double start_t = millis_since_boot(); double start_t = millis_since_boot();
gl_functions->glClear(GL_COLOR_BUFFER_BIT); ctx->functions()->glClear(GL_COLOR_BUFFER_BIT);
m_map->render(); m_map->render();
gl_functions->glFlush(); ctx->functions()->glFlush();
double end_t = millis_since_boot(); double end_t = millis_since_boot();
if ((vipc_server != nullptr) && loaded()) { if ((vipc_server != nullptr) && loaded()) {

@ -28,7 +28,6 @@ public:
private: private:
std::unique_ptr<QOpenGLContext> ctx; std::unique_ptr<QOpenGLContext> ctx;
std::unique_ptr<QOffscreenSurface> surface; std::unique_ptr<QOffscreenSurface> surface;
std::unique_ptr<QOpenGLFunctions> gl_functions;
std::unique_ptr<QOpenGLFramebufferObject> fbo; std::unique_ptr<QOpenGLFramebufferObject> fbo;
std::unique_ptr<VisionIpcServer> vipc_server; std::unique_ptr<VisionIpcServer> vipc_server;

Loading…
Cancel
Save