Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -1786,14 +1786,29 @@ bool Application::event(QEvent* event) { · 1785 unmodified lines | |||
| 1786 | return false; | 1786 | return false; |
| 1787 | } | 1787 | } |
| 1788 | 1788 | ||
| 1789 | static bool justPresented = false; | ||
| 1789 | if ((int)event->type() == (int)Present) { | 1790 | if ((int)event->type() == (int)Present) { |
| 1791 | if (justPresented) { | ||
| 1792 | justPresented = false; | ||
| 1793 | |||
| 1794 | // If presentation is hogging the main thread, repost as low priority to avoid hanging the GUI. | ||
| 1795 | // This has the effect of allowing presentation to exceed the paint budget by X times and | ||
| 1796 | // only dropping every (1/X) frames, instead of every ceil(X) frames. | ||
| 1797 | // (e.g. at a 60FPS target, painting for 17us would fall to 58.82FPS instead of 30FPS). | ||
| 1798 | removePostedEvents(this, Present); | ||
| 1799 | postEvent(this, new QEvent(static_cast<QEvent::Type>(Present)), Qt::LowEventPriority); | ||
| 1800 | return true; | ||
| 1801 | } | ||
| 1802 | |||
| 1790 | idle(); | 1803 | idle(); |
| 1791 | removePostedEvents(this, Present); // clear pending presents so we don't clog the pipes | ||
| 1792 | return true; | 1804 | return true; |
| 1793 | } else if ((int)event->type() == (int)Paint) { | 1805 | } else if ((int)event->type() == (int)Paint) { |
| 1806 | justPresented = true; | ||
| 1794 | paintGL(); | 1807 | paintGL(); |
| 1795 | return true; | 1808 | return true; |
| 1796 | } else if ((int)event->type() == (int)Lambda) { | 1809 | } |
| 1810 | |||
| 1811 | if ((int)event->type() == (int)Lambda) { | ||
| 1797 | static_cast<LambdaEvent*>(event)->call(); | 1812 | static_cast<LambdaEvent*>(event)->call(); |
| 1798 | return true; | 1813 | return true; |
| 1799 | } | 1814 | } |
| @@ -2605,7 +2620,7 @@ void Application::idle() { · 805 unmodified lines | |||
| 2605 | _renderedFrameIndex = displayPlugin->presentCount(); | 2620 | _renderedFrameIndex = displayPlugin->presentCount(); |
| 2606 | 2621 | ||
| 2607 | // Request a paint ASAP | 2622 | // Request a paint ASAP |
| 2608 | postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority); | 2623 | postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority + 1); |
| 2609 | 2624 | ||
| 2610 | // Update the deadlock watchdog | 2625 | // Update the deadlock watchdog |
| 2611 | updateHeartbeat(); | 2626 | updateHeartbeat(); |