mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:40:05 +00:00
Reorder initialization and rendering to prevent color flicker
This commit is contained in:
parent
5a0224631d
commit
dd3751313f
5 changed files with 21 additions and 5 deletions
|
|
@ -106,6 +106,12 @@ void ColorTableLayer::Render(const QMapbox::CustomLayerRenderParameters& params)
|
||||||
{
|
{
|
||||||
gl::OpenGLFunctions& gl = context()->gl_;
|
gl::OpenGLFunctions& gl = context()->gl_;
|
||||||
|
|
||||||
|
if (!context()->radarProductView_->IsInitialized())
|
||||||
|
{
|
||||||
|
// Defer rendering until view is initialized
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
glm::mat4 projection = glm::ortho(0.0f,
|
glm::mat4 projection = glm::ortho(0.0f,
|
||||||
static_cast<float>(params.width),
|
static_cast<float>(params.width),
|
||||||
0.0f,
|
0.0f,
|
||||||
|
|
|
||||||
|
|
@ -274,8 +274,6 @@ void MapWidget::SelectRadarProduct(common::Level2Product product)
|
||||||
util::async(
|
util::async(
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
radarProductView->Initialize();
|
|
||||||
|
|
||||||
std::string colorTableFile =
|
std::string colorTableFile =
|
||||||
manager::SettingsManager::palette_settings()->palette(
|
manager::SettingsManager::palette_settings()->palette(
|
||||||
common::GetLevel2Palette(product));
|
common::GetLevel2Palette(product));
|
||||||
|
|
@ -285,6 +283,8 @@ void MapWidget::SelectRadarProduct(common::Level2Product product)
|
||||||
common::ColorTable::Load(colorTableFile);
|
common::ColorTable::Load(colorTableFile);
|
||||||
radarProductView->LoadColorTable(colorTable);
|
radarProductView->LoadColorTable(colorTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
radarProductView->Initialize();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (p->map_ != nullptr)
|
if (p->map_ != nullptr)
|
||||||
|
|
|
||||||
|
|
@ -630,9 +630,9 @@ void Level2ProductView::ComputeSweep()
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
BOOST_LOG_TRIVIAL(debug)
|
||||||
<< logPrefix_ << "Vertices calculated in " << timer.format(6, "%ws");
|
<< logPrefix_ << "Vertices calculated in " << timer.format(6, "%ws");
|
||||||
|
|
||||||
emit SweepComputed();
|
|
||||||
|
|
||||||
UpdateColorTable();
|
UpdateColorTable();
|
||||||
|
|
||||||
|
emit SweepComputed();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Level2ProductView> Level2ProductView::Create(
|
std::shared_ptr<Level2ProductView> Level2ProductView::Create(
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,10 @@ static const uint16_t DEFAULT_COLOR_TABLE_MAX = 255u;
|
||||||
class RadarProductViewImpl
|
class RadarProductViewImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit RadarProductViewImpl() : sweepMutex_ {} {}
|
explicit RadarProductViewImpl() : initialized_ {false}, sweepMutex_ {} {}
|
||||||
~RadarProductViewImpl() = default;
|
~RadarProductViewImpl() = default;
|
||||||
|
|
||||||
|
bool initialized_;
|
||||||
std::mutex sweepMutex_;
|
std::mutex sweepMutex_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -73,10 +74,17 @@ std::mutex& RadarProductView::sweep_mutex()
|
||||||
void RadarProductView::Initialize()
|
void RadarProductView::Initialize()
|
||||||
{
|
{
|
||||||
ComputeSweep();
|
ComputeSweep();
|
||||||
|
|
||||||
|
p->initialized_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadarProductView::SelectElevation(float elevation) {}
|
void RadarProductView::SelectElevation(float elevation) {}
|
||||||
|
|
||||||
|
bool RadarProductView::IsInitialized() const
|
||||||
|
{
|
||||||
|
return p->initialized_;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<float> RadarProductView::GetElevationCuts() const
|
std::vector<float> RadarProductView::GetElevationCuts() const
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ public:
|
||||||
virtual void SelectTime(std::chrono::system_clock::time_point time) = 0;
|
virtual void SelectTime(std::chrono::system_clock::time_point time) = 0;
|
||||||
virtual void Update() = 0;
|
virtual void Update() = 0;
|
||||||
|
|
||||||
|
bool IsInitialized() const;
|
||||||
|
|
||||||
virtual common::RadarProductGroup GetRadarProductGroup() const = 0;
|
virtual common::RadarProductGroup GetRadarProductGroup() const = 0;
|
||||||
virtual std::string GetRadarProductName() const = 0;
|
virtual std::string GetRadarProductName() const = 0;
|
||||||
virtual std::vector<float> GetElevationCuts() const;
|
virtual std::vector<float> GetElevationCuts() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue