diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 20176b7f47..592358e637 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -284,11 +284,18 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) case Message::SelectObject: { ref_ptr msg = message; - ASSERT(m_selectionShape != nullptr, ()); + if (msg->IsDismiss()) - m_selectionShape->Hide(); + { + // m_selectionShape can be null in case of deselection + if (m_selectionShape != nullptr) + m_selectionShape->Hide(); + } else + { + ASSERT(m_selectionShape != nullptr, ()); m_selectionShape->Show(msg->GetSelectedObject(), msg->GetPosition(), msg->IsAnim()); + } break; } diff --git a/iphone/Maps/Classes/EAGLView.h b/iphone/Maps/Classes/EAGLView.h index ec9f0afdeb..a8df3d1365 100644 --- a/iphone/Maps/Classes/EAGLView.h +++ b/iphone/Maps/Classes/EAGLView.h @@ -21,7 +21,6 @@ namespace dp CGRect lastViewSize; } -- (void)initRenderPolicy; - (void)deallocateNative; - (CGPoint)viewPoint2GlobalPoint:(CGPoint)pt; - (CGPoint)globalPoint2ViewPoint:(CGPoint)pt; diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index 0f815a443e..86ac171a13 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -89,6 +89,8 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale) if ((self = [super initWithCoder:coder])) { + lastViewSize = CGRectZero; + // Setup Layer Properties CAEAGLLayer * eaglLayer = (CAEAGLLayer *)self.layer; @@ -107,14 +109,13 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale) return self; } -- (void)initRenderPolicy +- (void)createDrapeEngineWithWidth:(int)width height:(int)height { - NSLog(@"EAGLView initRenderPolicy Started"); + NSLog(@"EAGLView createDrapeEngine Started"); - CGRect frameRect = [UIScreen mainScreen].applicationFrame; Framework::DrapeCreationParams p; - p.m_surfaceWidth = frameRect.size.width; - p.m_surfaceHeight = frameRect.size.height; + p.m_surfaceWidth = width; + p.m_surfaceHeight = height; p.m_visualScale = self.contentScaleFactor; /// @TODO (iOS developers) remove this stuff and create real logic for init and layout core widgets @@ -129,7 +130,7 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale) GetFramework().CreateDrapeEngine(make_ref(m_factory), move(p)); - NSLog(@"EAGLView initRenderPolicy Ended"); + NSLog(@"EAGLView createDrapeEngine Ended"); } - (void)addSubview:(UIView *)view @@ -149,6 +150,14 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale) { int w = width * self.contentScaleFactor; int h = height * self.contentScaleFactor; + + if (GetFramework().GetDrapeEngine() == nullptr) + { + [self createDrapeEngineWithWidth:w height:h]; + GetFramework().LoadState(); + return; + } + GetFramework().OnSize(w, h); /// @TODO (iOS developers) remove this stuff and create real logic for layout core widgets diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index c95522fcc2..16f5edebd3 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -412,8 +412,6 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction) - (void)viewDidLoad { [super viewDidLoad]; - EAGLView * v = (EAGLView *)self.view; - [v initRenderPolicy]; self.view.clipsToBounds = YES; [MTRGManager setMyCom:YES]; self.controlsManager = [[MWMMapViewControlsManager alloc] initWithParentController:self]; @@ -505,15 +503,10 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction) m_StickyThreshold = 10; - EAGLView * v = (EAGLView *)self.view; - [v initRenderPolicy]; - self.forceRoutingStateChange = ForceRoutingStateChangeNone; self.userTouchesAction = UserTouchesActionNone; self.menuRestoreState = MWMBottomMenuStateInactive; - // restore previous screen position - f.LoadState(); f.LoadBookmarks(); using TLocationStateModeFn = void (*)(id, SEL, location::EMyPositionMode); diff --git a/iphone/Maps/Platform/opengl/iosOGLContext.mm b/iphone/Maps/Platform/opengl/iosOGLContext.mm index 0ab44261a1..0ec7e221de 100644 --- a/iphone/Maps/Platform/opengl/iosOGLContext.mm +++ b/iphone/Maps/Platform/opengl/iosOGLContext.mm @@ -56,10 +56,17 @@ void iosOGLContext::setDefaultFramebuffer() glBindFramebuffer(GL_FRAMEBUFFER, m_frameBufferId); } -void iosOGLContext::resize(int /*w*/, int /*h*/) +void iosOGLContext::resize(int w, int h) { if (m_needBuffers && m_hasBuffers) { + GLint width = 0; + GLint height = 0; + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width); + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height); + if (width == w && height == h) + return; + destroyBuffers(); initBuffers(); } diff --git a/map/framework.cpp b/map/framework.cpp index 800a6a68e3..dd0a987270 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -155,14 +155,12 @@ void Framework::SwitchMyPositionNextMode() void Framework::InvalidateMyPosition() { - ASSERT(m_drapeEngine != nullptr, ()); CallDrapeFunction(bind(&df::DrapeEngine::InvalidateMyPosition, _1)); } void Framework::SetMyPositionModeListener(location::TMyPositionModeChanged const & fn) { - ASSERT(m_drapeEngine != nullptr, ()); - CallDrapeFunction(bind(&df::DrapeEngine::SetMyPositionModeListener, _1, fn)); + m_myPositionListener = fn; } void Framework::OnUserPositionChanged(m2::PointD const & position) @@ -915,7 +913,6 @@ void Framework::EnterBackground() ClearAllCaches(); #endif - ASSERT(m_drapeEngine != nullptr, ("Drape engine has not been initialized yet")); if (m_drapeEngine != nullptr) m_drapeEngine->SetRenderingEnabled(false); } @@ -924,7 +921,7 @@ void Framework::EnterForeground() { m_startForegroundTime = my::Timer::LocalTime(); - ASSERT(m_drapeEngine != nullptr, ("Drape engine has not been initialized yet")); + // Drape can be not initialized here in case of the first launch if (m_drapeEngine != nullptr) m_drapeEngine->SetRenderingEnabled(true); } @@ -1272,6 +1269,9 @@ void Framework::CreateDrapeEngine(ref_ptr contextFactory, m_drapeEngine->SetTapEventInfoListener(bind(&Framework::OnTapEvent, this, _1, _2, _3, _4)); m_drapeEngine->SetUserPositionListener(bind(&Framework::OnUserPositionChanged, this, _1)); OnSize(params.m_surfaceWidth, params.m_surfaceHeight); + + m_drapeEngine->SetMyPositionModeListener(m_myPositionListener); + InvalidateMyPosition(); } ref_ptr Framework::GetDrapeEngine() diff --git a/map/framework.hpp b/map/framework.hpp index 6171b5b50e..b5cdfbf6e8 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -87,6 +87,9 @@ class Framework #endif protected: + using TDrapeFunction = function; + using TDownloadCountryListener = function; + StringsBundle m_stringsBundle; // The order matters here: storage::CountryInfoGetter must be @@ -100,25 +103,21 @@ protected: routing::RoutingSession m_routingSession; - typedef vector::iterator CategoryIter; - drape_ptr m_storageBridge; drape_ptr m_drapeEngine; - using TDrapeFunction = function; - void CallDrapeFunction(TDrapeFunction const & fn); - double m_startForegroundTime; - void StopLocationFollow(); - - using TDownloadCountryListener = function; TDownloadCountryListener m_downloadCountryListener; storage::Storage m_storage; shared_ptr m_activeMaps; storage::CountryTree m_globalCntTree; + location::TMyPositionModeChanged m_myPositionListener; + + BookmarkManager m_bmManager; + /// This function is called by m_storage when latest local files /// were changed. void UpdateLatestCountryFile(platform::LocalCountryFile const & localFile); @@ -126,10 +125,12 @@ protected: /// This function is called by m_model when the map file is deregistered. void OnMapDeregistered(platform::LocalCountryFile const & localFile); - BookmarkManager m_bmManager; - void ClearAllCaches(); + void StopLocationFollow(); + + void CallDrapeFunction(TDrapeFunction const & fn); + public: Framework(); virtual ~Framework();