diff --git a/base/timer.cpp b/base/timer.cpp index 8e7c36453f..0c88ab2b00 100644 --- a/base/timer.cpp +++ b/base/timer.cpp @@ -22,6 +22,8 @@ namespace base // static double Timer::LocalTime() { + /// @todo duration_cast(system_clock::now().time_since_epoch()).count() ? + #ifdef OMIM_OS_WINDOWS_NATIVE FILETIME ft; GetSystemTimeAsFileTime(&ft); diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index 3eaf3f1d52..0aef86be9a 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -743,9 +743,18 @@ void DrapeEngine::OnEnterBackground() m_startBackgroundTime = base::Timer::LocalTime(); settings::Set(kLastEnterBackground, m_startBackgroundTime); - m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, - make_unique_dp(), - MessagePriority::High); + /// @todo By VNG: Make direct call to FR, because logic with PostMessage is not working now. + /// Rendering engine becomes disabled first and posted message won't be processed in a correct timing + /// and will remain pending in queue, waiting until rendering queue will became active. + /// As a result, we will get OnEnterBackground notification when we already entered foreground (sic!). + /// One minus with direct call is that we are not in FR rendering thread, but I don't see a problem here now. + /// To make it works as expected with PostMessage, we should refactor platform notifications, + /// especially Android with its AppBackgroundTracker. + m_frontend->OnEnterBackground(); + +// m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, +// make_unique_dp(), +// MessagePriority::High); } void DrapeEngine::RequestSymbolsSize(std::vector const & symbols, diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 2875cde42c..d211f05c2e 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -16,14 +16,12 @@ #include "shaders/programs.hpp" +#include "drape/constants.hpp" #include "drape/drape_global.hpp" #include "drape/framebuffer.hpp" #include "drape/support_manager.hpp" -#include "drape/utils/glyph_usage_tracker.hpp" -#include "drape/utils/gpu_mem_tracker.hpp" #include "drape/utils/projection.hpp" -#include "indexer/classificator_loader.hpp" #include "indexer/drawing_rules.hpp" #include "indexer/map_style_reader.hpp" #include "indexer/scales.hpp" @@ -47,10 +45,11 @@ #include #include -using namespace std::placeholders; namespace df { +using namespace std::placeholders; + namespace { float constexpr kIsometryAngle = static_cast(math::pi) * 76.0f / 180.0f; @@ -812,11 +811,11 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) break; } - case Message::Type::OnEnterBackground: - { - m_myPositionController->OnEnterBackground(); - break; - } +// case Message::Type::OnEnterBackground: +// { +// m_myPositionController->OnEnterBackground(); +// break; +// } case Message::Type::SetAddNewPlaceMode: { @@ -2522,6 +2521,11 @@ void FrontendRenderer::ChangeModelView(double autoScale, m2::PointD const & user AddUserEvent(make_unique_dp(userPos, pxZero, azimuth, autoScale, parallelAnimCreator)); } +void FrontendRenderer::OnEnterBackground() +{ + m_myPositionController->OnEnterBackground(); +} + ScreenBase const & FrontendRenderer::ProcessEvents(bool & modelViewChanged, bool & viewportChanged) { ScreenBase const & modelView = m_userEventStream.ProcessEvents(modelViewChanged, viewportChanged); @@ -2610,11 +2614,6 @@ void FrontendRenderer::OnCacheRouteArrows(dp::DrapeID subrouteIndex, std::vector MessagePriority::Normal); } -drape_ptr const & FrontendRenderer::GetScenarioManager() const -{ - return m_scenarioManager; -} - void FrontendRenderer::CollectShowOverlaysEvents() { ASSERT(m_overlaysShowStatsCallback != nullptr, ()); diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index a84d763f1c..20f2ce8d55 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -1,16 +1,11 @@ #pragma once -#include "base/thread.hpp" - -#include "drape_frontend/gui/layer_render.hpp" - -#include "drape_frontend/backend_renderer.hpp" #include "drape_frontend/base_renderer.hpp" #include "drape_frontend/drape_api_renderer.hpp" #include "drape_frontend/frame_values.hpp" #include "drape_frontend/gps_track_renderer.hpp" +#include "drape_frontend/gui/layer_render.hpp" #include "drape_frontend/my_position_controller.hpp" -#include "drape_frontend/navigator.hpp" #include "drape_frontend/overlays_tracker.hpp" #include "drape_frontend/render_group.hpp" #include "drape_frontend/render_state_extension.hpp" @@ -18,7 +13,6 @@ #include "drape_frontend/route_renderer.hpp" #include "drape_frontend/postprocess_renderer.hpp" #include "drape_frontend/threads_commutator.hpp" -#include "drape_frontend/tile_info.hpp" #include "drape_frontend/traffic_renderer.hpp" #include "drape_frontend/transit_scheme_renderer.hpp" #include "drape_frontend/user_event_stream.hpp" @@ -29,18 +23,18 @@ #include "drape/overlay_tree.hpp" #include "drape/pointers.hpp" -#include "drape/vertex_array_buffer.hpp" #include "platform/location.hpp" #include "geometry/screenbase.hpp" #include "geometry/triangle2d.hpp" +#include "base/thread.hpp" + #include #include #include #include -#include #include namespace dp @@ -148,10 +142,11 @@ public: void ChangeModelView(double autoScale, m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero, TAnimationCreator const & parallelAnimCreator) override; - drape_ptr const & GetScenarioManager() const; - + drape_ptr const & GetScenarioManager() const { return m_scenarioManager; } location::EMyPositionMode GetMyPositionMode() const { return m_myPositionController->GetCurrentMode(); } + void OnEnterBackground(); + protected: void AcceptMessage(ref_ptr message) override; std::unique_ptr CreateRoutine() override; diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp index bf21f8b382..667feb45d1 100644 --- a/drape_frontend/my_position_controller.cpp +++ b/drape_frontend/my_position_controller.cpp @@ -336,7 +336,6 @@ void MyPositionController::NextMode(ScreenBase const & screen) // Start looking for location. if (m_mode == location::NotFollowNoPosition) { - ResetNotification(m_locationWaitingNotifyId); ChangeMode(location::PendingPosition); if (!m_isPositionAssigned) @@ -525,14 +524,9 @@ void MyPositionController::LoseLocation() return; if (m_mode == location::Follow || m_mode == location::FollowAndRotate) - { - ResetNotification(m_locationWaitingNotifyId); ChangeMode(location::PendingPosition); - } else - { ChangeMode(location::NotFollowNoPosition); - } if (m_listener != nullptr) m_listener->PositionChanged(Position(), false /* hasPosition */); @@ -636,6 +630,7 @@ void MyPositionController::ChangeMode(location::EMyPositionMode newMode) if (newMode == location::PendingPosition) { + ResetNotification(m_locationWaitingNotifyId); m_pendingTimer.Reset(); m_pendingStarted = true; }