Remove GlContext from MapContext, layers receive MapContext from Initialize/Render

This commit is contained in:
Dan Paulat 2025-05-08 23:15:46 -05:00
parent 2d4ad2737e
commit 44a864f50f
25 changed files with 446 additions and 398 deletions

View file

@ -135,14 +135,14 @@ public:
std::size_t lineWidth_ {};
};
explicit Impl(AlertLayer* self,
std::shared_ptr<gl::GlContext> context,
awips::Phenomenon phenomenon) :
explicit Impl(AlertLayer* self,
const std::shared_ptr<gl::GlContext>& glContext,
awips::Phenomenon phenomenon) :
self_ {self},
phenomenon_ {phenomenon},
ibw_ {awips::ibw::GetImpactBasedWarningInfo(phenomenon)},
geoLines_ {{false, std::make_shared<gl::draw::GeoLines>(context)},
{true, std::make_shared<gl::draw::GeoLines>(context)}}
geoLines_ {{false, std::make_shared<gl::draw::GeoLines>(glContext)},
{true, std::make_shared<gl::draw::GeoLines>(glContext)}}
{
UpdateLineData();
ConnectSignals();
@ -245,12 +245,12 @@ public:
std::vector<boost::signals2::scoped_connection> connections_ {};
};
AlertLayer::AlertLayer(const std::shared_ptr<MapContext>& context,
awips::Phenomenon phenomenon) :
AlertLayer::AlertLayer(const std::shared_ptr<gl::GlContext>& glContext,
awips::Phenomenon phenomenon) :
DrawLayer(
context,
glContext,
fmt::format("AlertLayer {}", awips::GetPhenomenonText(phenomenon))),
p(std::make_unique<Impl>(this, context->gl_context(), phenomenon))
p(std::make_unique<Impl>(this, glContext, phenomenon))
{
for (auto alertActive : {false, true})
{
@ -274,11 +274,11 @@ void AlertLayer::InitializeHandler()
}
}
void AlertLayer::Initialize()
void AlertLayer::Initialize(const std::shared_ptr<MapContext>& mapContext)
{
logger_->debug("Initialize: {}", awips::GetPhenomenonText(p->phenomenon_));
DrawLayer::Initialize();
DrawLayer::Initialize(mapContext);
auto& alertLayerHandler = AlertLayerHandler::Instance();
@ -296,16 +296,17 @@ void AlertLayer::Initialize()
p->ConnectAlertHandlerSignals();
}
void AlertLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
void AlertLayer::Render(const std::shared_ptr<MapContext>& mapContext,
const QMapLibre::CustomLayerRenderParameters& params)
{
gl::OpenGLFunctions& gl = context()->gl_context()->gl();
gl::OpenGLFunctions& gl = gl_context()->gl();
for (auto alertActive : {false, true})
{
p->geoLines_.at(alertActive)->set_selected_time(p->selectedTime_);
}
DrawLayer::Render(params);
DrawLayer::Render(mapContext, params);
SCWX_GL_CHECK_ERROR();
}