| 332 | } |
| 333 | |
| 334 | bool Framework::AttachSurface(JNIEnv * env, jobject jSurface) |
| 335 | { |
| 336 | LOG(LINFO, ("Attach surface started.")); |
| 337 | |
| 338 | int w = 0, h = 0; |
| 339 | if (m_vulkanContextFactory) |
| 340 | { |
| 341 | auto factory = CastFactory(m_vulkanContextFactory); |
| 342 | factory->SetSurface(env, jSurface); |
| 343 | if (!factory->IsValid()) |
| 344 | { |
| 345 | LOG(LWARNING, ("Invalid Vulkan API context.")); |
| 346 | return false; |
| 347 | } |
| 348 | w = factory->GetWidth(); |
| 349 | h = factory->GetHeight(); |
| 350 | } |
| 351 | else |
| 352 | { |
| 353 | ASSERT(m_oglContextFactory != nullptr, ()); |
| 354 | auto factory = m_oglContextFactory->CastFactory<AndroidOGLContextFactory>(); |
| 355 | factory->SetSurface(env, jSurface); |
| 356 | if (!factory->IsValid()) |
| 357 | { |
| 358 | LOG(LWARNING, ("Invalid GL context.")); |
| 359 | return false; |
| 360 | } |
| 361 | w = factory->GetWidth(); |
| 362 | h = factory->GetHeight(); |
| 363 | } |
| 364 | |
| 365 | ASSERT(!m_guiPositions.empty(), ("GUI elements must be set-up before engine is created")); |
| 366 | |
| 367 | if (m_vulkanContextFactory) |
| 368 | { |
| 369 | m_vulkanContextFactory->SetPresentAvailable(true); |
| 370 | m_work.SetRenderingEnabled(); |
| 371 | } |
| 372 | else |
| 373 | { |
| 374 | m_oglContextFactory->SetPresentAvailable(true); |
| 375 | m_work.SetRenderingEnabled(make_ref(m_oglContextFactory)); |
| 376 | } |
| 377 | |
| 378 | if (m_isSurfaceDestroyed) |
| 379 | { |
| 380 | LOG(LINFO, ("Recover surface, viewport size:", w, h)); |
| 381 | bool const recreateContextDependentResources = (m_vulkanContextFactory == nullptr); |
| 382 | m_work.OnRecoverSurface(w, h, recreateContextDependentResources); |
| 383 | m_isSurfaceDestroyed = false; |
| 384 | } |
| 385 | |
| 386 | LOG(LINFO, ("Attach surface finished.")); |
| 387 | |
| 388 | return true; |
| 389 | } |
| 390 | |
| 391 | void Framework::PauseSurfaceRendering() |
no test coverage detected