macOS: Treat default swapInterval (-1) as vsync-enabled display-link
Change-Id: I6d3d241d3813bfac36155ad219d4a338cb1ef6f7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
21e25ff38b
commit
17e5158570
@ -330,7 +330,7 @@ void QCocoaScreen::deliverUpdateRequests()
|
||||
auto windows = QGuiApplication::allWindows();
|
||||
for (int i = 0; i < windows.size(); ++i) {
|
||||
QWindow *window = windows.at(i);
|
||||
QPlatformWindow *platformWindow = window->handle();
|
||||
auto *platformWindow = static_cast<QCocoaWindow*>(window->handle());
|
||||
if (!platformWindow)
|
||||
continue;
|
||||
|
||||
@ -341,7 +341,7 @@ void QCocoaScreen::deliverUpdateRequests()
|
||||
continue;
|
||||
|
||||
// Skip windows that are not doing update requests via display link
|
||||
if (!(window->format().swapInterval() > 0))
|
||||
if (!platformWindow->updatesWithDisplayLink())
|
||||
continue;
|
||||
|
||||
platformWindow->deliverUpdateRequest();
|
||||
|
@ -129,6 +129,7 @@ public:
|
||||
bool isForeignWindow() const override;
|
||||
|
||||
void requestUpdate() override;
|
||||
bool updatesWithDisplayLink() const;
|
||||
void deliverUpdateRequest() override;
|
||||
|
||||
void requestActivateWindow() override;
|
||||
|
@ -1473,11 +1473,10 @@ void QCocoaWindow::recreateWindowIfNeeded()
|
||||
|
||||
void QCocoaWindow::requestUpdate()
|
||||
{
|
||||
const int swapInterval = format().swapInterval();
|
||||
qCDebug(lcQpaDrawing) << "QCocoaWindow::requestUpdate" << window() << "swapInterval" << swapInterval;
|
||||
qCDebug(lcQpaDrawing) << "QCocoaWindow::requestUpdate" << window()
|
||||
<< "using" << (updatesWithDisplayLink() ? "display-link" : "timer");
|
||||
|
||||
if (swapInterval > 0) {
|
||||
// Vsync is enabled, deliver via CVDisplayLink
|
||||
if (updatesWithDisplayLink()) {
|
||||
static_cast<QCocoaScreen *>(screen())->requestUpdate();
|
||||
} else {
|
||||
// Fall back to the un-throttled timer-based callback
|
||||
@ -1485,6 +1484,12 @@ void QCocoaWindow::requestUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
bool QCocoaWindow::updatesWithDisplayLink() const
|
||||
{
|
||||
// Update via CVDisplayLink if Vsync is enabled
|
||||
return format().swapInterval() != 0;
|
||||
}
|
||||
|
||||
void QCocoaWindow::deliverUpdateRequest()
|
||||
{
|
||||
// Don't send update requests for views that need display, as the update
|
||||
|
Loading…
Reference in New Issue
Block a user