void Framework::DetachSurface() { m_work.EnterBackground(); ASSERT(m_contextFactory != nullptr, ()); AndroidOGLContextFactory * factory = m_contextFactory->CastFactory<AndroidOGLContextFactory>(); factory->ResetSurface(); }
void Framework::DetachSurface(bool destroyContext) { LOG(LINFO, ("Detach surface.")); if (destroyContext) { LOG(LINFO, ("Destroy context.")); m_isContextDestroyed = true; m_work.EnterBackground(); } m_work.SetRenderingDisabled(destroyContext); ASSERT(m_contextFactory != nullptr, ()); AndroidOGLContextFactory * factory = m_contextFactory->CastFactory<AndroidOGLContextFactory>(); factory->ResetSurface(); }
bool Framework::AttachSurface(JNIEnv * env, jobject jSurface) { LOG(LINFO, ("Attach surface.")); ASSERT(m_contextFactory != nullptr, ()); AndroidOGLContextFactory * factory = m_contextFactory->CastFactory<AndroidOGLContextFactory>(); factory->SetSurface(env, jSurface); if (!factory->IsValid()) { LOG(LWARNING, ("Invalid GL context.")); return false; } ASSERT(!m_guiPositions.empty(), ("GUI elements must be set-up before engine is created")); m_work.SetRenderingEnabled(factory); if (m_isContextDestroyed) { LOG(LINFO, ("Recover GL resources, viewport size:", factory->GetWidth(), factory->GetHeight())); m_work.UpdateDrapeEngine(factory->GetWidth(), factory->GetHeight()); m_isContextDestroyed = false; m_work.EnterForeground(); } return true; }