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();
|
auto windows = QGuiApplication::allWindows();
|
||||||
for (int i = 0; i < windows.size(); ++i) {
|
for (int i = 0; i < windows.size(); ++i) {
|
||||||
QWindow *window = windows.at(i);
|
QWindow *window = windows.at(i);
|
||||||
QPlatformWindow *platformWindow = window->handle();
|
auto *platformWindow = static_cast<QCocoaWindow*>(window->handle());
|
||||||
if (!platformWindow)
|
if (!platformWindow)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ void QCocoaScreen::deliverUpdateRequests()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Skip windows that are not doing update requests via display link
|
// Skip windows that are not doing update requests via display link
|
||||||
if (!(window->format().swapInterval() > 0))
|
if (!platformWindow->updatesWithDisplayLink())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
platformWindow->deliverUpdateRequest();
|
platformWindow->deliverUpdateRequest();
|
||||||
|
@ -129,6 +129,7 @@ public:
|
|||||||
bool isForeignWindow() const override;
|
bool isForeignWindow() const override;
|
||||||
|
|
||||||
void requestUpdate() override;
|
void requestUpdate() override;
|
||||||
|
bool updatesWithDisplayLink() const;
|
||||||
void deliverUpdateRequest() override;
|
void deliverUpdateRequest() override;
|
||||||
|
|
||||||
void requestActivateWindow() override;
|
void requestActivateWindow() override;
|
||||||
|
@ -1473,11 +1473,10 @@ void QCocoaWindow::recreateWindowIfNeeded()
|
|||||||
|
|
||||||
void QCocoaWindow::requestUpdate()
|
void QCocoaWindow::requestUpdate()
|
||||||
{
|
{
|
||||||
const int swapInterval = format().swapInterval();
|
qCDebug(lcQpaDrawing) << "QCocoaWindow::requestUpdate" << window()
|
||||||
qCDebug(lcQpaDrawing) << "QCocoaWindow::requestUpdate" << window() << "swapInterval" << swapInterval;
|
<< "using" << (updatesWithDisplayLink() ? "display-link" : "timer");
|
||||||
|
|
||||||
if (swapInterval > 0) {
|
if (updatesWithDisplayLink()) {
|
||||||
// Vsync is enabled, deliver via CVDisplayLink
|
|
||||||
static_cast<QCocoaScreen *>(screen())->requestUpdate();
|
static_cast<QCocoaScreen *>(screen())->requestUpdate();
|
||||||
} else {
|
} else {
|
||||||
// Fall back to the un-throttled timer-based callback
|
// 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()
|
void QCocoaWindow::deliverUpdateRequest()
|
||||||
{
|
{
|
||||||
// Don't send update requests for views that need display, as the update
|
// Don't send update requests for views that need display, as the update
|
||||||
|
Loading…
Reference in New Issue
Block a user