forked from organicmaps/organicmaps
[core] Rendering on many surfaces
Signed-off-by: Andrew Shkrob <andrew.shkrob.social@yandex.by>
This commit is contained in:
parent
8fe6460422
commit
31b6b48e22
13 changed files with 503 additions and 441 deletions
|
@ -107,7 +107,6 @@ enum MultiTouchAction
|
|||
|
||||
Framework::Framework()
|
||||
: m_lastCompass(0.0)
|
||||
, m_isSurfaceDestroyed(false)
|
||||
, m_isChoosePositionMode(false)
|
||||
{
|
||||
m_work.GetTrafficManager().SetStateListener(bind(&Framework::TrafficStateChanged, this, _1));
|
||||
|
@ -163,15 +162,22 @@ void Framework::IsolinesSchemeStateChanged(IsolinesManager::IsolinesState state)
|
|||
m_onIsolinesStateChangedFn(state);
|
||||
}
|
||||
|
||||
bool Framework::DestroySurfaceOnDetach()
|
||||
bool Framework::DestroySurfaceOnDetach(df::DrapeEngineId engineId)
|
||||
{
|
||||
if (m_vulkanContextFactory)
|
||||
if (m_drapeEngines[engineId].m_vulkanContextFactory)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi, bool firstLaunch,
|
||||
bool launchByDeepLink, uint32_t appVersionCode)
|
||||
df::DrapeEngineId Framework::CreateDrapeEngineId()
|
||||
{
|
||||
df::DrapeEngineId engineId = m_work.CreateDrapeEngineId();
|
||||
m_drapeEngines[engineId];
|
||||
return engineId;
|
||||
}
|
||||
|
||||
bool Framework::CreateDrapeEngine(JNIEnv * env, df::DrapeEngineId engineId, jobject jSurface, int densityDpi,
|
||||
bool firstLaunch, bool launchByDeepLink, uint32_t appVersionCode)
|
||||
{
|
||||
// Vulkan is supported only since Android 8.0, because some Android devices with Android 7.x
|
||||
// have fatal driver issue, which can lead to process termination and whole OS destabilization.
|
||||
|
@ -183,34 +189,36 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
|
|||
if (vulkanForbidden)
|
||||
LOG(LWARNING, ("Vulkan API is forbidden on this device."));
|
||||
|
||||
DrapeEngineData &drapeEngineData = m_drapeEngines[engineId];
|
||||
|
||||
if (m_work.LoadPreferredGraphicsAPI() == dp::ApiVersion::Vulkan && !vulkanForbidden)
|
||||
{
|
||||
m_vulkanContextFactory =
|
||||
drapeEngineData.m_vulkanContextFactory =
|
||||
make_unique_dp<AndroidVulkanContextFactory>(appVersionCode, sdkVersion);
|
||||
if (!CastFactory(m_vulkanContextFactory)->IsVulkanSupported())
|
||||
if (!CastFactory(drapeEngineData.m_vulkanContextFactory)->IsVulkanSupported())
|
||||
{
|
||||
LOG(LWARNING, ("Vulkan API is not supported."));
|
||||
m_vulkanContextFactory.reset();
|
||||
drapeEngineData.m_vulkanContextFactory.reset();
|
||||
}
|
||||
|
||||
if (m_vulkanContextFactory)
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
{
|
||||
auto f = CastFactory(m_vulkanContextFactory);
|
||||
auto f = CastFactory(drapeEngineData.m_vulkanContextFactory);
|
||||
f->SetSurface(env, jSurface);
|
||||
if (!f->IsValid())
|
||||
{
|
||||
LOG(LWARNING, ("Invalid Vulkan API context."));
|
||||
m_vulkanContextFactory.reset();
|
||||
drapeEngineData.m_vulkanContextFactory.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AndroidOGLContextFactory * oglFactory = nullptr;
|
||||
if (!m_vulkanContextFactory)
|
||||
if (!drapeEngineData.m_vulkanContextFactory)
|
||||
{
|
||||
m_oglContextFactory = make_unique_dp<dp::ThreadSafeFactory>(
|
||||
drapeEngineData.m_oglContextFactory = make_unique_dp<dp::ThreadSafeFactory>(
|
||||
new AndroidOGLContextFactory(env, jSurface));
|
||||
oglFactory = m_oglContextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
oglFactory = drapeEngineData.m_oglContextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
if (!oglFactory->IsValid())
|
||||
{
|
||||
LOG(LWARNING, ("Invalid GL context."));
|
||||
|
@ -219,9 +227,9 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
|
|||
}
|
||||
|
||||
::Framework::DrapeCreationParams p;
|
||||
if (m_vulkanContextFactory)
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
{
|
||||
auto f = CastFactory(m_vulkanContextFactory);
|
||||
auto f = CastFactory(drapeEngineData.m_vulkanContextFactory);
|
||||
p.m_apiVersion = dp::ApiVersion::Vulkan;
|
||||
p.m_surfaceWidth = f->GetWidth();
|
||||
p.m_surfaceHeight = f->GetHeight();
|
||||
|
@ -238,33 +246,35 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
|
|||
p.m_isChoosePositionMode = m_isChoosePositionMode;
|
||||
p.m_hints.m_isFirstLaunch = firstLaunch;
|
||||
p.m_hints.m_isLaunchByDeepLink = launchByDeepLink;
|
||||
ASSERT(!m_guiPositions.empty(), ("GUI elements must be set-up before engine is created"));
|
||||
p.m_widgetsInitInfo = m_guiPositions;
|
||||
ASSERT(!drapeEngineData.m_guiPositions.empty(), ("GUI elements must be set-up before engine is created"));
|
||||
p.m_widgetsInitInfo = drapeEngineData.m_guiPositions;
|
||||
|
||||
m_work.SetMyPositionModeListener(bind(&Framework::MyPositionModeChanged, this, _1, _2));
|
||||
|
||||
if (m_vulkanContextFactory)
|
||||
m_work.CreateDrapeEngine(make_ref(m_vulkanContextFactory), move(p));
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
m_work.CreateDrapeEngine(engineId, make_ref(drapeEngineData.m_vulkanContextFactory), move(p));
|
||||
else
|
||||
m_work.CreateDrapeEngine(make_ref(m_oglContextFactory), move(p));
|
||||
m_work.CreateDrapeEngine(engineId, make_ref(drapeEngineData.m_oglContextFactory), move(p));
|
||||
|
||||
m_work.EnterForeground();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Framework::IsDrapeEngineCreated() const
|
||||
bool Framework::IsDrapeEngineCreated(df::DrapeEngineId engineId) const
|
||||
{
|
||||
return m_work.IsDrapeEngineCreated();
|
||||
return m_work.IsDrapeEngineCreated(engineId);
|
||||
}
|
||||
|
||||
void Framework::Resize(JNIEnv * env, jobject jSurface, int w, int h)
|
||||
void Framework::Resize(JNIEnv * env, df::DrapeEngineId engineId, jobject jSurface, int w, int h)
|
||||
{
|
||||
if (m_vulkanContextFactory)
|
||||
auto& drapeEngineData = m_drapeEngines[engineId];
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
{
|
||||
auto vulkanContextFactory = CastFactory(m_vulkanContextFactory);
|
||||
auto vulkanContextFactory = CastFactory(drapeEngineData.m_vulkanContextFactory);
|
||||
if (vulkanContextFactory->GetWidth() != w || vulkanContextFactory->GetHeight() != h)
|
||||
{
|
||||
m_vulkanContextFactory->SetPresentAvailable(false);
|
||||
drapeEngineData.m_vulkanContextFactory->SetPresentAvailable(false);
|
||||
m_work.SetRenderingDisabled(false /* destroySurface */);
|
||||
|
||||
vulkanContextFactory->ChangeSurface(env, jSurface, w, h);
|
||||
|
@ -275,32 +285,33 @@ void Framework::Resize(JNIEnv * env, jobject jSurface, int w, int h)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_oglContextFactory->CastFactory<AndroidOGLContextFactory>()->UpdateSurfaceSize(w, h);
|
||||
drapeEngineData.m_oglContextFactory->CastFactory<AndroidOGLContextFactory>()->UpdateSurfaceSize(w, h);
|
||||
}
|
||||
m_work.OnSize(w, h);
|
||||
m_work.OnSize(engineId, w, h);
|
||||
}
|
||||
|
||||
void Framework::DetachSurface(bool destroySurface)
|
||||
void Framework::DetachSurface(df::DrapeEngineId engineId, bool destroySurface)
|
||||
{
|
||||
LOG(LINFO, ("Detach surface started. destroySurface =", destroySurface));
|
||||
if (m_vulkanContextFactory)
|
||||
auto& drapeEngineData = m_drapeEngines[engineId];
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
{
|
||||
m_vulkanContextFactory->SetPresentAvailable(false);
|
||||
drapeEngineData.m_vulkanContextFactory->SetPresentAvailable(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(m_oglContextFactory != nullptr, ());
|
||||
m_oglContextFactory->SetPresentAvailable(false);
|
||||
ASSERT(drapeEngineData.m_oglContextFactory != nullptr, ());
|
||||
drapeEngineData.m_oglContextFactory->SetPresentAvailable(false);
|
||||
}
|
||||
|
||||
if (destroySurface)
|
||||
{
|
||||
LOG(LINFO, ("Destroy surface."));
|
||||
m_isSurfaceDestroyed = true;
|
||||
drapeEngineData.m_isSurfaceDestroyed = true;
|
||||
m_work.OnDestroySurface();
|
||||
}
|
||||
|
||||
if (m_vulkanContextFactory)
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
{
|
||||
// With Vulkan we don't need to recreate all graphics resources,
|
||||
// we have to destroy only resources bound with surface (swapchains,
|
||||
|
@ -309,25 +320,25 @@ void Framework::DetachSurface(bool destroySurface)
|
|||
m_work.SetRenderingDisabled(false /* destroySurface */);
|
||||
|
||||
// Allow pipeline dump only on enter background.
|
||||
CastFactory(m_vulkanContextFactory)->ResetSurface(destroySurface /* allowPipelineDump */);
|
||||
CastFactory(drapeEngineData.m_vulkanContextFactory)->ResetSurface(destroySurface /* allowPipelineDump */);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_work.SetRenderingDisabled(destroySurface);
|
||||
auto factory = m_oglContextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
auto factory = drapeEngineData.m_oglContextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
factory->ResetSurface();
|
||||
}
|
||||
LOG(LINFO, ("Detach surface finished."));
|
||||
}
|
||||
|
||||
bool Framework::AttachSurface(JNIEnv * env, jobject jSurface)
|
||||
bool Framework::AttachSurface(JNIEnv * env, df::DrapeEngineId engineId, jobject jSurface)
|
||||
{
|
||||
LOG(LINFO, ("Attach surface started."));
|
||||
|
||||
auto& drapeEngineData = m_drapeEngines[engineId];
|
||||
int w = 0, h = 0;
|
||||
if (m_vulkanContextFactory)
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
{
|
||||
auto factory = CastFactory(m_vulkanContextFactory);
|
||||
auto factory = CastFactory(drapeEngineData.m_vulkanContextFactory);
|
||||
factory->SetSurface(env, jSurface);
|
||||
if (!factory->IsValid())
|
||||
{
|
||||
|
@ -339,8 +350,8 @@ bool Framework::AttachSurface(JNIEnv * env, jobject jSurface)
|
|||
}
|
||||
else
|
||||
{
|
||||
ASSERT(m_oglContextFactory != nullptr, ());
|
||||
auto factory = m_oglContextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
ASSERT(drapeEngineData.m_oglContextFactory != nullptr, ());
|
||||
auto factory = drapeEngineData.m_oglContextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
factory->SetSurface(env, jSurface);
|
||||
if (!factory->IsValid())
|
||||
{
|
||||
|
@ -351,25 +362,25 @@ bool Framework::AttachSurface(JNIEnv * env, jobject jSurface)
|
|||
h = factory->GetHeight();
|
||||
}
|
||||
|
||||
ASSERT(!m_guiPositions.empty(), ("GUI elements must be set-up before engine is created"));
|
||||
ASSERT(!drapeEngineData.m_guiPositions.empty(), ("GUI elements must be set-up before engine is created"));
|
||||
|
||||
if (m_vulkanContextFactory)
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
{
|
||||
m_vulkanContextFactory->SetPresentAvailable(true);
|
||||
drapeEngineData.m_vulkanContextFactory->SetPresentAvailable(true);
|
||||
m_work.SetRenderingEnabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oglContextFactory->SetPresentAvailable(true);
|
||||
m_work.SetRenderingEnabled(make_ref(m_oglContextFactory));
|
||||
drapeEngineData.m_oglContextFactory->SetPresentAvailable(true);
|
||||
m_work.SetRenderingEnabled(make_ref(drapeEngineData.m_oglContextFactory));
|
||||
}
|
||||
|
||||
if (m_isSurfaceDestroyed)
|
||||
if (drapeEngineData.m_isSurfaceDestroyed)
|
||||
{
|
||||
LOG(LINFO, ("Recover surface, viewport size:", w, h));
|
||||
bool const recreateContextDependentResources = (m_vulkanContextFactory == nullptr);
|
||||
m_work.OnRecoverSurface(w, h, recreateContextDependentResources);
|
||||
m_isSurfaceDestroyed = false;
|
||||
bool const recreateContextDependentResources = (drapeEngineData.m_vulkanContextFactory == nullptr);
|
||||
m_work.OnRecoverSurface(engineId, w, h, recreateContextDependentResources);
|
||||
drapeEngineData.m_isSurfaceDestroyed = false;
|
||||
}
|
||||
|
||||
LOG(LINFO, ("Attach surface finished."));
|
||||
|
@ -377,26 +388,28 @@ bool Framework::AttachSurface(JNIEnv * env, jobject jSurface)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Framework::PauseSurfaceRendering()
|
||||
void Framework::PauseSurfaceRendering(df::DrapeEngineId engineId)
|
||||
{
|
||||
if (m_vulkanContextFactory)
|
||||
m_vulkanContextFactory->SetPresentAvailable(false);
|
||||
if (m_oglContextFactory)
|
||||
m_oglContextFactory->SetPresentAvailable(false);
|
||||
auto& drapeEngineData = m_drapeEngines[engineId];
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
drapeEngineData.m_vulkanContextFactory->SetPresentAvailable(false);
|
||||
if (drapeEngineData.m_oglContextFactory)
|
||||
drapeEngineData.m_oglContextFactory->SetPresentAvailable(false);
|
||||
|
||||
LOG(LINFO, ("Pause surface rendering."));
|
||||
}
|
||||
|
||||
void Framework::ResumeSurfaceRendering()
|
||||
void Framework::ResumeSurfaceRendering(df::DrapeEngineId engineId)
|
||||
{
|
||||
if (m_vulkanContextFactory)
|
||||
auto& drapeEngineData = m_drapeEngines[engineId];
|
||||
if (drapeEngineData.m_vulkanContextFactory)
|
||||
{
|
||||
if (CastFactory(m_vulkanContextFactory)->IsValid())
|
||||
m_vulkanContextFactory->SetPresentAvailable(true);
|
||||
if (CastFactory(drapeEngineData.m_vulkanContextFactory)->IsValid())
|
||||
drapeEngineData.m_vulkanContextFactory->SetPresentAvailable(true);
|
||||
}
|
||||
if (m_oglContextFactory)
|
||||
if (drapeEngineData.m_oglContextFactory)
|
||||
{
|
||||
AndroidOGLContextFactory * factory = m_oglContextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
AndroidOGLContextFactory * factory = drapeEngineData.m_oglContextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
if (factory->IsValid())
|
||||
factory->SetPresentAvailable(true);
|
||||
}
|
||||
|
@ -412,10 +425,13 @@ void Framework::MarkMapStyle(MapStyle mapStyle)
|
|||
{
|
||||
// In case of Vulkan rendering we don't recreate geometry and textures data, so
|
||||
// we need use SetMapStyle instead of MarkMapStyle in all cases.
|
||||
if (m_vulkanContextFactory)
|
||||
m_work.SetMapStyle(mapStyle);
|
||||
else
|
||||
m_work.MarkMapStyle(mapStyle);
|
||||
for (const auto& [engineId, engineData] : m_drapeEngines)
|
||||
{
|
||||
if (engineData.m_vulkanContextFactory)
|
||||
m_work.SetMapStyle(mapStyle);
|
||||
else
|
||||
m_work.MarkMapStyle(mapStyle);
|
||||
}
|
||||
}
|
||||
|
||||
MapStyle Framework::GetMapStyle() const
|
||||
|
@ -471,17 +487,17 @@ void Framework::ShowNode(CountryId const & idx, bool zoomToDownloadButton)
|
|||
}
|
||||
}
|
||||
|
||||
void Framework::Scale(double factor, m2::PointD const & pxPoint, bool isAnim)
|
||||
void Framework::Scale(df::DrapeEngineId engineId, double factor, m2::PointD const & pxPoint, bool isAnim)
|
||||
{
|
||||
m_work.Scale(factor, pxPoint, isAnim);
|
||||
m_work.Scale(engineId, factor, pxPoint, isAnim);
|
||||
}
|
||||
|
||||
void Framework::Move(double factorX, double factorY, bool isAnim)
|
||||
void Framework::Move(df::DrapeEngineId engineId, double factorX, double factorY, bool isAnim)
|
||||
{
|
||||
m_work.Move(factorX, factorY, isAnim);
|
||||
m_work.Move(engineId, factorX, factorY, isAnim);
|
||||
}
|
||||
|
||||
void Framework::Touch(int action, Finger const & f1, Finger const & f2, uint8_t maskedPointer)
|
||||
void Framework::Touch(df::DrapeEngineId engineId, int action, Finger const & f1, Finger const & f2, uint8_t maskedPointer)
|
||||
{
|
||||
MultiTouchAction eventType = static_cast<MultiTouchAction>(action);
|
||||
df::TouchEvent event;
|
||||
|
@ -514,7 +530,7 @@ void Framework::Touch(int action, Finger const & f1, Finger const & f2, uint8_t
|
|||
event.SetSecondTouch(touch);
|
||||
|
||||
event.SetFirstMaskedPointer(maskedPointer);
|
||||
m_work.TouchEvent(event);
|
||||
m_work.TouchEvent(engineId, event);
|
||||
}
|
||||
|
||||
m2::PointD Framework::GetViewportCenter() const
|
||||
|
@ -527,14 +543,14 @@ void Framework::AddString(string const & name, string const & value)
|
|||
m_work.AddString(name, value);
|
||||
}
|
||||
|
||||
void Framework::Scale(::Framework::EScaleMode mode)
|
||||
void Framework::Scale(df::DrapeEngineId engineId, ::Framework::EScaleMode mode)
|
||||
{
|
||||
m_work.Scale(mode, true);
|
||||
m_work.Scale(engineId, mode, true);
|
||||
}
|
||||
|
||||
void Framework::Scale(m2::PointD const & centerPt, int targetZoom, bool animate)
|
||||
void Framework::Scale(df::DrapeEngineId engineId, m2::PointD const & centerPt, int targetZoom, bool animate)
|
||||
{
|
||||
ref_ptr<df::DrapeEngine> engine = m_work.GetDrapeEngine();
|
||||
ref_ptr<df::DrapeEngine> engine = m_work.GetDrapeEngine(engineId);
|
||||
if (engine)
|
||||
engine->SetModelViewCenter(centerPt, targetZoom, animate, false);
|
||||
}
|
||||
|
@ -658,27 +674,27 @@ location::EMyPositionMode Framework::GetMyPositionMode() const
|
|||
|
||||
void Framework::SwitchMyPositionNextMode()
|
||||
{
|
||||
ASSERT(IsDrapeEngineCreated(), ());
|
||||
ASSERT(IsDrapeEngineCreated(0), ());
|
||||
m_work.SwitchMyPositionNextMode();
|
||||
}
|
||||
|
||||
void Framework::SetupWidget(gui::EWidget widget, float x, float y, dp::Anchor anchor)
|
||||
void Framework::SetupWidget(df::DrapeEngineId engineId, gui::EWidget widget, float x, float y, dp::Anchor anchor)
|
||||
{
|
||||
m_guiPositions[widget] = gui::Position(m2::PointF(x, y), anchor);
|
||||
m_drapeEngines[engineId].m_guiPositions[widget] = gui::Position(m2::PointF(x, y), anchor);
|
||||
}
|
||||
|
||||
void Framework::ApplyWidgets()
|
||||
void Framework::ApplyWidgets(df::DrapeEngineId engineId)
|
||||
{
|
||||
gui::TWidgetsLayoutInfo layout;
|
||||
for (auto const & widget : m_guiPositions)
|
||||
for (auto const & widget : m_drapeEngines[engineId].m_guiPositions)
|
||||
layout[widget.first] = widget.second.m_pixelPivot;
|
||||
|
||||
m_work.SetWidgetLayout(move(layout));
|
||||
m_work.SetWidgetLayout(engineId, move(layout));
|
||||
}
|
||||
|
||||
void Framework::CleanWidgets()
|
||||
void Framework::CleanWidgets(df::DrapeEngineId engineId)
|
||||
{
|
||||
m_guiPositions.clear();
|
||||
m_drapeEngines[engineId].m_guiPositions.clear();
|
||||
}
|
||||
|
||||
void Framework::SetupMeasurementSystem()
|
||||
|
@ -1628,7 +1644,8 @@ Java_app_organicmaps_Framework_nativeGetAutoZoomEnabled(JNIEnv *, jclass)
|
|||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Framework_nativeZoomToPoint(JNIEnv * env, jclass, jdouble lat, jdouble lon, jint zoom, jboolean animate)
|
||||
{
|
||||
g_framework->Scale(m2::PointD(mercator::FromLatLon(lat, lon)), zoom, animate);
|
||||
// TODO: fix
|
||||
g_framework->Scale(0, m2::PointD(mercator::FromLatLon(lat, lon)), zoom, animate);
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
|
@ -1691,7 +1708,7 @@ Java_app_organicmaps_Framework_nativeGetActiveObjectFormattedCuisine(JNIEnv * en
|
|||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Framework_nativeSetVisibleRect(JNIEnv * env, jclass, jint left, jint top, jint right, jint bottom)
|
||||
{
|
||||
frm()->SetVisibleViewport(m2::RectD(left, top, right, bottom));
|
||||
// frm()->SetVisibleViewport(m2::RectD(left, top, right, bottom));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
|
|
|
@ -50,8 +50,14 @@ namespace android
|
|||
class Framework : private power_management::PowerManager::Subscriber
|
||||
{
|
||||
private:
|
||||
drape_ptr<dp::ThreadSafeFactory> m_oglContextFactory;
|
||||
drape_ptr<dp::GraphicsContextFactory> m_vulkanContextFactory;
|
||||
struct DrapeEngineData
|
||||
{
|
||||
drape_ptr<dp::ThreadSafeFactory> m_oglContextFactory;
|
||||
drape_ptr<dp::GraphicsContextFactory> m_vulkanContextFactory;
|
||||
bool m_isSurfaceDestroyed;
|
||||
std::map<gui::EWidget, gui::Position> m_guiPositions;
|
||||
};
|
||||
std::unordered_map<df::DrapeEngineId, DrapeEngineData> m_drapeEngines;
|
||||
::Framework m_work;
|
||||
|
||||
math::LowPassVector<float, 3> m_sensors[2];
|
||||
|
@ -59,10 +65,6 @@ namespace android
|
|||
|
||||
std::string m_searchQuery;
|
||||
|
||||
bool m_isSurfaceDestroyed;
|
||||
|
||||
std::map<gui::EWidget, gui::Position> m_guiPositions;
|
||||
|
||||
void TrafficStateChanged(TrafficManager::TrafficState state);
|
||||
void TransitSchemeStateChanged(TransitReadManager::TransitSchemeState state);
|
||||
void IsolinesSchemeStateChanged(IsolinesManager::IsolinesState state);
|
||||
|
@ -89,14 +91,15 @@ namespace android
|
|||
void OnLocationUpdated(location::GpsInfo const & info);
|
||||
void OnCompassUpdated(location::CompassInfo const & info, bool forceRedraw);
|
||||
|
||||
bool CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi, bool firstLaunch,
|
||||
bool launchByDeepLink, uint32_t appVersionCode);
|
||||
bool IsDrapeEngineCreated() const;
|
||||
bool DestroySurfaceOnDetach();
|
||||
void DetachSurface(bool destroySurface);
|
||||
bool AttachSurface(JNIEnv * env, jobject jSurface);
|
||||
void PauseSurfaceRendering();
|
||||
void ResumeSurfaceRendering();
|
||||
df::DrapeEngineId CreateDrapeEngineId();
|
||||
bool CreateDrapeEngine(JNIEnv * env, df::DrapeEngineId engineId, jobject jSurface, int densityDpi,
|
||||
bool firstLaunch, bool launchByDeepLink, uint32_t appVersionCode);
|
||||
bool IsDrapeEngineCreated(df::DrapeEngineId engineId) const;
|
||||
bool DestroySurfaceOnDetach(df::DrapeEngineId engineId);
|
||||
void DetachSurface(df::DrapeEngineId engineId, bool destroySurface);
|
||||
bool AttachSurface(JNIEnv * env, df::DrapeEngineId engineId, jobject jSurface);
|
||||
void PauseSurfaceRendering(df::DrapeEngineId engineId);
|
||||
void ResumeSurfaceRendering(df::DrapeEngineId engineId);
|
||||
|
||||
void SetMapStyle(MapStyle mapStyle);
|
||||
void MarkMapStyle(MapStyle mapStyle);
|
||||
|
@ -112,7 +115,7 @@ namespace android
|
|||
return m_work.GetRoutingManager().GetLastUsedRouter();
|
||||
}
|
||||
|
||||
void Resize(JNIEnv * env, jobject jSurface, int w, int h);
|
||||
void Resize(JNIEnv * env, df::DrapeEngineId engineId, jobject jSurface, int w, int h);
|
||||
|
||||
struct Finger
|
||||
{
|
||||
|
@ -127,11 +130,11 @@ namespace android
|
|||
float m_x, m_y;
|
||||
};
|
||||
|
||||
void Scale(double factor, m2::PointD const & pxPoint, bool isAnim);
|
||||
void Scale(df::DrapeEngineId engineId, double factor, m2::PointD const & pxPoint, bool isAnim);
|
||||
|
||||
void Move(double factorX, double factorY, bool isAnim);
|
||||
void Move(df::DrapeEngineId engineId, double factorX, double factorY, bool isAnim);
|
||||
|
||||
void Touch(int action, Finger const & f1, Finger const & f2, uint8_t maskedPointer);
|
||||
void Touch(df::DrapeEngineId engineId, int action, Finger const & f1, Finger const & f2, uint8_t maskedPointer);
|
||||
|
||||
bool Search(search::EverywhereSearchParams const & params);
|
||||
std::string GetLastSearchQuery() { return m_searchQuery; }
|
||||
|
@ -145,8 +148,8 @@ namespace android
|
|||
|
||||
void AddString(std::string const & name, std::string const & value);
|
||||
|
||||
void Scale(::Framework::EScaleMode mode);
|
||||
void Scale(m2::PointD const & centerPt, int targetZoom, bool animate);
|
||||
void Scale(df::DrapeEngineId engineId, ::Framework::EScaleMode mode);
|
||||
void Scale(df::DrapeEngineId engineId, m2::PointD const & centerPt, int targetZoom, bool animate);
|
||||
|
||||
void ReplaceBookmark(kml::MarkId markId, kml::BookmarkData & bm);
|
||||
void MoveBookmark(kml::MarkId markId, kml::MarkGroupId curCat, kml::MarkGroupId newCat);
|
||||
|
@ -180,9 +183,9 @@ namespace android
|
|||
void SetChoosePositionMode(bool isChoosePositionMode, bool isBusiness, bool hasPosition, m2::PointD const & position);
|
||||
bool GetChoosePositionMode();
|
||||
|
||||
void SetupWidget(gui::EWidget widget, float x, float y, dp::Anchor anchor);
|
||||
void ApplyWidgets();
|
||||
void CleanWidgets();
|
||||
void SetupWidget(df::DrapeEngineId engineId, gui::EWidget widget, float x, float y, dp::Anchor anchor);
|
||||
void ApplyWidgets(df::DrapeEngineId engineId);
|
||||
void CleanWidgets(df::DrapeEngineId engineId);
|
||||
|
||||
place_page::Info & GetPlacePageInfo();
|
||||
|
||||
|
|
|
@ -22,21 +22,27 @@ void OnRenderingInitializationFinished(std::shared_ptr<jobject> const & listener
|
|||
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_app_organicmaps_Map_nativeCreateEngineId(JNIEnv * env, jclass)
|
||||
{
|
||||
return g_framework->CreateDrapeEngineId();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_app_organicmaps_Map_nativeCreateEngine(JNIEnv * env, jclass,
|
||||
jobject surface, jint density,
|
||||
jboolean firstLaunch,
|
||||
jlong engineId, jobject surface,
|
||||
jint density, jboolean firstLaunch,
|
||||
jboolean isLaunchByDeepLink,
|
||||
jint appVersionCode)
|
||||
{
|
||||
return g_framework->CreateDrapeEngine(env, surface, density, firstLaunch, isLaunchByDeepLink,
|
||||
return g_framework->CreateDrapeEngine(env, engineId, surface, density, firstLaunch, isLaunchByDeepLink,
|
||||
base::asserted_cast<uint32_t>(appVersionCode));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_app_organicmaps_Map_nativeIsEngineCreated(JNIEnv *, jclass)
|
||||
Java_app_organicmaps_Map_nativeIsEngineCreated(JNIEnv *, jclass, jlong engineId)
|
||||
{
|
||||
return g_framework->IsDrapeEngineCreated();
|
||||
return g_framework->IsDrapeEngineCreated(static_cast<df::DrapeEngineId>(engineId));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
|
@ -47,72 +53,72 @@ Java_app_organicmaps_Map_nativeShowMapForUrl(JNIEnv * env, jclass, jstring url)
|
|||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeSetRenderingInitializationFinishedListener(
|
||||
JNIEnv *, jclass, jobject listener)
|
||||
JNIEnv *, jclass, jlong engineId, jobject listener)
|
||||
{
|
||||
if (listener)
|
||||
{
|
||||
g_framework->NativeFramework()->SetGraphicsContextInitializationHandler(
|
||||
g_framework->NativeFramework()->SetGraphicsContextInitializationHandler(engineId,
|
||||
std::bind(&OnRenderingInitializationFinished, jni::make_global_ref(listener)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_framework->NativeFramework()->SetGraphicsContextInitializationHandler(nullptr);
|
||||
g_framework->NativeFramework()->SetGraphicsContextInitializationHandler(engineId, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_app_organicmaps_Map_nativeAttachSurface(JNIEnv * env, jclass, jobject surface)
|
||||
Java_app_organicmaps_Map_nativeAttachSurface(JNIEnv * env, jclass, jlong engineId, jobject surface)
|
||||
{
|
||||
return g_framework->AttachSurface(env, surface);
|
||||
return g_framework->AttachSurface(env, engineId, surface);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeDetachSurface(JNIEnv *, jclass, jboolean destroySurface)
|
||||
Java_app_organicmaps_Map_nativeDetachSurface(JNIEnv *, jclass, jlong engineId, jboolean destroySurface)
|
||||
{
|
||||
g_framework->DetachSurface(destroySurface);
|
||||
g_framework->DetachSurface(engineId, destroySurface);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeSurfaceChanged(JNIEnv * env, jclass, jobject surface, jint w, jint h)
|
||||
Java_app_organicmaps_Map_nativeSurfaceChanged(JNIEnv * env, jclass, jlong engineId, jobject surface, jint w, jint h)
|
||||
{
|
||||
g_framework->Resize(env, surface, w, h);
|
||||
g_framework->Resize(env, engineId, surface, w, h);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_app_organicmaps_Map_nativeDestroySurfaceOnDetach(JNIEnv *, jclass)
|
||||
Java_app_organicmaps_Map_nativeDestroySurfaceOnDetach(JNIEnv *, jclass, jlong engineId)
|
||||
{
|
||||
return g_framework->DestroySurfaceOnDetach();
|
||||
return g_framework->DestroySurfaceOnDetach(engineId);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativePauseSurfaceRendering(JNIEnv *, jclass)
|
||||
Java_app_organicmaps_Map_nativePauseSurfaceRendering(JNIEnv *, jclass, jlong engineId)
|
||||
{
|
||||
g_framework->PauseSurfaceRendering();
|
||||
g_framework->PauseSurfaceRendering(engineId);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeResumeSurfaceRendering(JNIEnv *, jclass)
|
||||
Java_app_organicmaps_Map_nativeResumeSurfaceRendering(JNIEnv *, jclass, jlong engineId)
|
||||
{
|
||||
g_framework->ResumeSurfaceRendering();
|
||||
g_framework->ResumeSurfaceRendering(engineId);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeApplyWidgets(JNIEnv *, jclass)
|
||||
Java_app_organicmaps_Map_nativeApplyWidgets(JNIEnv *, jclass, jlong engineId)
|
||||
{
|
||||
g_framework->ApplyWidgets();
|
||||
g_framework->ApplyWidgets(engineId);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeCleanWidgets(JNIEnv *, jclass)
|
||||
Java_app_organicmaps_Map_nativeCleanWidgets(JNIEnv *, jclass, jlong engineId)
|
||||
{
|
||||
g_framework->CleanWidgets();
|
||||
g_framework->CleanWidgets(engineId);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeSetupWidget(
|
||||
JNIEnv *, jclass, jint widget, jfloat x, jfloat y, jint anchor)
|
||||
JNIEnv *, jclass, jlong engineId, jint widget, jfloat x, jfloat y, jint anchor)
|
||||
{
|
||||
g_framework->SetupWidget(static_cast<gui::EWidget>(widget), x, y, static_cast<dp::Anchor>(anchor));
|
||||
g_framework->SetupWidget(engineId, static_cast<gui::EWidget>(widget), x, y, static_cast<dp::Anchor>(anchor));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
@ -126,37 +132,37 @@ Java_app_organicmaps_Map_nativeCompassUpdated(JNIEnv *, jclass, jdouble north, j
|
|||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeMove(
|
||||
JNIEnv *, jclass, jdouble factorX, jdouble factorY, jboolean isAnim)
|
||||
JNIEnv *, jclass, jlong engineId, jdouble factorX, jdouble factorY, jboolean isAnim)
|
||||
{
|
||||
g_framework->Move(factorX, factorY, isAnim);
|
||||
g_framework->Move(engineId, factorX, factorY, isAnim);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeScalePlus(JNIEnv *, jclass)
|
||||
Java_app_organicmaps_Map_nativeScalePlus(JNIEnv *, jclass, jlong engineId)
|
||||
{
|
||||
g_framework->Scale(::Framework::SCALE_MAG);
|
||||
g_framework->Scale(engineId, ::Framework::SCALE_MAG);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeScaleMinus(JNIEnv *, jclass)
|
||||
Java_app_organicmaps_Map_nativeScaleMinus(JNIEnv *, jclass, jlong engineId)
|
||||
{
|
||||
g_framework->Scale(::Framework::SCALE_MIN);
|
||||
g_framework->Scale(engineId, ::Framework::SCALE_MIN);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeScale(
|
||||
JNIEnv *, jclass, jdouble factor, jdouble focusX, jdouble focusY, jboolean isAnim)
|
||||
JNIEnv *, jclass, jlong engineId, jdouble factor, jdouble focusX, jdouble focusY, jboolean isAnim)
|
||||
{
|
||||
g_framework->Scale(factor, {focusX, focusY}, isAnim);
|
||||
g_framework->Scale(static_cast<df::DrapeEngineId>(engineId), factor, {focusX, focusY}, isAnim);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_app_organicmaps_Map_nativeOnTouch(JNIEnv *, jclass, jint action,
|
||||
Java_app_organicmaps_Map_nativeOnTouch(JNIEnv *, jclass, jlong engineId, jint action,
|
||||
jint id1, jfloat x1, jfloat y1,
|
||||
jint id2, jfloat x2, jfloat y2,
|
||||
jint maskedPointer)
|
||||
{
|
||||
g_framework->Touch(action,
|
||||
g_framework->Touch(engineId, action,
|
||||
android::Framework::Finger(id1, x1, y1),
|
||||
android::Framework::Finger(id2, x2, y2), maskedPointer);
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ public final class Map
|
|||
public static final int INVALID_POINTER_MASK = 0xFF;
|
||||
public static final int INVALID_TOUCH_ID = -1;
|
||||
|
||||
private final long mEngineId;
|
||||
|
||||
private int mCurrentCompassOffsetX;
|
||||
private int mCurrentCompassOffsetY;
|
||||
private int mBottomWidgetOffsetX;
|
||||
|
@ -70,6 +72,8 @@ public final class Map
|
|||
|
||||
public Map()
|
||||
{
|
||||
mEngineId = nativeCreateEngineId();
|
||||
Logger.d(TAG, "Created engineId: " + mEngineId);
|
||||
onCreate(false);
|
||||
}
|
||||
|
||||
|
@ -88,9 +92,9 @@ public final class Map
|
|||
final int navPadding = UiUtils.dimen(context, R.dimen.nav_frame_padding);
|
||||
final int marginX = UiUtils.dimen(context, R.dimen.margin_compass) + navPadding;
|
||||
final int marginY = UiUtils.dimen(context, R.dimen.margin_compass_top) + navPadding;
|
||||
nativeSetupWidget(WIDGET_COMPASS, mWidth - x - marginX, y + marginY, ANCHOR_CENTER);
|
||||
nativeSetupWidget(mEngineId, WIDGET_COMPASS, mWidth - x - marginX, y + marginY, ANCHOR_CENTER);
|
||||
if (forceRedraw && mSurfaceCreated)
|
||||
nativeApplyWidgets();
|
||||
nativeApplyWidgets(mEngineId);
|
||||
mCurrentCompassOffsetX = x;
|
||||
mCurrentCompassOffsetY = y;
|
||||
}
|
||||
|
@ -119,8 +123,8 @@ public final class Map
|
|||
|
||||
public void onSurfaceCreated(final Context context, final Surface surface, Rect surfaceFrame, int surfaceDpi)
|
||||
{
|
||||
if (nativeIsEngineCreated())
|
||||
nativeDetachSurface(true);
|
||||
if (nativeIsEngineCreated(mEngineId))
|
||||
nativeDetachSurface(mEngineId, true);
|
||||
|
||||
if (isThemeChangingProcess(context))
|
||||
{
|
||||
|
@ -129,9 +133,9 @@ public final class Map
|
|||
}
|
||||
|
||||
Logger.d(TAG, "mSurfaceCreated = " + mSurfaceCreated);
|
||||
if (nativeIsEngineCreated())
|
||||
if (nativeIsEngineCreated(mEngineId))
|
||||
{
|
||||
if (!nativeAttachSurface(surface))
|
||||
if (!nativeAttachSurface(mEngineId, surface))
|
||||
{
|
||||
if (mCallbackUnsupported != null)
|
||||
mCallbackUnsupported.report();
|
||||
|
@ -140,7 +144,7 @@ public final class Map
|
|||
mSurfaceCreated = true;
|
||||
mSurfaceAttached = true;
|
||||
mRequireResize = true;
|
||||
nativeResumeSurfaceRendering();
|
||||
nativeResumeSurfaceRendering(mEngineId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -148,7 +152,7 @@ public final class Map
|
|||
setupWidgets(context, surfaceFrame.width(), surfaceFrame.height());
|
||||
|
||||
final boolean firstStart = LocationHelper.INSTANCE.isInFirstRun();
|
||||
if (!nativeCreateEngine(surface, surfaceDpi, firstStart, mLaunchByDeepLink, BuildConfig.VERSION_CODE))
|
||||
if (!nativeCreateEngine(mEngineId, surface, surfaceDpi, firstStart, mLaunchByDeepLink, BuildConfig.VERSION_CODE))
|
||||
{
|
||||
if (mCallbackUnsupported != null)
|
||||
mCallbackUnsupported.report();
|
||||
|
@ -160,7 +164,7 @@ public final class Map
|
|||
|
||||
mSurfaceCreated = true;
|
||||
mSurfaceAttached = true;
|
||||
nativeResumeSurfaceRendering();
|
||||
nativeResumeSurfaceRendering(mEngineId);
|
||||
if (mMapRenderingListener != null)
|
||||
mMapRenderingListener.onRenderingCreated();
|
||||
}
|
||||
|
@ -177,11 +181,11 @@ public final class Map
|
|||
if (!mSurfaceCreated || (!mRequireResize && isSurfaceCreating))
|
||||
return;
|
||||
|
||||
nativeSurfaceChanged(surface, surfaceFrame.width(), surfaceFrame.height());
|
||||
nativeSurfaceChanged(mEngineId, surface, surfaceFrame.width(), surfaceFrame.height());
|
||||
|
||||
mRequireResize = false;
|
||||
setupWidgets(context, surfaceFrame.width(), surfaceFrame.height());
|
||||
nativeApplyWidgets();
|
||||
nativeApplyWidgets(mEngineId);
|
||||
if (mMapRenderingListener != null)
|
||||
mMapRenderingListener.onRenderingRestored();
|
||||
}
|
||||
|
@ -192,8 +196,8 @@ public final class Map
|
|||
if (!mSurfaceCreated || !mSurfaceAttached || !isAdded)
|
||||
return;
|
||||
|
||||
nativeDetachSurface(!activityIsChangingConfigurations);
|
||||
mSurfaceCreated = !nativeDestroySurfaceOnDetach();
|
||||
nativeDetachSurface(mEngineId, !activityIsChangingConfigurations);
|
||||
mSurfaceCreated = !nativeDestroySurfaceOnDetach(mEngineId);
|
||||
mSurfaceAttached = false;
|
||||
}
|
||||
|
||||
|
@ -218,12 +222,12 @@ public final class Map
|
|||
|
||||
public void onStart()
|
||||
{
|
||||
nativeSetRenderingInitializationFinishedListener(mMapRenderingListener);
|
||||
nativeSetRenderingInitializationFinishedListener(mEngineId, mMapRenderingListener);
|
||||
}
|
||||
|
||||
public void onStop()
|
||||
{
|
||||
nativeSetRenderingInitializationFinishedListener(null);
|
||||
nativeSetRenderingInitializationFinishedListener(mEngineId, null);
|
||||
}
|
||||
|
||||
public void onPause(final Context context)
|
||||
|
@ -232,14 +236,14 @@ public final class Map
|
|||
|
||||
// Pause/Resume can be called without surface creation/destroy.
|
||||
if (mSurfaceAttached)
|
||||
nativePauseSurfaceRendering();
|
||||
nativePauseSurfaceRendering(mEngineId);
|
||||
}
|
||||
|
||||
public void onResume()
|
||||
{
|
||||
// Pause/Resume can be called without surface creation/destroy.
|
||||
if (mSurfaceAttached)
|
||||
nativeResumeSurfaceRendering();
|
||||
nativeResumeSurfaceRendering(mEngineId);
|
||||
}
|
||||
|
||||
boolean isContextCreated()
|
||||
|
@ -249,46 +253,46 @@ public final class Map
|
|||
|
||||
public void onScroll(float distanceX, float distanceY)
|
||||
{
|
||||
Map.nativeMove(-distanceX / ((float) mWidth), distanceY / ((float) mHeight), false);
|
||||
nativeMove(mEngineId, -distanceX / ((float) mWidth), distanceY / ((float) mHeight), false);
|
||||
}
|
||||
|
||||
public static void zoomIn()
|
||||
public void zoomIn()
|
||||
{
|
||||
nativeScalePlus();
|
||||
nativeScalePlus(mEngineId);
|
||||
}
|
||||
|
||||
public static void zoomOut()
|
||||
public void zoomOut()
|
||||
{
|
||||
nativeScaleMinus();
|
||||
nativeScaleMinus(mEngineId);
|
||||
}
|
||||
|
||||
public static void onScale(double factor, double focusX, double focusY, boolean isAnim)
|
||||
public void onScale(double factor, double focusX, double focusY, boolean isAnim)
|
||||
{
|
||||
nativeScale(factor, focusX, focusY, isAnim);
|
||||
nativeScale(mEngineId, factor, focusX, focusY, isAnim);
|
||||
}
|
||||
|
||||
public static void onTouch(int actionType, MotionEvent event, int pointerIndex)
|
||||
public void onTouch(int actionType, MotionEvent event, int pointerIndex)
|
||||
{
|
||||
if (event.getPointerCount() == 1)
|
||||
{
|
||||
nativeOnTouch(actionType, event.getPointerId(0), event.getX(), event.getY(), Map.INVALID_TOUCH_ID, 0, 0, 0);
|
||||
nativeOnTouch(mEngineId, actionType, event.getPointerId(0), event.getX(), event.getY(), Map.INVALID_TOUCH_ID, 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
nativeOnTouch(actionType,
|
||||
nativeOnTouch(mEngineId, actionType,
|
||||
event.getPointerId(0), event.getX(0), event.getY(0),
|
||||
event.getPointerId(1), event.getX(1), event.getY(1), pointerIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onTouch(float x, float y)
|
||||
public void onTouch(float x, float y)
|
||||
{
|
||||
nativeOnTouch(Map.NATIVE_ACTION_UP, 0, x, y, Map.INVALID_TOUCH_ID, 0, 0, 0);
|
||||
nativeOnTouch(mEngineId, Map.NATIVE_ACTION_UP, 0, x, y, Map.INVALID_TOUCH_ID, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static boolean isEngineCreated()
|
||||
{
|
||||
return nativeIsEngineCreated();
|
||||
return nativeIsEngineCreated(0);
|
||||
}
|
||||
|
||||
public static boolean showMapForUrl(String url)
|
||||
|
@ -301,30 +305,30 @@ public final class Map
|
|||
mHeight = height;
|
||||
mWidth = width;
|
||||
|
||||
nativeCleanWidgets();
|
||||
nativeCleanWidgets(mEngineId);
|
||||
setupBottomWidgetsOffset(context, mBottomWidgetOffsetX, mBottomWidgetOffsetY);
|
||||
nativeSetupWidget(WIDGET_SCALE_FPS_LABEL, UiUtils.dimen(context, R.dimen.margin_base), UiUtils.dimen(context, R.dimen.margin_base), ANCHOR_LEFT_TOP);
|
||||
nativeSetupWidget(mEngineId, WIDGET_SCALE_FPS_LABEL, UiUtils.dimen(context, R.dimen.margin_base), UiUtils.dimen(context, R.dimen.margin_base), ANCHOR_LEFT_TOP);
|
||||
setupCompass(context, mCurrentCompassOffsetX, mCurrentCompassOffsetY, false);
|
||||
}
|
||||
|
||||
private void setupRuler(final Context context, int offsetX, int offsetY)
|
||||
{
|
||||
nativeSetupWidget(WIDGET_RULER,
|
||||
nativeSetupWidget(mEngineId, WIDGET_RULER,
|
||||
UiUtils.dimen(context, R.dimen.margin_ruler) + offsetX,
|
||||
mHeight - UiUtils.dimen(context, R.dimen.margin_ruler) - offsetY,
|
||||
ANCHOR_LEFT_BOTTOM);
|
||||
if (mSurfaceCreated)
|
||||
nativeApplyWidgets();
|
||||
nativeApplyWidgets(mEngineId);
|
||||
}
|
||||
|
||||
private void setupAttribution(final Context context, int offsetX, int offsetY)
|
||||
{
|
||||
nativeSetupWidget(WIDGET_COPYRIGHT,
|
||||
nativeSetupWidget(mEngineId, WIDGET_COPYRIGHT,
|
||||
UiUtils.dimen(context, R.dimen.margin_ruler) + offsetX,
|
||||
mHeight - UiUtils.dimen(context, R.dimen.margin_ruler) - offsetY,
|
||||
ANCHOR_LEFT_BOTTOM);
|
||||
if (mSurfaceCreated)
|
||||
nativeApplyWidgets();
|
||||
nativeApplyWidgets(mEngineId);
|
||||
}
|
||||
|
||||
private boolean isThemeChangingProcess(final Context context)
|
||||
|
@ -333,33 +337,34 @@ public final class Map
|
|||
}
|
||||
|
||||
// Engine
|
||||
private static native boolean nativeCreateEngine(Surface surface, int density,
|
||||
boolean firstLaunch,
|
||||
private static native long nativeCreateEngineId();
|
||||
private static native boolean nativeCreateEngine(long engineId, Surface surface,
|
||||
int density, boolean firstLaunch,
|
||||
boolean isLaunchByDeepLink,
|
||||
int appVersionCode);
|
||||
private static native boolean nativeIsEngineCreated();
|
||||
private static native boolean nativeIsEngineCreated(long engineId);
|
||||
private static native void nativeSetRenderingInitializationFinishedListener(
|
||||
@Nullable MapRenderingListener listener);
|
||||
long engineId, @Nullable MapRenderingListener listener);
|
||||
private static native boolean nativeShowMapForUrl(String url);
|
||||
|
||||
// Surface
|
||||
private static native boolean nativeAttachSurface(Surface surface);
|
||||
private static native void nativeDetachSurface(boolean destroySurface);
|
||||
private static native void nativeSurfaceChanged(Surface surface, int w, int h);
|
||||
private static native boolean nativeDestroySurfaceOnDetach();
|
||||
private static native void nativePauseSurfaceRendering();
|
||||
private static native void nativeResumeSurfaceRendering();
|
||||
private static native boolean nativeAttachSurface(long engineId, Surface surface);
|
||||
private static native void nativeDetachSurface(long engineId, boolean destroySurface);
|
||||
private static native void nativeSurfaceChanged(long engineId, Surface surface, int w, int h);
|
||||
private static native boolean nativeDestroySurfaceOnDetach(long engineId);
|
||||
private static native void nativePauseSurfaceRendering(long engineId);
|
||||
private static native void nativeResumeSurfaceRendering(long engineId);
|
||||
|
||||
// Widgets
|
||||
private static native void nativeApplyWidgets();
|
||||
private static native void nativeCleanWidgets();
|
||||
private static native void nativeSetupWidget(int widget, float x, float y, int anchor);
|
||||
private static native void nativeApplyWidgets(long engineId);
|
||||
private static native void nativeCleanWidgets(long engineId);
|
||||
private static native void nativeSetupWidget(long engineId, int widget, float x, float y, int anchor);
|
||||
private static native void nativeCompassUpdated(double north, boolean forceRedraw);
|
||||
|
||||
// Events
|
||||
private static native void nativeMove(double factorX, double factorY, boolean isAnim);
|
||||
private static native void nativeScalePlus();
|
||||
private static native void nativeScaleMinus();
|
||||
private static native void nativeScale(double factor, double focusX, double focusY, boolean isAnim);
|
||||
private static native void nativeOnTouch(int actionType, int id1, float x1, float y1, int id2, float x2, float y2, int maskedPointer);
|
||||
private static native void nativeMove(long engineId, double factorX, double factorY, boolean isAnim);
|
||||
private static native void nativeScalePlus(long engineId);
|
||||
private static native void nativeScaleMinus(long engineId);
|
||||
private static native void nativeScale(long engineId, double factor, double focusX, double focusY, boolean isAnim);
|
||||
private static native void nativeOnTouch(long engineId, int actionType, int id1, float x1, float y1, int id2, float x2, float y2, int maskedPointer);
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ public class MapFragment extends BaseMwmFragment implements View.OnTouchListener
|
|||
action = Map.NATIVE_ACTION_CANCEL;
|
||||
break;
|
||||
}
|
||||
Map.onTouch(action, event, pointerIndex);
|
||||
mMap.onTouch(action, event, pointerIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -642,10 +642,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
switch (button)
|
||||
{
|
||||
case zoomIn:
|
||||
Map.zoomIn();
|
||||
// TODO: fix
|
||||
// Map.zoomIn();
|
||||
break;
|
||||
case zoomOut:
|
||||
Map.zoomOut();
|
||||
// TODO: fix
|
||||
// Map.zoomOut();
|
||||
break;
|
||||
case myPosition:
|
||||
LocationState.nativeSwitchToNextMode();
|
||||
|
@ -1715,10 +1717,12 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
switch (keyCode)
|
||||
{
|
||||
case KeyEvent.KEYCODE_DPAD_DOWN:
|
||||
Map.zoomOut();
|
||||
// TODO: fix
|
||||
// Map.zoomOut();
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_DPAD_UP:
|
||||
Map.zoomIn();
|
||||
// TODO: fix
|
||||
// Map.zoomIn();
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_ESCAPE:
|
||||
Intent currIntent = getIntent();
|
||||
|
|
|
@ -126,12 +126,12 @@ public class SurfaceRenderer implements DefaultLifecycleObserver, SurfaceCallbac
|
|||
|
||||
public void onZoomIn()
|
||||
{
|
||||
Map.zoomIn();
|
||||
mMap.zoomIn();
|
||||
}
|
||||
|
||||
public void onZoomOut()
|
||||
{
|
||||
Map.zoomOut();
|
||||
mMap.zoomOut();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,14 +153,14 @@ public class SurfaceRenderer implements DefaultLifecycleObserver, SurfaceCallbac
|
|||
|
||||
final boolean animated = Float.compare(scaleFactor, 2f) == 0;
|
||||
|
||||
Map.onScale(scaleFactor, x, y, animated);
|
||||
mMap.onScale(scaleFactor, x, y, animated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(float x, float y)
|
||||
{
|
||||
Log.d(TAG, "onClick: x: " + x + ", y: " + y);
|
||||
Map.onTouch(x, y);
|
||||
mMap.onTouch(x, y);
|
||||
}
|
||||
|
||||
private void reportUnsupported()
|
||||
|
|
|
@ -188,8 +188,8 @@ void StipplePenIndex::UploadResources(ref_ptr<dp::GraphicsContext> context, ref_
|
|||
|
||||
// Assume that all patterns are initialized when creating texture (ReserveResource) and uploaded once.
|
||||
// Should provide additional logic like in ColorPalette::UploadResources, if we want multiple uploads.
|
||||
if (m_uploadCalled)
|
||||
LOG(LERROR, ("Multiple stipple pen texture uploads are not supported"));
|
||||
// if (m_uploadCalled)
|
||||
// LOG(LERROR, ("Multiple stipple pen texture uploads are not supported"));
|
||||
m_uploadCalled = true;
|
||||
|
||||
uint32_t height = 0;
|
||||
|
|
|
@ -46,6 +46,8 @@ namespace df
|
|||
class UserMarksProvider;
|
||||
class MapDataProvider;
|
||||
|
||||
using DrapeEngineId = std::size_t;
|
||||
|
||||
class DrapeEngine
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -57,7 +57,8 @@ void RunScenario(Framework * framework, std::shared_ptr<BenchmarkHandle> handle)
|
|||
|
||||
auto & scenarioData = handle->m_scenariosToRun[handle->m_currentScenario];
|
||||
|
||||
framework->GetDrapeEngine()->RunScenario(std::move(scenarioData),
|
||||
// TODO: fix
|
||||
framework->GetDrapeEngine(0)->RunScenario(std::move(scenarioData),
|
||||
[handle](std::string const & name)
|
||||
{
|
||||
#ifdef DRAPE_MEASURER_BENCHMARK
|
||||
|
|
|
@ -153,8 +153,11 @@ pair<MwmSet::MwmId, MwmSet::RegResult> Framework::RegisterMap(LocalCountryFile c
|
|||
void Framework::OnLocationError(TLocationError /*error*/)
|
||||
{
|
||||
m_trafficManager.UpdateMyPosition(TrafficManager::MyPosition());
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->LoseLocation();
|
||||
for (const auto& [_, drapeEngineData] : m_drapeEngines)
|
||||
{
|
||||
if (drapeEngineData.m_drapeEngine)
|
||||
drapeEngineData.m_drapeEngine->LoseLocation();
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::OnLocationUpdate(GpsInfo const & info)
|
||||
|
@ -193,14 +196,18 @@ void Framework::OnCompassUpdate(CompassInfo const & info)
|
|||
CompassInfo const & rInfo = info;
|
||||
#endif
|
||||
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->SetCompassInfo(rInfo);
|
||||
for (const auto& [_, drapeEngineData] : m_drapeEngines)
|
||||
{
|
||||
if (drapeEngineData.m_drapeEngine)
|
||||
drapeEngineData.m_drapeEngine->SetCompassInfo(rInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::SwitchMyPositionNextMode()
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->SwitchMyPositionNextMode();
|
||||
for (const auto& [engineId, drapeEngineData] : m_drapeEngines)
|
||||
if (drapeEngineData.m_drapeEngine)
|
||||
drapeEngineData.m_drapeEngine->SwitchMyPositionNextMode();
|
||||
}
|
||||
|
||||
void Framework::SetMyPositionModeListener(TMyPositionModeChanged && fn)
|
||||
|
@ -215,7 +222,10 @@ void Framework::SetMyPositionPendingTimeoutListener(df::DrapeEngine::UserPositio
|
|||
|
||||
EMyPositionMode Framework::GetMyPositionMode() const
|
||||
{
|
||||
return m_drapeEngine ? m_drapeEngine->GetMyPositionMode() : PendingPosition;
|
||||
for (const auto& [engineId, drapeEngineData] : m_drapeEngines)
|
||||
if (drapeEngineData.m_drapeEngine)
|
||||
return drapeEngineData.m_drapeEngine->GetMyPositionMode();
|
||||
return PendingPosition;
|
||||
}
|
||||
|
||||
TrafficManager & Framework::GetTrafficManager()
|
||||
|
@ -804,11 +814,11 @@ void Framework::ShowBookmark(Bookmark const * mark)
|
|||
auto es = GetBookmarkManager().GetEditSession();
|
||||
es.SetIsVisible(mark->GetGroupId(), true /* visible */);
|
||||
|
||||
if (m_drapeEngine != nullptr)
|
||||
{
|
||||
m_drapeEngine->SetModelViewCenter(mark->GetPivot(), scale, true /* isAnim */,
|
||||
true /* trackVisibleViewport */);
|
||||
}
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// {
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetModelViewCenter(mark->GetPivot(), scale, true /* isAnim */,
|
||||
// true /* trackVisibleViewport */);
|
||||
// }
|
||||
|
||||
ActivateMapSelection();
|
||||
}
|
||||
|
@ -867,13 +877,13 @@ void Framework::ShowFeature(FeatureID const & featureId)
|
|||
info.m_match = place_page::BuildInfo::Match::FeatureOnly;
|
||||
m_currentPlacePageInfo = BuildPlacePageInfo(info);
|
||||
|
||||
if (m_drapeEngine != nullptr)
|
||||
{
|
||||
auto const pt = m_currentPlacePageInfo->GetMercator();
|
||||
auto const scale = scales::GetUpperComfortScale();
|
||||
m_drapeEngine->SetModelViewCenter(pt, scale, true /* isAnim */, true /* trackVisibleViewport */);
|
||||
}
|
||||
ActivateMapSelection();
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// {
|
||||
// auto const pt = m_currentPlacePageInfo->GetMercator();
|
||||
// auto const scale = scales::GetUpperComfortScale();
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetModelViewCenter(pt, scale, true /* isAnim */, true /* trackVisibleViewport */);
|
||||
// }
|
||||
// ActivateMapSelection();
|
||||
}
|
||||
|
||||
void Framework::AddBookmarksFile(string const & filePath, bool isTemporaryFile)
|
||||
|
@ -907,8 +917,8 @@ void Framework::LoadViewport()
|
|||
m2::AnyRectD rect;
|
||||
if (settings::Get("ScreenClipRect", rect) && df::GetWorldRect().IsRectInside(rect.GetGlobalRect()))
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->SetModelViewAnyRect(rect, false /* isAnim */, false /* useVisibleViewport */);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetModelViewAnyRect(rect, false /* isAnim */, false /* useVisibleViewport */);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -918,10 +928,10 @@ void Framework::LoadViewport()
|
|||
|
||||
void Framework::ShowAll()
|
||||
{
|
||||
if (m_drapeEngine == nullptr)
|
||||
return;
|
||||
m_drapeEngine->SetModelViewAnyRect(m2::AnyRectD(m_featuresFetcher.GetWorldRect()), false /* isAnim */,
|
||||
false /* useVisibleViewport */);
|
||||
// if (!m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// return;
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetModelViewAnyRect(m2::AnyRectD(m_featuresFetcher.GetWorldRect()), false /* isAnim */,
|
||||
// false /* useVisibleViewport */);
|
||||
}
|
||||
|
||||
m2::PointD Framework::GetVisiblePixelCenter() const
|
||||
|
@ -937,8 +947,8 @@ m2::PointD const & Framework::GetViewportCenter() const
|
|||
void Framework::SetViewportCenter(m2::PointD const & pt, int zoomLevel /* = -1 */,
|
||||
bool isAnim /* = true */)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->SetModelViewCenter(pt, zoomLevel, isAnim, false /* trackVisibleViewport */);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetModelViewCenter(pt, zoomLevel, isAnim, false /* trackVisibleViewport */);
|
||||
}
|
||||
|
||||
m2::RectD Framework::GetCurrentViewport() const
|
||||
|
@ -946,9 +956,9 @@ m2::RectD Framework::GetCurrentViewport() const
|
|||
return m_currentModelView.ClipRect();
|
||||
}
|
||||
|
||||
void Framework::SetVisibleViewport(m2::RectD const & rect)
|
||||
void Framework::SetVisibleViewport(df::DrapeEngineId engineId, m2::RectD const & rect)
|
||||
{
|
||||
if (m_drapeEngine == nullptr)
|
||||
if (!m_drapeEngines[engineId].m_drapeEngine)
|
||||
return;
|
||||
|
||||
double constexpr kEps = 0.5;
|
||||
|
@ -960,22 +970,22 @@ void Framework::SetVisibleViewport(m2::RectD const & rect)
|
|||
return;
|
||||
|
||||
m_visibleViewport = rect;
|
||||
m_drapeEngine->SetVisibleViewport(rect);
|
||||
m_drapeEngines[engineId].m_drapeEngine->SetVisibleViewport(rect);
|
||||
}
|
||||
|
||||
void Framework::ShowRect(m2::RectD const & rect, int maxScale, bool animation, bool useVisibleViewport)
|
||||
{
|
||||
if (m_drapeEngine == nullptr)
|
||||
return;
|
||||
|
||||
m_drapeEngine->SetModelViewRect(rect, true /* applyRotation */, maxScale /* zoom */, animation,
|
||||
useVisibleViewport);
|
||||
// if (!m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// return;
|
||||
//
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetModelViewRect(rect, true /* applyRotation */, maxScale /* zoom */, animation,
|
||||
// useVisibleViewport);
|
||||
}
|
||||
|
||||
void Framework::ShowRect(m2::AnyRectD const & rect, bool animation, bool useVisibleViewport)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->SetModelViewAnyRect(rect, animation, useVisibleViewport);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetModelViewAnyRect(rect, animation, useVisibleViewport);
|
||||
}
|
||||
|
||||
void Framework::GetTouchRect(m2::PointD const & center, uint32_t pxRadius, m2::AnyRectD & rect)
|
||||
|
@ -991,26 +1001,26 @@ void Framework::SetViewportListener(TViewportChangedFn const & fn)
|
|||
#if defined(OMIM_OS_MAC) || defined(OMIM_OS_LINUX)
|
||||
void Framework::NotifyGraphicsReady(TGraphicsReadyFn const & fn, bool needInvalidate)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->NotifyGraphicsReady(fn, needInvalidate);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->NotifyGraphicsReady(fn, needInvalidate);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Framework::StopLocationFollow()
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->StopLocationFollow();
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->StopLocationFollow();
|
||||
}
|
||||
|
||||
void Framework::OnSize(int w, int h)
|
||||
void Framework::OnSize(df::DrapeEngineId engineId, int w, int h)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->Resize(std::max(w, 2), std::max(h, 2));
|
||||
if (m_drapeEngines[engineId].m_drapeEngine != nullptr)
|
||||
m_drapeEngines[engineId].m_drapeEngine->Resize(std::max(w, 2), std::max(h, 2));
|
||||
|
||||
/// @todo Expected that DrapeEngine::Resize does all the work, but nope ..
|
||||
/// - Strange, but seems like iOS works fine without it.
|
||||
/// - Test Android screen orientation and position mark in map and navigation modes.
|
||||
SetVisibleViewport(m2::RectD(0, 0, w, h));
|
||||
SetVisibleViewport(engineId,m2::RectD(0, 0, w, h));
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -1024,57 +1034,57 @@ double ScaleModeToFactor(Framework::EScaleMode mode)
|
|||
|
||||
} // namespace
|
||||
|
||||
void Framework::Scale(EScaleMode mode, bool isAnim)
|
||||
void Framework::Scale(df::DrapeEngineId engineId, EScaleMode mode, bool isAnim)
|
||||
{
|
||||
Scale(ScaleModeToFactor(mode), isAnim);
|
||||
Scale(engineId, ScaleModeToFactor(mode), isAnim);
|
||||
}
|
||||
|
||||
void Framework::Scale(Framework::EScaleMode mode, m2::PointD const & pxPoint, bool isAnim)
|
||||
void Framework::Scale(df::DrapeEngineId engineId, Framework::EScaleMode mode, m2::PointD const & pxPoint, bool isAnim)
|
||||
{
|
||||
Scale(ScaleModeToFactor(mode), pxPoint, isAnim);
|
||||
Scale(engineId, ScaleModeToFactor(mode), pxPoint, isAnim);
|
||||
}
|
||||
|
||||
void Framework::Scale(double factor, bool isAnim)
|
||||
void Framework::Scale(df::DrapeEngineId engineId, double factor, bool isAnim)
|
||||
{
|
||||
Scale(factor, GetVisiblePixelCenter(), isAnim);
|
||||
Scale(engineId, factor, GetVisiblePixelCenter(), isAnim);
|
||||
}
|
||||
|
||||
void Framework::Scale(double factor, m2::PointD const & pxPoint, bool isAnim)
|
||||
void Framework::Scale(df::DrapeEngineId engineId, double factor, m2::PointD const & pxPoint, bool isAnim)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->Scale(factor, pxPoint, isAnim);
|
||||
if (m_drapeEngines[engineId].m_drapeEngine != nullptr)
|
||||
m_drapeEngines[engineId].m_drapeEngine->Scale(factor, pxPoint, isAnim);
|
||||
}
|
||||
|
||||
void Framework::Move(double factorX, double factorY, bool isAnim)
|
||||
void Framework::Move(df::DrapeEngineId engineId, double factorX, double factorY, bool isAnim)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->Move(factorX, factorY, isAnim);
|
||||
if (m_drapeEngines[engineId].m_drapeEngine != nullptr)
|
||||
m_drapeEngines[engineId].m_drapeEngine->Move(factorX, factorY, isAnim);
|
||||
}
|
||||
|
||||
void Framework::Rotate(double azimuth, bool isAnim)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->Rotate(azimuth, isAnim);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->Rotate(azimuth, isAnim);
|
||||
}
|
||||
|
||||
void Framework::TouchEvent(df::TouchEvent const & touch)
|
||||
void Framework::TouchEvent(df::DrapeEngineId engineId, df::TouchEvent const & touch)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->AddTouchEvent(touch);
|
||||
if (m_drapeEngines[engineId].m_drapeEngine != nullptr)
|
||||
m_drapeEngines[engineId].m_drapeEngine->AddTouchEvent(touch);
|
||||
}
|
||||
|
||||
int Framework::GetDrawScale() const
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
return df::GetDrawTileScale(m_currentModelView);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// return df::GetDrawTileScale(m_currentModelView);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Framework::RunFirstLaunchAnimation()
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->RunFirstLaunchAnimation();
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->RunFirstLaunchAnimation();
|
||||
}
|
||||
|
||||
bool Framework::IsCountryLoadedByName(string_view name) const
|
||||
|
@ -1084,8 +1094,8 @@ bool Framework::IsCountryLoadedByName(string_view name) const
|
|||
|
||||
void Framework::InvalidateRect(m2::RectD const & rect)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->InvalidateRect(rect);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->InvalidateRect(rect);
|
||||
}
|
||||
|
||||
void Framework::ClearAllCaches()
|
||||
|
@ -1128,8 +1138,9 @@ void Framework::MemoryWarning()
|
|||
|
||||
void Framework::EnterBackground()
|
||||
{
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->OnEnterBackground();
|
||||
for (const auto& [engineId, drapeEngineData] : m_drapeEngines)
|
||||
if (drapeEngineData.m_drapeEngine)
|
||||
drapeEngineData.m_drapeEngine->OnEnterBackground();
|
||||
|
||||
SaveViewport();
|
||||
|
||||
|
@ -1145,8 +1156,9 @@ void Framework::EnterBackground()
|
|||
|
||||
void Framework::EnterForeground()
|
||||
{
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->OnEnterForeground();
|
||||
for (const auto& [engineId, drapeEngineData] : m_drapeEngines)
|
||||
if (drapeEngineData.m_drapeEngine)
|
||||
drapeEngineData.m_drapeEngine->OnEnterForeground();
|
||||
|
||||
m_trafficManager.OnEnterForeground();
|
||||
}
|
||||
|
@ -1275,12 +1287,12 @@ void Framework::SelectSearchResult(search::Result const & result, bool animation
|
|||
m_currentPlacePageInfo = BuildPlacePageInfo(info);
|
||||
if (m_currentPlacePageInfo)
|
||||
{
|
||||
if (m_drapeEngine) {
|
||||
if (scale < 0)
|
||||
scale = GetFeatureViewportScale(m_currentPlacePageInfo->GetTypes());
|
||||
m2::PointD const center = m_currentPlacePageInfo->GetMercator();
|
||||
m_drapeEngine->SetModelViewCenter(center, scale, animation, true /* trackVisibleViewport */);
|
||||
}
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine) {
|
||||
// if (scale < 0)
|
||||
// scale = GetFeatureViewportScale(m_currentPlacePageInfo->GetTypes());
|
||||
// m2::PointD const center = m_currentPlacePageInfo->GetMercator();
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetModelViewCenter(center, scale, animation, true /* trackVisibleViewport */);
|
||||
// }
|
||||
|
||||
ActivateMapSelection();
|
||||
}
|
||||
|
@ -1422,7 +1434,14 @@ bool Framework::GetDistanceAndAzimut(m2::PointD const & point,
|
|||
return (d < 25000.0);
|
||||
}
|
||||
|
||||
void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFactory, DrapeCreationParams && params)
|
||||
df::DrapeEngineId Framework::CreateDrapeEngineId()
|
||||
{
|
||||
df::DrapeEngineId engineId = static_cast<df::DrapeEngineId>(random());
|
||||
m_drapeEngines[engineId];
|
||||
return engineId;
|
||||
}
|
||||
|
||||
void Framework::CreateDrapeEngine(df::DrapeEngineId engineId, ref_ptr<dp::GraphicsContextFactory> contextFactory, DrapeCreationParams && params)
|
||||
{
|
||||
auto idReadFn = [this](df::MapDataProvider::TReadCallback<FeatureID const> const & fn,
|
||||
m2::RectD const & r,
|
||||
|
@ -1451,12 +1470,12 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFac
|
|||
{
|
||||
};
|
||||
|
||||
auto onGraphicsContextInitialized = [this]()
|
||||
auto onGraphicsContextInitialized = [this, engineId]()
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this]()
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, engineId]()
|
||||
{
|
||||
if (m_onGraphicsContextInitialized)
|
||||
m_onGraphicsContextInitialized();
|
||||
if (m_drapeEngines[engineId].m_onGraphicsContextInitialized)
|
||||
m_drapeEngines[engineId].m_onGraphicsContextInitialized();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1488,26 +1507,27 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFac
|
|||
isAutozoomEnabled, simplifiedTrafficColors, std::move(overlaysShowStatsFn),
|
||||
std::move(onGraphicsContextInitialized));
|
||||
|
||||
m_drapeEngine = make_unique_dp<df::DrapeEngine>(std::move(p));
|
||||
m_drapeEngine->SetModelViewListener([this](ScreenBase const & screen)
|
||||
DrapeEngineData &drapeEngineData = m_drapeEngines[engineId];
|
||||
drapeEngineData.m_drapeEngine = make_unique_dp<df::DrapeEngine>(std::move(p));
|
||||
drapeEngineData.m_drapeEngine->SetModelViewListener([this](ScreenBase const & screen)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, screen](){ OnViewportChanged(screen); });
|
||||
});
|
||||
m_drapeEngine->SetTapEventInfoListener([this](df::TapInfo const & tapInfo)
|
||||
drapeEngineData.m_drapeEngine->SetTapEventInfoListener([this](df::TapInfo const & tapInfo)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, tapInfo]()
|
||||
{
|
||||
OnTapEvent(place_page::BuildInfo(tapInfo));
|
||||
});
|
||||
});
|
||||
m_drapeEngine->SetUserPositionListener([this](m2::PointD const & position, bool hasPosition)
|
||||
drapeEngineData.m_drapeEngine->SetUserPositionListener([this](m2::PointD const & position, bool hasPosition)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, position, hasPosition]()
|
||||
{
|
||||
OnUserPositionChanged(position, hasPosition);
|
||||
});
|
||||
});
|
||||
m_drapeEngine->SetUserPositionPendingTimeoutListener([this]()
|
||||
drapeEngineData.m_drapeEngine->SetUserPositionPendingTimeoutListener([this]()
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this]()
|
||||
{
|
||||
|
@ -1516,7 +1536,7 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFac
|
|||
});
|
||||
});
|
||||
|
||||
OnSize(params.m_surfaceWidth, params.m_surfaceHeight);
|
||||
OnSize(engineId, params.m_surfaceWidth, params.m_surfaceHeight);
|
||||
|
||||
Allow3dMode(allow3d, allow3dBuildings);
|
||||
|
||||
|
@ -1525,15 +1545,15 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFac
|
|||
if (m_connectToGpsTrack)
|
||||
GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2));
|
||||
|
||||
GetBookmarkManager().SetDrapeEngine(make_ref(m_drapeEngine));
|
||||
m_drapeApi.SetDrapeEngine(make_ref(m_drapeEngine));
|
||||
m_routingManager.SetDrapeEngine(make_ref(m_drapeEngine), allow3d);
|
||||
m_trafficManager.SetDrapeEngine(make_ref(m_drapeEngine));
|
||||
m_transitManager.SetDrapeEngine(make_ref(m_drapeEngine));
|
||||
m_isolinesManager.SetDrapeEngine(make_ref(m_drapeEngine));
|
||||
m_searchMarks.SetDrapeEngine(make_ref(m_drapeEngine));
|
||||
// GetBookmarkManager().SetDrapeEngine(make_ref(drapeEngineData.m_drapeEngine));
|
||||
drapeEngineData.m_drapeApi.SetDrapeEngine(make_ref(drapeEngineData.m_drapeEngine));
|
||||
// m_routingManager.SetDrapeEngine(make_ref(drapeEngineData.m_drapeEngine), allow3d);
|
||||
// m_trafficManager.SetDrapeEngine(make_ref(drapeEngineData.m_drapeEngine));
|
||||
// m_transitManager.SetDrapeEngine(make_ref(drapeEngineData.m_drapeEngine));
|
||||
// m_isolinesManager.SetDrapeEngine(make_ref(drapeEngineData.m_drapeEngine));
|
||||
// m_searchMarks.SetDrapeEngine(make_ref(drapeEngineData.m_drapeEngine));
|
||||
|
||||
InvalidateUserMarks();
|
||||
// InvalidateUserMarks();
|
||||
|
||||
auto const transitSchemeEnabled = LoadTransitSchemeEnabled();
|
||||
m_transitManager.EnableTransitSchemeMode(transitSchemeEnabled);
|
||||
|
@ -1543,20 +1563,21 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFac
|
|||
if (!settings::Get(kShowDebugInfo, showDebugInfo))
|
||||
showDebugInfo = false;
|
||||
if (showDebugInfo)
|
||||
m_drapeEngine->ShowDebugInfo(showDebugInfo);
|
||||
drapeEngineData.m_drapeEngine->ShowDebugInfo(showDebugInfo);
|
||||
|
||||
benchmark::RunGraphicsBenchmark(this);
|
||||
}
|
||||
|
||||
void Framework::OnRecoverSurface(int width, int height, bool recreateContextDependentResources)
|
||||
void Framework::OnRecoverSurface(df::DrapeEngineId engineId, int width, int height, bool recreateContextDependentResources)
|
||||
{
|
||||
if (m_drapeEngine)
|
||||
DrapeEngineData &drapeEngineData = m_drapeEngines[engineId];
|
||||
if (drapeEngineData.m_drapeEngine)
|
||||
{
|
||||
m_drapeEngine->RecoverSurface(width, height, recreateContextDependentResources);
|
||||
drapeEngineData.m_drapeEngine->RecoverSurface(width, height, recreateContextDependentResources);
|
||||
|
||||
InvalidateUserMarks();
|
||||
|
||||
m_drapeApi.Invalidate();
|
||||
drapeEngineData.m_drapeApi.Invalidate();
|
||||
}
|
||||
|
||||
m_trafficManager.OnRecoverSurface();
|
||||
|
@ -1571,86 +1592,88 @@ void Framework::OnDestroySurface()
|
|||
|
||||
void Framework::UpdateVisualScale(double vs)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->UpdateVisualScale(vs, m_isRenderingEnabled);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->UpdateVisualScale(vs, m_isRenderingEnabled);
|
||||
}
|
||||
|
||||
void Framework::UpdateMyPositionRoutingOffset(bool useDefault, int offsetY)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->UpdateMyPositionRoutingOffset(useDefault, offsetY);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->UpdateMyPositionRoutingOffset(useDefault, offsetY);
|
||||
}
|
||||
|
||||
ref_ptr<df::DrapeEngine> Framework::GetDrapeEngine()
|
||||
ref_ptr<df::DrapeEngine> Framework::GetDrapeEngine(df::DrapeEngineId engineId)
|
||||
{
|
||||
return make_ref(m_drapeEngine);
|
||||
return make_ref(m_drapeEngines[engineId].m_drapeEngine);
|
||||
}
|
||||
|
||||
void Framework::DestroyDrapeEngine()
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
for (auto& [engineId, drapeEngineData] : m_drapeEngines)
|
||||
{
|
||||
m_drapeApi.SetDrapeEngine(nullptr);
|
||||
m_routingManager.SetDrapeEngine(nullptr, false);
|
||||
m_trafficManager.SetDrapeEngine(nullptr);
|
||||
m_transitManager.SetDrapeEngine(nullptr);
|
||||
m_isolinesManager.SetDrapeEngine(nullptr);
|
||||
m_searchMarks.SetDrapeEngine(nullptr);
|
||||
GetBookmarkManager().SetDrapeEngine(nullptr);
|
||||
|
||||
if (drapeEngineData.m_drapeEngine != nullptr)
|
||||
{
|
||||
drapeEngineData.m_drapeApi.SetDrapeEngine(nullptr);
|
||||
m_routingManager.SetDrapeEngine(nullptr, false);
|
||||
m_trafficManager.SetDrapeEngine(nullptr);
|
||||
m_transitManager.SetDrapeEngine(nullptr);
|
||||
m_isolinesManager.SetDrapeEngine(nullptr);
|
||||
m_searchMarks.SetDrapeEngine(nullptr);
|
||||
GetBookmarkManager().SetDrapeEngine(nullptr);
|
||||
drapeEngineData.m_drapeEngine.reset();
|
||||
}
|
||||
m_trafficManager.Teardown();
|
||||
GpsTracker::Instance().Disconnect();
|
||||
m_drapeEngine.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::SetRenderingEnabled(ref_ptr<dp::GraphicsContextFactory> contextFactory)
|
||||
{
|
||||
m_isRenderingEnabled = true;
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->SetRenderingEnabled(contextFactory);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetRenderingEnabled(contextFactory);
|
||||
}
|
||||
|
||||
void Framework::SetRenderingDisabled(bool destroySurface)
|
||||
{
|
||||
m_isRenderingEnabled = false;
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->SetRenderingDisabled(destroySurface);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetRenderingDisabled(destroySurface);
|
||||
}
|
||||
|
||||
void Framework::SetGraphicsContextInitializationHandler(df::OnGraphicsContextInitialized && handler)
|
||||
void Framework::SetGraphicsContextInitializationHandler(df::DrapeEngineId engineId, df::OnGraphicsContextInitialized && handler)
|
||||
{
|
||||
m_onGraphicsContextInitialized = std::move(handler);
|
||||
m_drapeEngines[engineId].m_onGraphicsContextInitialized = std::move(handler);
|
||||
}
|
||||
|
||||
void Framework::EnableDebugRectRendering(bool enabled)
|
||||
{
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->EnableDebugRectRendering(enabled);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->EnableDebugRectRendering(enabled);
|
||||
}
|
||||
|
||||
void Framework::ConnectToGpsTracker()
|
||||
{
|
||||
m_connectToGpsTrack = true;
|
||||
if (m_drapeEngine)
|
||||
{
|
||||
m_drapeEngine->ClearGpsTrackPoints();
|
||||
GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2));
|
||||
}
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// {
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->ClearGpsTrackPoints();
|
||||
// GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2));
|
||||
// }
|
||||
}
|
||||
|
||||
void Framework::DisconnectFromGpsTracker()
|
||||
{
|
||||
m_connectToGpsTrack = false;
|
||||
GpsTracker::Instance().Disconnect();
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->ClearGpsTrackPoints();
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->ClearGpsTrackPoints();
|
||||
}
|
||||
|
||||
void Framework::OnUpdateGpsTrackPointsCallback(vector<pair<size_t, location::GpsTrackInfo>> && toAdd,
|
||||
pair<size_t, size_t> const & toRemove)
|
||||
{
|
||||
ASSERT(m_drapeEngine.get() != nullptr, ());
|
||||
// ASSERT(m_drapeEngines.begin()->second.m_drapeEngine.get() != nullptr, ());
|
||||
|
||||
vector<df::GpsTrackPoint> pointsAdd;
|
||||
pointsAdd.reserve(toAdd.size());
|
||||
|
@ -1674,7 +1697,7 @@ void Framework::OnUpdateGpsTrackPointsCallback(vector<pair<size_t, location::Gps
|
|||
indicesRemove.emplace_back(i);
|
||||
}
|
||||
|
||||
m_drapeEngine->UpdateGpsTrackPoints(std::move(pointsAdd), std::move(indicesRemove));
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->UpdateGpsTrackPoints(std::move(pointsAdd), std::move(indicesRemove));
|
||||
}
|
||||
|
||||
void Framework::MarkMapStyle(MapStyle mapStyle)
|
||||
|
@ -1694,11 +1717,11 @@ void Framework::MarkMapStyle(MapStyle mapStyle)
|
|||
|
||||
void Framework::SetMapStyle(MapStyle mapStyle)
|
||||
{
|
||||
MarkMapStyle(mapStyle);
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->UpdateMapStyle();
|
||||
InvalidateUserMarks();
|
||||
UpdateMinBuildingsTapZoom();
|
||||
// MarkMapStyle(mapStyle);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->UpdateMapStyle();
|
||||
// InvalidateUserMarks();
|
||||
// UpdateMinBuildingsTapZoom();
|
||||
}
|
||||
|
||||
MapStyle Framework::GetMapStyle() const
|
||||
|
@ -1713,10 +1736,10 @@ void Framework::SetupMeasurementSystem()
|
|||
m_routingManager.SetTurnNotificationsUnits(measurement_utils::GetMeasurementUnits());
|
||||
}
|
||||
|
||||
void Framework::SetWidgetLayout(gui::TWidgetsLayoutInfo && layout)
|
||||
void Framework::SetWidgetLayout(df::DrapeEngineId engineId, gui::TWidgetsLayoutInfo && layout)
|
||||
{
|
||||
ASSERT(m_drapeEngine != nullptr, ());
|
||||
m_drapeEngine->SetWidgetLayout(std::move(layout));
|
||||
ASSERT(m_drapeEngines[engineId].m_drapeEngine != nullptr, ());
|
||||
m_drapeEngines[engineId].m_drapeEngine->SetWidgetLayout(std::move(layout));
|
||||
}
|
||||
|
||||
bool Framework::ShowMapForURL(string const & url)
|
||||
|
@ -1776,8 +1799,8 @@ bool Framework::ShowMapForURL(string const & url)
|
|||
|
||||
// ShowRect function interferes with ActivateMapSelection and we have strange behaviour as a result.
|
||||
// Use more obvious SetModelViewCenter here.
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->SetModelViewCenter(point, scale, true, true);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetModelViewCenter(point, scale, true, true);
|
||||
|
||||
if (result != NO_NEED_CLICK)
|
||||
{
|
||||
|
@ -1971,12 +1994,12 @@ void Framework::ActivateMapSelection()
|
|||
|
||||
auto const selObj = m_currentPlacePageInfo->GetSelectedObject();
|
||||
CHECK_NOT_EQUAL(selObj, df::SelectionShape::OBJECT_EMPTY, ("Empty selections are impossible."));
|
||||
if (m_drapeEngine)
|
||||
{
|
||||
auto const & bi = m_currentPlacePageInfo->GetBuildInfo();
|
||||
m_drapeEngine->SelectObject(selObj, m_currentPlacePageInfo->GetMercator(), featureId,
|
||||
bi.m_needAnimationOnSelection, bi.m_isGeometrySelectionAllowed, true);
|
||||
}
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// {
|
||||
// auto const & bi = m_currentPlacePageInfo->GetBuildInfo();
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SelectObject(selObj, m_currentPlacePageInfo->GetMercator(), featureId,
|
||||
// bi.m_needAnimationOnSelection, bi.m_isGeometrySelectionAllowed, true);
|
||||
// }
|
||||
|
||||
/// @todo Current android logic is strange (see SetPlacePageListeners comments), so skip assert.
|
||||
//ASSERT(m_onPlacePageOpen, ());
|
||||
|
@ -1998,8 +2021,8 @@ void Framework::DeactivateMapSelection(bool notifyUI)
|
|||
|
||||
m_currentPlacePageInfo = {};
|
||||
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->DeselectObject();
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->DeselectObject();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2047,13 +2070,13 @@ void Framework::OnTapEvent(place_page::BuildInfo const & buildInfo)
|
|||
{
|
||||
if (m_currentPlacePageInfo->GetTrackId() == prevTrackId)
|
||||
{
|
||||
if (m_drapeEngine)
|
||||
{
|
||||
m_drapeEngine->SelectObject(df::SelectionShape::ESelectedObject::OBJECT_TRACK,
|
||||
m_currentPlacePageInfo->GetMercator(), FeatureID(),
|
||||
false /* isAnim */, false /* isGeometrySelectionAllowed */,
|
||||
true /* isSelectionShapeVisible */);
|
||||
}
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
// {
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SelectObject(df::SelectionShape::ESelectedObject::OBJECT_TRACK,
|
||||
// m_currentPlacePageInfo->GetMercator(), FeatureID(),
|
||||
// false /* isAnim */, false /* isGeometrySelectionAllowed */,
|
||||
// true /* isSelectionShapeVisible */);
|
||||
// }
|
||||
return;
|
||||
}
|
||||
GetBookmarkManager().UpdateElevationMyPosition(m_currentPlacePageInfo->GetTrackId());
|
||||
|
@ -2071,8 +2094,8 @@ void Framework::OnTapEvent(place_page::BuildInfo const & buildInfo)
|
|||
|
||||
void Framework::InvalidateRendering()
|
||||
{
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->Invalidate();
|
||||
if (m_drapeEngines.begin()->second.m_drapeEngine)
|
||||
m_drapeEngines.begin()->second.m_drapeEngine->Invalidate();
|
||||
}
|
||||
|
||||
void Framework::UpdateMinBuildingsTapZoom()
|
||||
|
@ -2198,16 +2221,16 @@ std::optional<place_page::Info> Framework::BuildPlacePageInfo(
|
|||
auto const isFeatureMatchingEnabled = buildInfo.IsFeatureMatchingEnabled();
|
||||
|
||||
// Using VisualParams inside FindTrackInTapPosition/GetDefaultTapRect requires drapeEngine.
|
||||
if (m_drapeEngine != nullptr && buildInfo.IsTrackMatchingEnabled() && !buildInfo.m_isLongTap &&
|
||||
!(isFeatureMatchingEnabled && selectedFeature.IsValid()))
|
||||
{
|
||||
auto const trackSelectionInfo = FindTrackInTapPosition(buildInfo);
|
||||
if (trackSelectionInfo.m_trackId != kml::kInvalidTrackId)
|
||||
{
|
||||
BuildTrackPlacePage(trackSelectionInfo, outInfo);
|
||||
return outInfo;
|
||||
}
|
||||
}
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr && buildInfo.IsTrackMatchingEnabled() && !buildInfo.m_isLongTap &&
|
||||
// !(isFeatureMatchingEnabled && selectedFeature.IsValid()))
|
||||
// {
|
||||
// auto const trackSelectionInfo = FindTrackInTapPosition(buildInfo);
|
||||
// if (trackSelectionInfo.m_trackId != kml::kInvalidTrackId)
|
||||
// {
|
||||
// BuildTrackPlacePage(trackSelectionInfo, outInfo);
|
||||
// return outInfo;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (isFeatureMatchingEnabled && !selectedFeature.IsValid())
|
||||
selectedFeature = FindBuildingAtPoint(buildInfo.m_mercator);
|
||||
|
@ -2402,16 +2425,16 @@ void Framework::SaveTransliteration(bool allowTranslit)
|
|||
|
||||
void Framework::Allow3dMode(bool allow3d, bool allow3dBuildings)
|
||||
{
|
||||
if (m_drapeEngine == nullptr)
|
||||
return;
|
||||
|
||||
if (!m_powerManager.IsFacilityEnabled(power_management::Facility::PerspectiveView))
|
||||
allow3d = false;
|
||||
|
||||
if (!m_powerManager.IsFacilityEnabled(power_management::Facility::Buildings3d))
|
||||
allow3dBuildings = false;
|
||||
|
||||
m_drapeEngine->Allow3dMode(allow3d, allow3dBuildings);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine == nullptr)
|
||||
// return;
|
||||
//
|
||||
// if (!m_powerManager.IsFacilityEnabled(power_management::Facility::PerspectiveView))
|
||||
// allow3d = false;
|
||||
//
|
||||
// if (!m_powerManager.IsFacilityEnabled(power_management::Facility::Buildings3d))
|
||||
// allow3dBuildings = false;
|
||||
//
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->Allow3dMode(allow3d, allow3dBuildings);
|
||||
}
|
||||
|
||||
void Framework::Save3dMode(bool allow3d, bool allow3dBuildings)
|
||||
|
@ -2446,10 +2469,10 @@ void Framework::SetLargeFontsSize(bool isLargeSize)
|
|||
{
|
||||
double const scaleFactor = isLargeSize ? kLargeFontsScaleFactor : 1.0;
|
||||
|
||||
ASSERT(m_drapeEngine.get() != nullptr, ());
|
||||
m_drapeEngine->SetFontScaleFactor(scaleFactor);
|
||||
// ASSERT(m_drapeEngines.begin()->second.m_drapeEngine.get() != nullptr, ());
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetFontScaleFactor(scaleFactor);
|
||||
|
||||
InvalidateRect(GetCurrentViewport());
|
||||
// InvalidateRect(GetCurrentViewport());
|
||||
}
|
||||
|
||||
bool Framework::LoadTrafficEnabled()
|
||||
|
@ -2491,8 +2514,8 @@ void Framework::AllowAutoZoom(bool allowAutoZoom)
|
|||
routing::RouterType const type = m_routingManager.GetRouter();
|
||||
bool const isPedestrianRoute = type == RouterType::Pedestrian;
|
||||
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->AllowAutoZoom(allowAutoZoom && !isPedestrianRoute);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->AllowAutoZoom(allowAutoZoom && !isPedestrianRoute);
|
||||
}
|
||||
|
||||
void Framework::SaveAutoZoom(bool allowAutoZoom)
|
||||
|
@ -2529,11 +2552,11 @@ void Framework::SaveIsolinesEnabled(bool enabled)
|
|||
void Framework::EnableChoosePositionMode(bool enable, bool enableBounds, bool applyPosition,
|
||||
m2::PointD const & position)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
{
|
||||
m_drapeEngine->EnableChoosePositionMode(enable,
|
||||
enableBounds ? GetSelectedFeatureTriangles() : vector<m2::TriangleD>(), applyPosition, position);
|
||||
}
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// {
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->EnableChoosePositionMode(enable,
|
||||
// enableBounds ? GetSelectedFeatureTriangles() : vector<m2::TriangleD>(), applyPosition, position);
|
||||
// }
|
||||
}
|
||||
|
||||
vector<m2::TriangleD> Framework::GetSelectedFeatureTriangles() const
|
||||
|
@ -2561,8 +2584,8 @@ vector<m2::TriangleD> Framework::GetSelectedFeatureTriangles() const
|
|||
|
||||
void Framework::BlockTapEvents(bool block)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->BlockTapEvents(block);
|
||||
// if (m_drapeEngines.begin()->second.m_drapeEngine != nullptr)
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->BlockTapEvents(block);
|
||||
}
|
||||
|
||||
bool Framework::ParseDrapeDebugCommand(string const & query)
|
||||
|
@ -2589,14 +2612,14 @@ bool Framework::ParseDrapeDebugCommand(string const & query)
|
|||
|
||||
if (query == "?aa" || query == "effect:antialiasing")
|
||||
{
|
||||
m_drapeEngine->SetPosteffectEnabled(df::PostprocessRenderer::Antialiasing,
|
||||
true /* enabled */);
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetPosteffectEnabled(df::PostprocessRenderer::Antialiasing,
|
||||
// true /* enabled */);
|
||||
return true;
|
||||
}
|
||||
if (query == "?no-aa" || query == "effect:no-antialiasing")
|
||||
{
|
||||
m_drapeEngine->SetPosteffectEnabled(df::PostprocessRenderer::Antialiasing,
|
||||
false /* enabled */);
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->SetPosteffectEnabled(df::PostprocessRenderer::Antialiasing,
|
||||
// false /* enabled */);
|
||||
return true;
|
||||
}
|
||||
if (query == "?scheme")
|
||||
|
@ -2621,29 +2644,29 @@ bool Framework::ParseDrapeDebugCommand(string const & query)
|
|||
}
|
||||
if (query == "?debug-info")
|
||||
{
|
||||
m_drapeEngine->ShowDebugInfo(true /* shown */);
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->ShowDebugInfo(true /* shown */);
|
||||
return true;
|
||||
}
|
||||
if (query == "?debug-info-always")
|
||||
{
|
||||
m_drapeEngine->ShowDebugInfo(true /* shown */);
|
||||
settings::Set(kShowDebugInfo, true);
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->ShowDebugInfo(true /* shown */);
|
||||
// settings::Set(kShowDebugInfo, true);
|
||||
return true;
|
||||
}
|
||||
if (query == "?no-debug-info")
|
||||
{
|
||||
m_drapeEngine->ShowDebugInfo(false /* shown */);
|
||||
settings::Set(kShowDebugInfo, false);
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->ShowDebugInfo(false /* shown */);
|
||||
// settings::Set(kShowDebugInfo, false);
|
||||
return true;
|
||||
}
|
||||
if (query == "?debug-rect")
|
||||
{
|
||||
m_drapeEngine->EnableDebugRectRendering(true /* shown */);
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->EnableDebugRectRendering(true /* shown */);
|
||||
return true;
|
||||
}
|
||||
if (query == "?no-debug-rect")
|
||||
{
|
||||
m_drapeEngine->EnableDebugRectRendering(false /* shown */);
|
||||
// m_drapeEngines.begin()->second.m_drapeEngine->EnableDebugRectRendering(false /* shown */);
|
||||
return true;
|
||||
}
|
||||
#if defined(OMIM_METAL_AVAILABLE)
|
||||
|
@ -3168,7 +3191,7 @@ void Framework::OnRouteFollow(routing::RouterType type)
|
|||
// TODO. We need to sync two enums VehicleType and RouterType to be able to pass
|
||||
// GetRoutingSettings(type).m_matchRoute to the FollowRoute() instead of |isPedestrianRoute|.
|
||||
// |isArrowGlued| parameter fully corresponds to |m_matchRoute| in RoutingSettings.
|
||||
m_drapeEngine->FollowRoute(scale, scale3d, enableAutoZoom, !isPedestrianRoute /* isArrowGlued */);
|
||||
m_drapeEngines.begin()->second.m_drapeEngine->FollowRoute(scale, scale3d, enableAutoZoom, !isPedestrianRoute /* isArrowGlued */);
|
||||
}
|
||||
|
||||
// RoutingManager::Delegate
|
||||
|
|
|
@ -162,7 +162,13 @@ protected:
|
|||
using TViewportChangedFn = df::DrapeEngine::ModelViewChangedHandler;
|
||||
TViewportChangedFn m_viewportChangedFn;
|
||||
|
||||
drape_ptr<df::DrapeEngine> m_drapeEngine;
|
||||
struct DrapeEngineData
|
||||
{
|
||||
drape_ptr<df::DrapeEngine> m_drapeEngine;
|
||||
df::OnGraphicsContextInitialized m_onGraphicsContextInitialized;
|
||||
df::DrapeApi m_drapeApi;
|
||||
};
|
||||
std::unordered_map<df::DrapeEngineId, DrapeEngineData> m_drapeEngines;
|
||||
|
||||
StorageDownloadingPolicy m_storageDownloadingPolicy;
|
||||
storage::Storage m_storage;
|
||||
|
@ -175,8 +181,6 @@ protected:
|
|||
|
||||
SearchMarks m_searchMarks;
|
||||
|
||||
df::DrapeApi m_drapeApi;
|
||||
|
||||
bool m_isRenderingEnabled;
|
||||
|
||||
// Note. |m_powerManager| should be declared before |m_routingManager|
|
||||
|
@ -213,7 +217,7 @@ public:
|
|||
explicit Framework(FrameworkParams const & params = {});
|
||||
virtual ~Framework() override;
|
||||
|
||||
df::DrapeApi & GetDrapeApi() { return m_drapeApi; }
|
||||
df::DrapeApi & GetDrapeApi() { return m_drapeEngines.begin()->second.m_drapeApi; }
|
||||
|
||||
/// \returns true if there're unsaved changes in map with |countryId| and false otherwise.
|
||||
/// \note It works for group and leaf node.
|
||||
|
@ -394,17 +398,18 @@ public:
|
|||
df::Hints m_hints;
|
||||
};
|
||||
|
||||
void CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFactory, DrapeCreationParams && params);
|
||||
ref_ptr<df::DrapeEngine> GetDrapeEngine();
|
||||
bool IsDrapeEngineCreated() const { return m_drapeEngine != nullptr; }
|
||||
df::DrapeEngineId CreateDrapeEngineId();
|
||||
void CreateDrapeEngine(df::DrapeEngineId engineId, ref_ptr<dp::GraphicsContextFactory> contextFactory, DrapeCreationParams && params);
|
||||
ref_ptr<df::DrapeEngine> GetDrapeEngine(df::DrapeEngineId engineId);
|
||||
bool IsDrapeEngineCreated(df::DrapeEngineId engineId) const { return m_drapeEngines.count(engineId) != 0 && m_drapeEngines.at(engineId).m_drapeEngine != nullptr; }
|
||||
void DestroyDrapeEngine();
|
||||
/// Called when graphics engine should be temporarily paused and then resumed.
|
||||
void SetRenderingEnabled(ref_ptr<dp::GraphicsContextFactory> contextFactory = nullptr);
|
||||
void SetRenderingDisabled(bool destroySurface);
|
||||
|
||||
void SetGraphicsContextInitializationHandler(df::OnGraphicsContextInitialized && handler);
|
||||
void SetGraphicsContextInitializationHandler(df::DrapeEngineId engineId, df::OnGraphicsContextInitialized && handler);
|
||||
|
||||
void OnRecoverSurface(int width, int height, bool recreateContextDependentResources);
|
||||
void OnRecoverSurface(df::DrapeEngineId engineId, int width, int height, bool recreateContextDependentResources);
|
||||
void OnDestroySurface();
|
||||
|
||||
void UpdateVisualScale(double vs);
|
||||
|
@ -419,8 +424,6 @@ private:
|
|||
/// Depends on initialized Drape engine.
|
||||
void LoadViewport();
|
||||
|
||||
df::OnGraphicsContextInitialized m_onGraphicsContextInitialized;
|
||||
|
||||
public:
|
||||
void ConnectToGpsTracker();
|
||||
void DisconnectFromGpsTracker();
|
||||
|
@ -431,7 +434,7 @@ public:
|
|||
|
||||
void SetupMeasurementSystem();
|
||||
|
||||
void SetWidgetLayout(gui::TWidgetsLayoutInfo && layout);
|
||||
void SetWidgetLayout(df::DrapeEngineId engineId, gui::TWidgetsLayoutInfo && layout);
|
||||
|
||||
void PrepareToShutdown();
|
||||
|
||||
|
@ -493,7 +496,7 @@ public:
|
|||
void SetViewportCenter(m2::PointD const & pt, int zoomLevel = -1, bool isAnim = true);
|
||||
|
||||
m2::RectD GetCurrentViewport() const;
|
||||
void SetVisibleViewport(m2::RectD const & rect);
|
||||
void SetVisibleViewport(df::DrapeEngineId engineId, m2::RectD const & rect);
|
||||
|
||||
/// - Check minimal visible scale according to downloaded countries.
|
||||
void ShowRect(m2::RectD const & rect, int maxScale = -1, bool animation = true,
|
||||
|
@ -512,7 +515,7 @@ public:
|
|||
void StopLocationFollow();
|
||||
|
||||
/// Resize event from window.
|
||||
void OnSize(int w, int h);
|
||||
void OnSize(df::DrapeEngineId engineId, int w, int h);
|
||||
|
||||
enum EScaleMode
|
||||
{
|
||||
|
@ -522,20 +525,20 @@ public:
|
|||
SCALE_MIN_LIGHT
|
||||
};
|
||||
|
||||
void Scale(EScaleMode mode, bool isAnim);
|
||||
void Scale(EScaleMode mode, m2::PointD const & pxPoint, bool isAnim);
|
||||
void Scale(double factor, bool isAnim);
|
||||
void Scale(double factor, m2::PointD const & pxPoint, bool isAnim);
|
||||
void Scale(df::DrapeEngineId engineId, EScaleMode mode, bool isAnim);
|
||||
void Scale(df::DrapeEngineId engineId, EScaleMode mode, m2::PointD const & pxPoint, bool isAnim);
|
||||
void Scale(df::DrapeEngineId engineId, double factor, bool isAnim);
|
||||
void Scale(df::DrapeEngineId engineId, double factor, m2::PointD const & pxPoint, bool isAnim);
|
||||
|
||||
/// Moves the viewport a distance of factorX * viewportWidth and factorY * viewportHeight.
|
||||
/// E.g. factorX == 1.0 moves the map one screen size to the right, factorX == -0.5 moves the map
|
||||
/// half screen size to the left, factorY == -2.0 moves the map two sizes down,
|
||||
/// factorY = 1.5 moves the map one and a half size up.
|
||||
void Move(double factorX, double factorY, bool isAnim);
|
||||
void Move(df::DrapeEngineId engineId, double factorX, double factorY, bool isAnim);
|
||||
|
||||
void Rotate(double azimuth, bool isAnim);
|
||||
|
||||
void TouchEvent(df::TouchEvent const & touch);
|
||||
void TouchEvent(df::DrapeEngineId engineId, df::TouchEvent const & touch);
|
||||
|
||||
int GetDrawScale() const;
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ private:
|
|||
for (auto const p : GetBoundPrograms()) \
|
||||
{ \
|
||||
auto const programName = DebugPrint(p); \
|
||||
CHECK(params.find(programName) == params.cend(), \
|
||||
("Program has already bound", programName)); \
|
||||
params[programName] = GetName(); \
|
||||
} \
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue