forked from organicmaps/organicmaps
Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
|
fdbb91aba3 |
5 changed files with 113 additions and 21 deletions
84
data/graphics_benchmark.json
Normal file
84
data/graphics_benchmark.json
Normal file
|
@ -0,0 +1,84 @@
|
|||
{
|
||||
"isActive":false,
|
||||
"scenarios":[
|
||||
{
|
||||
"name":"Zoom10",
|
||||
"steps":[
|
||||
{
|
||||
"city":"Minsk",
|
||||
"actionType":"centerViewport",
|
||||
"center":{
|
||||
"lat":53.893009,
|
||||
"lon":27.567444
|
||||
},
|
||||
"zoomLevel":10
|
||||
},
|
||||
{
|
||||
"actionType":"waitForTime",
|
||||
"time":5
|
||||
},
|
||||
{
|
||||
"city":"Moscow",
|
||||
"actionType":"centerViewport",
|
||||
"center":{
|
||||
"lat":55.751244,
|
||||
"lon":37.618423
|
||||
},
|
||||
"zoomLevel":10
|
||||
},
|
||||
{
|
||||
"actionType":"waitForTime",
|
||||
"time":5
|
||||
},
|
||||
{
|
||||
"city":"Istanbul",
|
||||
"actionType":"centerViewport",
|
||||
"center":{
|
||||
"lat":41.015137,
|
||||
"lon":28.979530
|
||||
},
|
||||
"zoomLevel":10
|
||||
},
|
||||
{
|
||||
"actionType":"waitForTime",
|
||||
"time":5
|
||||
},
|
||||
{
|
||||
"city":"Barcelona",
|
||||
"actionType":"centerViewport",
|
||||
"center":{
|
||||
"lat":41.390205,
|
||||
"lon":2.154007
|
||||
},
|
||||
"zoomLevel":10
|
||||
},
|
||||
{
|
||||
"actionType":"waitForTime",
|
||||
"time":5
|
||||
},
|
||||
{
|
||||
"city":"London",
|
||||
"actionType":"centerViewport",
|
||||
"center":{
|
||||
"lat":51.509865,
|
||||
"lon":-0.118092
|
||||
},
|
||||
"zoomLevel":10
|
||||
},
|
||||
{
|
||||
"actionType":"waitForTime",
|
||||
"time":5
|
||||
},
|
||||
{
|
||||
"city":"Paris",
|
||||
"actionType":"centerViewport",
|
||||
"center":{
|
||||
"lat":48.864716,
|
||||
"lon":2.349014
|
||||
},
|
||||
"zoomLevel":10
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -34,13 +34,9 @@ void ScenarioManager::Interrupt()
|
|||
bool ScenarioManager::RunScenario(ScenarioData && scenarioData, ScenarioCallback const & onStartFn, ScenarioCallback const & onFinishFn)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (m_thread != nullptr)
|
||||
{
|
||||
if (m_isFinished)
|
||||
InterruptImpl();
|
||||
else
|
||||
return false; // The only scenario can be executed currently.
|
||||
}
|
||||
// The only scenario can be executed currently.
|
||||
if (IsRunningImpl())
|
||||
return false;
|
||||
|
||||
std::swap(m_scenarioData, scenarioData);
|
||||
m_onStartHandler = onStartFn;
|
||||
|
@ -52,9 +48,8 @@ bool ScenarioManager::RunScenario(ScenarioData && scenarioData, ScenarioCallback
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ScenarioManager::IsRunning()
|
||||
bool ScenarioManager::IsRunningImpl()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (m_thread == nullptr)
|
||||
return false;
|
||||
|
||||
|
@ -66,10 +61,16 @@ bool ScenarioManager::IsRunning()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ScenarioManager::IsRunning()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return IsRunningImpl();
|
||||
}
|
||||
|
||||
void ScenarioManager::ThreadRoutine()
|
||||
{
|
||||
std::string const scenarioName = m_scenarioData.m_name;
|
||||
if (m_onStartHandler != nullptr)
|
||||
if (m_onStartHandler)
|
||||
m_onStartHandler(scenarioName);
|
||||
|
||||
for (auto const & action : m_scenarioData.m_scenario)
|
||||
|
@ -84,11 +85,11 @@ void ScenarioManager::ThreadRoutine()
|
|||
}
|
||||
}
|
||||
|
||||
switch(action->GetType())
|
||||
switch (action->GetType())
|
||||
{
|
||||
case ActionType::CenterViewport:
|
||||
{
|
||||
CenterViewportAction * centerViewportAction = static_cast<CenterViewportAction *>(action.get());
|
||||
auto const * centerViewportAction = static_cast<CenterViewportAction const *>(action.get());
|
||||
m_frontendRenderer->AddUserEvent(make_unique_dp<SetCenterEvent>(centerViewportAction->GetCenter(),
|
||||
centerViewportAction->GetZoomLevel(),
|
||||
true /* isAnim */,
|
||||
|
@ -99,7 +100,7 @@ void ScenarioManager::ThreadRoutine()
|
|||
|
||||
case ActionType::WaitForTime:
|
||||
{
|
||||
WaitForTimeAction * waitForTimeAction = static_cast<WaitForTimeAction *>(action.get());
|
||||
auto const * waitForTimeAction = static_cast<WaitForTimeAction const *>(action.get());
|
||||
std::this_thread::sleep_for(waitForTimeAction->GetDuration());
|
||||
break;
|
||||
}
|
||||
|
@ -109,19 +110,19 @@ void ScenarioManager::ThreadRoutine()
|
|||
}
|
||||
}
|
||||
|
||||
ScenarioCallback handler = nullptr;
|
||||
ScenarioCallback handler;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_scenarioData.m_scenario.clear();
|
||||
m_isFinished = true;
|
||||
if (m_onFinishHandler != nullptr)
|
||||
if (m_onFinishHandler)
|
||||
{
|
||||
handler = m_onFinishHandler;
|
||||
m_onFinishHandler = nullptr;
|
||||
handler = std::move(m_onFinishHandler);
|
||||
m_onFinishHandler = {};
|
||||
}
|
||||
}
|
||||
|
||||
if (handler != nullptr)
|
||||
if (handler)
|
||||
handler(scenarioName);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ public:
|
|||
private:
|
||||
void ThreadRoutine();
|
||||
void InterruptImpl();
|
||||
bool IsRunningImpl();
|
||||
|
||||
FrontendRenderer * m_frontendRenderer;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "storage/country_info_getter.hpp"
|
||||
|
||||
#include "platform/downloader_defines.hpp"
|
||||
#include "platform/http_client.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include "coding/reader.hpp"
|
||||
|
@ -91,7 +90,7 @@ void RunGraphicsBenchmark(Framework * framework)
|
|||
auto const fn = base::JoinPath(GetPlatform().SettingsDir(), "graphics_benchmark.json");
|
||||
if (!GetPlatform().IsFileExistsByFullPath(fn))
|
||||
return;
|
||||
|
||||
|
||||
std::string benchmarkData;
|
||||
try
|
||||
{
|
||||
|
@ -102,7 +101,7 @@ void RunGraphicsBenchmark(Framework * framework)
|
|||
LOG(LCRITICAL, ("Error reading benchmark file: ", e.what()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<BenchmarkHandle> handle = std::make_shared<BenchmarkHandle>();
|
||||
|
||||
// Parse scenarios.
|
||||
|
@ -110,6 +109,11 @@ void RunGraphicsBenchmark(Framework * framework)
|
|||
try
|
||||
{
|
||||
base::Json root(benchmarkData.c_str());
|
||||
|
||||
auto const isActive = FromJSONObjectOptional<bool>(root.get(), "isActive");
|
||||
if (isActive && *isActive == false)
|
||||
return;
|
||||
|
||||
json_t * scenariosNode = json_object_get(root.get(), "scenarios");
|
||||
if (scenariosNode == nullptr || !json_is_array(scenariosNode))
|
||||
return;
|
||||
|
|
|
@ -932,6 +932,7 @@ void Framework::SaveViewport()
|
|||
|
||||
void Framework::LoadViewport()
|
||||
{
|
||||
#ifndef SCENARIO_ENABLE
|
||||
m2::AnyRectD rect;
|
||||
if (settings::Get("ScreenClipRect", rect) && df::GetWorldRect().IsRectInside(rect.GetGlobalRect()))
|
||||
{
|
||||
|
@ -942,6 +943,7 @@ void Framework::LoadViewport()
|
|||
{
|
||||
ShowAll();
|
||||
}
|
||||
#endif // SCENARIO_ENABLE
|
||||
}
|
||||
|
||||
void Framework::ShowAll()
|
||||
|
|
Loading…
Add table
Reference in a new issue