| 568 | } |
| 569 | |
| 570 | bool StandardMainLoop::doMainLoop() |
| 571 | { |
| 572 | #ifdef TORQUE_DEBUG |
| 573 | if( gStartupTimer ) |
| 574 | { |
| 575 | Con::printf( "Started up in %.2f seconds...", |
| 576 | F32( gStartupTimer->getElapsedMs() ) / 1000.f ); |
| 577 | SAFE_DELETE( gStartupTimer ); |
| 578 | } |
| 579 | #endif |
| 580 | |
| 581 | bool keepRunning = true; |
| 582 | // while(keepRunning) |
| 583 | { |
| 584 | tm->setBackgroundThreshold(mClamp(sgBackgroundProcessSleepTime, 1, 200)); |
| 585 | tm->setForegroundThreshold(mClamp(sgTimeManagerProcessInterval, 1, 200)); |
| 586 | // update foreground/background status |
| 587 | if(WindowManager->getFirstWindow()) |
| 588 | { |
| 589 | static bool lastFocus = false; |
| 590 | bool newFocus = ( WindowManager->getFocusedWindow() != NULL ); |
| 591 | if(lastFocus != newFocus) |
| 592 | { |
| 593 | #ifndef TORQUE_SHIPPING |
| 594 | Con::printf("Window focus status changed: focus: %d", newFocus); |
| 595 | if (!newFocus) |
| 596 | Con::printf(" Using background sleep time: %u", Platform::getBackgroundSleepTime()); |
| 597 | #endif |
| 598 | |
| 599 | #ifdef TORQUE_OS_MAC |
| 600 | if (newFocus) |
| 601 | WindowManager->getFirstWindow()->show(); |
| 602 | |
| 603 | #endif |
| 604 | lastFocus = newFocus; |
| 605 | } |
| 606 | |
| 607 | // under the web plugin do not sleep the process when the child window loses focus as this will cripple the browser perfomance |
| 608 | if (!Platform::getWebDeployment()) |
| 609 | tm->setBackground(!newFocus); |
| 610 | else |
| 611 | tm->setBackground(false); |
| 612 | } |
| 613 | else |
| 614 | { |
| 615 | tm->setBackground(false); |
| 616 | } |
| 617 | |
| 618 | PROFILE_START(MainLoop); |
| 619 | Sampler::beginFrame(); |
| 620 | |
| 621 | if(!Process::processEvents()) |
| 622 | keepRunning = false; |
| 623 | |
| 624 | ThreadPool::processMainThreadWorkItems(); |
| 625 | Sampler::endFrame(); |
| 626 | PROFILE_END_NAMED(MainLoop); |
| 627 | } |
nothing calls this directly
no test coverage detected