Commit d91bdee3 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Allow fullscreen effects to override latency policy

With some effects, latency policy doesn't matter and it's preferred if
kwin uses the smoothest animation latency policy in order to minimize
the number of frame drops, e.g. slide.
parent 773384b5
Pipeline #179316 passed with stage
in 19 minutes and 43 seconds
......@@ -26,6 +26,7 @@
#include "osd.h"
#include "pointer_input.h"
#include "renderbackend.h"
#include "renderlayer.h"
#include "unmanaged.h"
#include "x11window.h"
#if KWIN_BUILD_TABBOX
......@@ -576,6 +577,15 @@ void EffectsHandlerImpl::setActiveFullScreenEffect(Effect *e)
fullscreen_effect = e;
Q_EMIT activeFullScreenEffectChanged();
if (activeChanged) {
const auto delegates = m_scene->delegates();
for (SceneDelegate *delegate : delegates) {
RenderLoop *loop = delegate->layer()->loop();
if (fullscreen_effect) {
loop->setLatencyPolicy(LatencyPolicy::LatencyExtremelyHigh);
} else {
loop->resetLatencyPolicy();
}
}
Q_EMIT hasActiveFullScreenEffectChanged();
}
}
......
......@@ -5,7 +5,6 @@
*/
#include "renderloop.h"
#include "options.h"
#include "renderloop_p.h"
#include "surfaceitem.h"
#include "utils/common.h"
......@@ -57,7 +56,7 @@ void RenderLoopPrivate::scheduleRepaint()
const std::chrono::nanoseconds safetyMargin = std::chrono::milliseconds(3);
std::chrono::nanoseconds renderTime;
switch (options->latencyPolicy()) {
switch (q->latencyPolicy()) {
case LatencyExteremelyLow:
renderTime = std::chrono::nanoseconds(long(vblankInterval.count() * 0.1));
break;
......@@ -230,6 +229,21 @@ void RenderLoop::scheduleRepaint(Item *item)
}
}
LatencyPolicy RenderLoop::latencyPolicy() const
{
return d->latencyPolicy.value_or(options->latencyPolicy());
}
void RenderLoop::setLatencyPolicy(LatencyPolicy policy)
{
d->latencyPolicy = policy;
}
void RenderLoop::resetLatencyPolicy()
{
d->latencyPolicy.reset();
}
std::chrono::nanoseconds RenderLoop::lastPresentationTimestamp() const
{
return d->lastPresentationTimestamp;
......
......@@ -7,6 +7,7 @@
#pragma once
#include "kwinglobals.h"
#include "options.h"
#include <QObject>
......@@ -109,6 +110,22 @@ public:
*/
void setVrrPolicy(VrrPolicy vrrPolicy);
/**
* Returns the latency policy for this render loop.
*/
LatencyPolicy latencyPolicy() const;
/**
* Sets the latecy policy of this render loop to @a policy. By default,
* the latency policy of this render loop matches options->latencyPolicy().
*/
void setLatencyPolicy(LatencyPolicy policy);
/**
* Resets the latency policy to the default value.
*/
void resetLatencyPolicy();
Q_SIGNALS:
/**
* This signal is emitted when the refresh rate of this RenderLoop has changed.
......
......@@ -11,6 +11,8 @@
#include <QTimer>
#include <optional>
namespace KWin
{
......@@ -41,6 +43,7 @@ public:
bool pendingReschedule = false;
bool pendingRepaint = false;
RenderLoop::VrrPolicy vrrPolicy = RenderLoop::VrrPolicy::Never;
std::optional<LatencyPolicy> latencyPolicy;
Item *fullscreenItem = nullptr;
enum class SyncMode {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment