Changeset View
Changeset View
Standalone View
Standalone View
composite.cpp
Show First 20 Lines • Show All 328 Lines • ▼ Show 20 Line(s) | 328 | connect(kwinApp(), &Application::x11ConnectionChanged, | |||
---|---|---|---|---|---|
329 | this, &Compositor::setupX11Support, Qt::UniqueConnection); | 329 | this, &Compositor::setupX11Support, Qt::UniqueConnection); | ||
330 | Workspace::self()->markXStackingOrderAsDirty(); | 330 | Workspace::self()->markXStackingOrderAsDirty(); | ||
331 | Q_ASSERT(m_scene); | 331 | Q_ASSERT(m_scene); | ||
332 | 332 | | |||
333 | connect(workspace(), &Workspace::destroyed, this, [this] { compositeTimer.stop(); }); | 333 | connect(workspace(), &Workspace::destroyed, this, [this] { compositeTimer.stop(); }); | ||
334 | setupX11Support(); | 334 | setupX11Support(); | ||
335 | fpsInterval = options->maxFpsInterval(); | 335 | fpsInterval = options->maxFpsInterval(); | ||
336 | 336 | | |||
337 | if (m_scene->syncsToVBlank()) { | 337 | const auto rate = currentRefreshRate(); | ||
338 | Q_ASSERT(rate != 0); // There is a fallback in options.cpp, so why check at all? | ||||
339 | if (rate != 0) { | ||||
338 | // If we do vsync, set the fps to the next multiple of the vblank rate. | 340 | // If we do vsync, set the fps to the next multiple of the vblank rate. | ||
339 | vBlankInterval = milliToNano(1000) / currentRefreshRate(); | 341 | vBlankInterval = milliToNano(1000) / currentRefreshRate(); | ||
340 | fpsInterval = qMax((fpsInterval / vBlankInterval) * vBlankInterval, vBlankInterval); | 342 | fpsInterval = qMax((fpsInterval / vBlankInterval) * vBlankInterval, vBlankInterval); | ||
341 | } else { | 343 | } else { | ||
342 | // No vsync - DO NOT set "0", would cause div-by-zero segfaults. | 344 | // No vsync - DO NOT set "0", would cause div-by-zero segfaults. | ||
343 | vBlankInterval = milliToNano(1); | 345 | vBlankInterval = milliToNano(1); | ||
344 | } | 346 | } | ||
zzag: Delete this branch? | |||||
Yea, I added an assert before anyway. I don't remember why I left the branch in and added the assert instead. Was maybe not sure about it but if you also see nothing wrong with removing the branch at the moment I'm gonna do it. romangg: Yea, I added an assert before anyway. I don't remember why I left the branch in and added the… | |||||
zzag: Yes, please delete this branch. | |||||
345 | 347 | | |||
346 | // Sets also the 'effects' pointer. | 348 | // Sets also the 'effects' pointer. | ||
347 | kwinApp()->platform()->createEffectsHandler(this, m_scene); | 349 | kwinApp()->platform()->createEffectsHandler(this, m_scene); | ||
348 | connect(Workspace::self(), &Workspace::deletedRemoved, m_scene, &Scene::removeToplevel); | 350 | connect(Workspace::self(), &Workspace::deletedRemoved, m_scene, &Scene::removeToplevel); | ||
349 | connect(effects, &EffectsHandler::screenGeometryChanged, this, &Compositor::addRepaintFull); | 351 | connect(effects, &EffectsHandler::screenGeometryChanged, this, &Compositor::addRepaintFull); | ||
350 | 352 | | |||
351 | for (X11Client *c : Workspace::self()->clientList()) { | 353 | for (X11Client *c : Workspace::self()->clientList()) { | ||
352 | c->setupCompositing(); | 354 | c->setupCompositing(); | ||
▲ Show 20 Lines • Show All 361 Lines • ▼ Show 20 Line(s) | 604 | { | |||
714 | // Stop here to ensure *we* cause the next repaint schedule - not some effect | 716 | // Stop here to ensure *we* cause the next repaint schedule - not some effect | ||
715 | // through m_scene->paint(). | 717 | // through m_scene->paint(). | ||
716 | compositeTimer.stop(); | 718 | compositeTimer.stop(); | ||
717 | 719 | | |||
718 | // Trigger at least one more pass even if there would be nothing to paint, so that scene->idle() | 720 | // Trigger at least one more pass even if there would be nothing to paint, so that scene->idle() | ||
719 | // is called the next time. If there would be nothing pending, it will not restart the timer and | 721 | // is called the next time. If there would be nothing pending, it will not restart the timer and | ||
720 | // scheduleRepaint() would restart it again somewhen later, called from functions that | 722 | // scheduleRepaint() would restart it again somewhen later, called from functions that | ||
721 | // would again add something pending. | 723 | // would again add something pending. | ||
722 | if (m_bufferSwapPending && m_scene->syncsToVBlank()) { | 724 | if (m_bufferSwapPending) { | ||
723 | m_composeAtSwapCompletion = true; | 725 | m_composeAtSwapCompletion = true; | ||
724 | } else { | 726 | } else { | ||
725 | scheduleRepaint(); | 727 | scheduleRepaint(); | ||
726 | } | 728 | } | ||
727 | } | 729 | } | ||
728 | 730 | | |||
729 | template <class T> | 731 | template <class T> | ||
730 | static bool repaintsPending(const QList<T*> &windows) | 732 | static bool repaintsPending(const QList<T*> &windows) | ||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 772 | { | |||
813 | else { // w/o blocking vsync we just jump to the next demanded tick | 815 | else { // w/o blocking vsync we just jump to the next demanded tick | ||
814 | if (fpsInterval > m_timeSinceLastVBlank) { | 816 | if (fpsInterval > m_timeSinceLastVBlank) { | ||
815 | waitTime = nanoToMilli(fpsInterval - m_timeSinceLastVBlank); | 817 | waitTime = nanoToMilli(fpsInterval - m_timeSinceLastVBlank); | ||
816 | if (!waitTime) { | 818 | if (!waitTime) { | ||
817 | // Will ensure we don't block out the eventloop - the system's just not faster ... | 819 | // Will ensure we don't block out the eventloop - the system's just not faster ... | ||
818 | waitTime = 1; | 820 | waitTime = 1; | ||
819 | } | 821 | } | ||
820 | } | 822 | } | ||
821 | /* else if (m_scene->syncsToVBlank() && m_timeSinceLastVBlank - fpsInterval < (vBlankInterval<<1)) { | 823 | /* else if (m_timeSinceLastVBlank - fpsInterval < (vBlankInterval<<1)) { | ||
822 | // NOTICE - "for later" ------------------------------------------------------------------ | 824 | // NOTICE - "for later" ------------------------------------------------------------------ | ||
823 | // It can happen that we push two frames within one refresh cycle. | 825 | // It can happen that we push two frames within one refresh cycle. | ||
824 | // Swapping will then block even with triple buffering when the GPU does not discard but | 826 | // Swapping will then block even with triple buffering when the GPU does not discard but | ||
825 | // queues frames | 827 | // queues frames | ||
826 | // now here's the mean part: if we take that as "OMG, we're late - next frame ASAP", | 828 | // now here's the mean part: if we take that as "OMG, we're late - next frame ASAP", | ||
827 | // there'll immediately be 2 frames in the pipe, swapping will block, we think we're | 829 | // there'll immediately be 2 frames in the pipe, swapping will block, we think we're | ||
828 | // late ... ewww | 830 | // late ... ewww | ||
829 | // so instead we pad to the clock again and add 2ms safety to ensure the pipe is really | 831 | // so instead we pad to the clock again and add 2ms safety to ensure the pipe is really | ||
▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines |
Delete this branch?