protocols: commit and presentation timing fixes (#13174)
* move commit timing fields to surface state * fix toTimespec init * update sendQueued api * update onPresented api * set zero copy flag * send clock id * move presented calcs inside condition * use only CLOCK_MONOTONIC for commit/presentation timings * fix setSetTimestamp * do not wait for commit timing while tearing * proto config * fix config defaults
This commit is contained in:
parent
407a623801
commit
ff061d177e
14 changed files with 107 additions and 64 deletions
|
|
@ -1573,6 +1573,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.type = CONFIG_OPTION_CHOICE,
|
.type = CONFIG_OPTION_CHOICE,
|
||||||
.data = SConfigOptionDescription::SChoiceData{0, "default,gamma22,gamma22force,srgb"},
|
.data = SConfigOptionDescription::SChoiceData{0, "default,gamma22,gamma22force,srgb"},
|
||||||
},
|
},
|
||||||
|
SConfigOptionDescription{
|
||||||
|
.value = "render:commit_timing_enabled",
|
||||||
|
.description = "Enable commit timing proto. Requires restart",
|
||||||
|
.type = CONFIG_OPTION_BOOL,
|
||||||
|
.data = SConfigOptionDescription::SBoolData{true},
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cursor:
|
* cursor:
|
||||||
|
|
|
||||||
|
|
@ -785,6 +785,7 @@ CConfigManager::CConfigManager() {
|
||||||
registerConfigVar("render:new_render_scheduling", Hyprlang::INT{0});
|
registerConfigVar("render:new_render_scheduling", Hyprlang::INT{0});
|
||||||
registerConfigVar("render:non_shader_cm", Hyprlang::INT{3});
|
registerConfigVar("render:non_shader_cm", Hyprlang::INT{3});
|
||||||
registerConfigVar("render:cm_sdr_eotf", Hyprlang::INT{0});
|
registerConfigVar("render:cm_sdr_eotf", Hyprlang::INT{0});
|
||||||
|
registerConfigVar("render:commit_timing_enabled", Hyprlang::INT{1});
|
||||||
|
|
||||||
registerConfigVar("ecosystem:no_update_news", Hyprlang::INT{0});
|
registerConfigVar("ecosystem:no_update_news", Hyprlang::INT{0});
|
||||||
registerConfigVar("ecosystem:no_donation_nag", Hyprlang::INT{0});
|
registerConfigVar("ecosystem:no_donation_nag", Hyprlang::INT{0});
|
||||||
|
|
|
||||||
|
|
@ -114,10 +114,12 @@ void CMonitor::onConnect(bool noRule) {
|
||||||
ts = nullptr;
|
ts = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ts)
|
if (!ts) {
|
||||||
PROTO::presentation->onPresented(m_self.lock(), Time::steadyNow(), event.refresh, event.seq, event.flags);
|
timespec mono{};
|
||||||
else
|
clock_gettime(CLOCK_MONOTONIC, &mono);
|
||||||
PROTO::presentation->onPresented(m_self.lock(), Time::fromTimespec(event.when), event.refresh, event.seq, event.flags);
|
PROTO::presentation->onPresented(m_self.lock(), mono, event.refresh, event.seq, event.flags & ~Aquamarine::IOutput::AQ_OUTPUT_PRESENT_HW_CLOCK);
|
||||||
|
} else
|
||||||
|
PROTO::presentation->onPresented(m_self.lock(), *ts, event.refresh, event.seq, event.flags);
|
||||||
|
|
||||||
if (m_zoomAnimFrameCounter < 5) {
|
if (m_zoomAnimFrameCounter < 5) {
|
||||||
m_zoomAnimFrameCounter++;
|
m_zoomAnimFrameCounter++;
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ Time::steady_tp Time::fromTimespec(const timespec* ts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timespec Time::toTimespec(const steady_tp& tp) {
|
struct timespec Time::toTimespec(const steady_tp& tp) {
|
||||||
struct timespec mono, real;
|
timespec mono{}, real{};
|
||||||
clock_gettime(CLOCK_MONOTONIC, &mono);
|
clock_gettime(CLOCK_MONOTONIC, &mono);
|
||||||
clock_gettime(CLOCK_REALTIME, &real);
|
clock_gettime(CLOCK_REALTIME, &real);
|
||||||
Time::steady_tp now = Time::steadyNow();
|
Time::steady_tp now = Time::steadyNow();
|
||||||
|
|
@ -136,3 +136,10 @@ struct timespec Time::toTimespec(const steady_tp& tp) {
|
||||||
auto sum = timeadd(tpTime, diffFinal);
|
auto sum = timeadd(tpTime, diffFinal);
|
||||||
return timespec{.tv_sec = sum.first, .tv_nsec = sum.second};
|
return timespec{.tv_sec = sum.first, .tv_nsec = sum.second};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Time::steady_dur Time::till(const timespec& ts) {
|
||||||
|
timespec mono{};
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &mono);
|
||||||
|
const auto delay = (ts.tv_sec - mono.tv_sec) * 1000000000 + (ts.tv_nsec - mono.tv_nsec);
|
||||||
|
return std::chrono::nanoseconds(delay);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ namespace Time {
|
||||||
|
|
||||||
steady_tp fromTimespec(const timespec*);
|
steady_tp fromTimespec(const timespec*);
|
||||||
struct timespec toTimespec(const steady_tp& tp);
|
struct timespec toTimespec(const steady_tp& tp);
|
||||||
|
steady_dur till(const timespec& ts);
|
||||||
|
|
||||||
uint64_t millis(const steady_tp& tp);
|
uint64_t millis(const steady_tp& tp);
|
||||||
uint64_t millis(const system_tp& tp);
|
uint64_t millis(const system_tp& tp);
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,8 @@ CProtocolManager::CProtocolManager() {
|
||||||
static const auto PENABLECM = CConfigValue<Hyprlang::INT>("render:cm_enabled");
|
static const auto PENABLECM = CConfigValue<Hyprlang::INT>("render:cm_enabled");
|
||||||
static const auto PDEBUGCM = CConfigValue<Hyprlang::INT>("debug:full_cm_proto");
|
static const auto PDEBUGCM = CConfigValue<Hyprlang::INT>("debug:full_cm_proto");
|
||||||
|
|
||||||
|
static const auto PENABLECT = CConfigValue<Hyprlang::INT>("render:commit_timing_enabled");
|
||||||
|
|
||||||
// Outputs are a bit dumb, we have to agree.
|
// Outputs are a bit dumb, we have to agree.
|
||||||
static auto P = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
|
static auto P = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||||
auto M = std::any_cast<PHLMONITOR>(param);
|
auto M = std::any_cast<PHLMONITOR>(param);
|
||||||
|
|
@ -194,7 +196,9 @@ CProtocolManager::CProtocolManager() {
|
||||||
PROTO::extDataDevice = makeUnique<CExtDataDeviceProtocol>(&ext_data_control_manager_v1_interface, 1, "ExtDataDevice");
|
PROTO::extDataDevice = makeUnique<CExtDataDeviceProtocol>(&ext_data_control_manager_v1_interface, 1, "ExtDataDevice");
|
||||||
PROTO::pointerWarp = makeUnique<CPointerWarpProtocol>(&wp_pointer_warp_v1_interface, 1, "PointerWarp");
|
PROTO::pointerWarp = makeUnique<CPointerWarpProtocol>(&wp_pointer_warp_v1_interface, 1, "PointerWarp");
|
||||||
PROTO::fifo = makeUnique<CFifoProtocol>(&wp_fifo_manager_v1_interface, 1, "Fifo");
|
PROTO::fifo = makeUnique<CFifoProtocol>(&wp_fifo_manager_v1_interface, 1, "Fifo");
|
||||||
PROTO::commitTiming = makeUnique<CCommitTimingProtocol>(&wp_commit_timing_manager_v1_interface, 1, "CommitTiming");
|
|
||||||
|
if (*PENABLECT)
|
||||||
|
PROTO::commitTiming = makeUnique<CCommitTimingProtocol>(&wp_commit_timing_manager_v1_interface, 1, "CommitTiming");
|
||||||
|
|
||||||
if (*PENABLECM)
|
if (*PENABLECM)
|
||||||
PROTO::colorManagement = makeUnique<CColorManagementProtocol>(&wp_color_manager_v1_interface, 1, "ColorManagement", *PDEBUGCM);
|
PROTO::colorManagement = makeUnique<CColorManagementProtocol>(&wp_color_manager_v1_interface, 1, "ColorManagement", *PDEBUGCM);
|
||||||
|
|
|
||||||
|
|
@ -12,61 +12,48 @@ CCommitTimerResource::CCommitTimerResource(UP<CWpCommitTimerV1>&& resource_, SP<
|
||||||
m_resource->setOnDestroy([this](CWpCommitTimerV1* r) { PROTO::commitTiming->destroyResource(this); });
|
m_resource->setOnDestroy([this](CWpCommitTimerV1* r) { PROTO::commitTiming->destroyResource(this); });
|
||||||
|
|
||||||
m_resource->setSetTimestamp([this](CWpCommitTimerV1* r, uint32_t tvHi, uint32_t tvLo, uint32_t tvNsec) {
|
m_resource->setSetTimestamp([this](CWpCommitTimerV1* r, uint32_t tvHi, uint32_t tvLo, uint32_t tvNsec) {
|
||||||
return;
|
|
||||||
|
|
||||||
if (!m_surface) {
|
if (!m_surface) {
|
||||||
r->error(WP_COMMIT_TIMER_V1_ERROR_SURFACE_DESTROYED, "Surface was gone");
|
r->error(WP_COMMIT_TIMER_V1_ERROR_SURFACE_DESTROYED, "Surface was gone");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pendingTimeout.has_value()) {
|
if (m_surface->m_pending.pendingTimeout.has_value()) {
|
||||||
r->error(WP_COMMIT_TIMER_V1_ERROR_TIMESTAMP_EXISTS, "Timestamp is already set");
|
r->error(WP_COMMIT_TIMER_V1_ERROR_TIMESTAMP_EXISTS, "Timestamp is already set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
timespec ts;
|
const auto delay = Time::till({.tv_sec = (((uint64_t)tvHi) << 32) | (uint64_t)tvLo, .tv_nsec = tvNsec});
|
||||||
ts.tv_sec = (((uint64_t)tvHi) << 32) | (uint64_t)tvLo;
|
|
||||||
ts.tv_nsec = tvNsec;
|
|
||||||
|
|
||||||
const auto TIME = Time::fromTimespec(&ts);
|
if (delay.count() <= 0) {
|
||||||
const auto TIME_NOW = Time::steadyNow();
|
m_surface->m_pending.pendingTimeout.reset();
|
||||||
|
|
||||||
if (TIME_NOW > TIME) {
|
|
||||||
m_pendingTimeout.reset();
|
|
||||||
} else
|
} else
|
||||||
m_pendingTimeout = TIME - TIME_NOW;
|
m_surface->m_pending.pendingTimeout = delay;
|
||||||
});
|
});
|
||||||
|
|
||||||
m_listeners.surfaceStateCommit = m_surface->m_events.stateCommit2.listen([this](auto state) {
|
m_listeners.surfaceStateCommit = m_surface->m_events.stateCommit2.listen([this](auto state) {
|
||||||
if (!m_pendingTimeout.has_value())
|
if (!state || !state->pendingTimeout.has_value() || !m_surface || m_surface->isTearing())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_surface->m_stateQueue.lock(state, LOCK_REASON_TIMER);
|
m_surface->m_stateQueue.lock(state, LOCK_REASON_TIMER);
|
||||||
|
|
||||||
if (!m_timerPresent) {
|
if (!state->timer) {
|
||||||
m_timerPresent = true;
|
state->timer = makeShared<CEventLoopTimer>(
|
||||||
timer = makeShared<CEventLoopTimer>(
|
state->pendingTimeout,
|
||||||
m_pendingTimeout,
|
[this, state](SP<CEventLoopTimer> self, void* data) {
|
||||||
[this](SP<CEventLoopTimer> self, void* data) {
|
if (!m_surface || !state)
|
||||||
if (!m_surface)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_surface->m_stateQueue.unlockFirst(LOCK_REASON_TIMER);
|
m_surface->m_stateQueue.unlock(state, LOCK_REASON_TIMER);
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
g_pEventLoopManager->addTimer(timer);
|
g_pEventLoopManager->addTimer(state->timer);
|
||||||
} else
|
} else
|
||||||
timer->updateTimeout(m_pendingTimeout);
|
state->timer->updateTimeout(state->pendingTimeout);
|
||||||
|
|
||||||
m_pendingTimeout.reset();
|
state->pendingTimeout.reset();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CCommitTimerResource::~CCommitTimerResource() {
|
|
||||||
if (m_timerPresent)
|
|
||||||
g_pEventLoopManager->removeTimer(timer);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CCommitTimerResource::good() {
|
bool CCommitTimerResource::good() {
|
||||||
return m_resource->resource();
|
return m_resource->resource();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
#include "commit-timing-v1.hpp"
|
#include "commit-timing-v1.hpp"
|
||||||
|
|
||||||
|
|
@ -14,16 +13,12 @@ class CEventLoopTimer;
|
||||||
class CCommitTimerResource {
|
class CCommitTimerResource {
|
||||||
public:
|
public:
|
||||||
CCommitTimerResource(UP<CWpCommitTimerV1>&& resource_, SP<CWLSurfaceResource> surface);
|
CCommitTimerResource(UP<CWpCommitTimerV1>&& resource_, SP<CWLSurfaceResource> surface);
|
||||||
~CCommitTimerResource();
|
|
||||||
|
|
||||||
bool good();
|
bool good();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UP<CWpCommitTimerV1> m_resource;
|
UP<CWpCommitTimerV1> m_resource;
|
||||||
WP<CWLSurfaceResource> m_surface;
|
WP<CWLSurfaceResource> m_surface;
|
||||||
bool m_timerPresent = false;
|
|
||||||
std::optional<Time::steady_dur> m_pendingTimeout;
|
|
||||||
SP<CEventLoopTimer> timer;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
CHyprSignalListener surfaceStateCommit;
|
CHyprSignalListener surfaceStateCommit;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ bool CPresentationFeedback::good() {
|
||||||
return m_resource->resource();
|
return m_resource->resource();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPresentationFeedback::sendQueued(WP<CQueuedPresentationData> data, const Time::steady_tp& when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags) {
|
void CPresentationFeedback::sendQueued(WP<CQueuedPresentationData> data, const timespec& when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags) {
|
||||||
auto client = m_resource->client();
|
auto client = m_resource->client();
|
||||||
|
|
||||||
if LIKELY (PROTO::outputs.contains(data->m_monitor->m_name) && data->m_wasPresented) {
|
if LIKELY (PROTO::outputs.contains(data->m_monitor->m_name) && data->m_wasPresented) {
|
||||||
|
|
@ -48,28 +48,26 @@ void CPresentationFeedback::sendQueued(WP<CQueuedPresentationData> data, const T
|
||||||
m_resource->sendSyncOutput(outputResource->getResource()->resource());
|
m_resource->sendSyncOutput(outputResource->getResource()->resource());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t flags = 0;
|
if (data->m_wasPresented) {
|
||||||
if (!data->m_monitor->m_tearingState.activelyTearing)
|
uint32_t flags = 0;
|
||||||
flags |= WP_PRESENTATION_FEEDBACK_KIND_VSYNC;
|
if (!data->m_monitor->m_tearingState.activelyTearing)
|
||||||
if (data->m_zeroCopy)
|
flags |= WP_PRESENTATION_FEEDBACK_KIND_VSYNC;
|
||||||
flags |= WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY;
|
if (data->m_zeroCopy)
|
||||||
if (reportedFlags & Aquamarine::IOutput::AQ_OUTPUT_PRESENT_HW_CLOCK)
|
flags |= WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY;
|
||||||
flags |= WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
|
if (reportedFlags & Aquamarine::IOutput::AQ_OUTPUT_PRESENT_HW_CLOCK)
|
||||||
if (reportedFlags & Aquamarine::IOutput::AQ_OUTPUT_PRESENT_HW_COMPLETION)
|
flags |= WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
|
||||||
flags |= WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION;
|
if (reportedFlags & Aquamarine::IOutput::AQ_OUTPUT_PRESENT_HW_COMPLETION)
|
||||||
|
flags |= WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION;
|
||||||
|
|
||||||
const auto TIMESPEC = Time::toTimespec(when);
|
time_t tv_sec = 0;
|
||||||
|
if (sizeof(time_t) > 4)
|
||||||
|
tv_sec = when.tv_sec >> 32;
|
||||||
|
|
||||||
time_t tv_sec = 0;
|
uint32_t refreshNs = m_resource->version() == 1 && data->m_monitor->m_vrrActive && data->m_monitor->m_output->vrrCapable ? 0 : untilRefreshNs;
|
||||||
if (sizeof(time_t) > 4)
|
|
||||||
tv_sec = TIMESPEC.tv_sec >> 32;
|
|
||||||
|
|
||||||
uint32_t refreshNs = m_resource->version() == 1 && data->m_monitor->m_vrrActive && data->m_monitor->m_output->vrrCapable ? 0 : untilRefreshNs;
|
m_resource->sendPresented(sc<uint32_t>(tv_sec), sc<uint32_t>(when.tv_sec & 0xFFFFFFFF), sc<uint32_t>(when.tv_nsec), refreshNs, sc<uint32_t>(seq >> 32),
|
||||||
|
|
||||||
if (data->m_wasPresented)
|
|
||||||
m_resource->sendPresented(sc<uint32_t>(tv_sec), sc<uint32_t>(TIMESPEC.tv_sec & 0xFFFFFFFF), sc<uint32_t>(TIMESPEC.tv_nsec), refreshNs, sc<uint32_t>(seq >> 32),
|
|
||||||
sc<uint32_t>(seq & 0xFFFFFFFF), sc<wpPresentationFeedbackKind>(flags));
|
sc<uint32_t>(seq & 0xFFFFFFFF), sc<wpPresentationFeedbackKind>(flags));
|
||||||
else
|
} else
|
||||||
m_resource->sendDiscarded();
|
m_resource->sendDiscarded();
|
||||||
|
|
||||||
m_done = true;
|
m_done = true;
|
||||||
|
|
@ -88,6 +86,7 @@ void CPresentationProtocol::bindManager(wl_client* client, void* data, uint32_t
|
||||||
|
|
||||||
RESOURCE->setDestroy([this](CWpPresentation* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
|
RESOURCE->setDestroy([this](CWpPresentation* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
|
||||||
RESOURCE->setFeedback([this](CWpPresentation* pMgr, wl_resource* surf, uint32_t id) { this->onGetFeedback(pMgr, surf, id); });
|
RESOURCE->setFeedback([this](CWpPresentation* pMgr, wl_resource* surf, uint32_t id) { this->onGetFeedback(pMgr, surf, id); });
|
||||||
|
RESOURCE->sendClockId(CLOCK_MONOTONIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPresentationProtocol::onManagerResourceDestroy(wl_resource* res) {
|
void CPresentationProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||||
|
|
@ -110,7 +109,7 @@ void CPresentationProtocol::onGetFeedback(CWpPresentation* pMgr, wl_resource* su
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPresentationProtocol::onPresented(PHLMONITOR pMonitor, const Time::steady_tp& when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags) {
|
void CPresentationProtocol::onPresented(PHLMONITOR pMonitor, const timespec& when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags) {
|
||||||
for (auto const& feedback : m_feedbacks) {
|
for (auto const& feedback : m_feedbacks) {
|
||||||
if (!feedback->m_surface)
|
if (!feedback->m_surface)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
|
|
@ -37,7 +38,7 @@ class CPresentationFeedback {
|
||||||
|
|
||||||
bool good();
|
bool good();
|
||||||
|
|
||||||
void sendQueued(WP<CQueuedPresentationData> data, const Time::steady_tp& when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags);
|
void sendQueued(WP<CQueuedPresentationData> data, const timespec& when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UP<CWpPresentationFeedback> m_resource;
|
UP<CWpPresentationFeedback> m_resource;
|
||||||
|
|
@ -53,7 +54,7 @@ class CPresentationProtocol : public IWaylandProtocol {
|
||||||
|
|
||||||
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
||||||
|
|
||||||
void onPresented(PHLMONITOR pMonitor, const Time::steady_tp& when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags);
|
void onPresented(PHLMONITOR pMonitor, const timespec& when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags);
|
||||||
void queueData(UP<CQueuedPresentationData>&& data);
|
void queueData(UP<CQueuedPresentationData>&& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -626,6 +626,30 @@ bool CWLSurfaceResource::hasVisibleSubsurface() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CWLSurfaceResource::isTearing() {
|
||||||
|
if (m_enteredOutputs.empty() && m_hlSurface) {
|
||||||
|
for (auto& m : g_pCompositor->m_monitors) {
|
||||||
|
if (!m || !m->m_enabled)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto box = m_hlSurface->getSurfaceBoxGlobal();
|
||||||
|
if (box && !box->intersection({m->m_position, m->m_size}).empty()) {
|
||||||
|
if (m->m_tearingState.activelyTearing)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (auto& m : m_enteredOutputs) {
|
||||||
|
if (!m)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (m->m_tearingState.activelyTearing)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CWLSurfaceResource::updateCursorShm(CRegion damage) {
|
void CWLSurfaceResource::updateCursorShm(CRegion damage) {
|
||||||
if (damage.empty())
|
if (damage.empty())
|
||||||
return;
|
return;
|
||||||
|
|
@ -670,8 +694,14 @@ void CWLSurfaceResource::presentFeedback(const Time::steady_tp& when, PHLMONITOR
|
||||||
FEEDBACK->attachMonitor(pMonitor);
|
FEEDBACK->attachMonitor(pMonitor);
|
||||||
if (discarded)
|
if (discarded)
|
||||||
FEEDBACK->discarded();
|
FEEDBACK->discarded();
|
||||||
else
|
else {
|
||||||
FEEDBACK->presented();
|
FEEDBACK->presented();
|
||||||
|
if (!pMonitor->m_lastScanout.expired()) {
|
||||||
|
const auto WINDOW = m_hlSurface ? Desktop::View::CWindow::fromView(m_hlSurface->view()) : nullptr;
|
||||||
|
if (WINDOW == pMonitor->m_lastScanout)
|
||||||
|
FEEDBACK->setPresentationType(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
PROTO::presentation->queueData(std::move(FEEDBACK));
|
PROTO::presentation->queueData(std::move(FEEDBACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,7 @@ class CWLSurfaceResource {
|
||||||
NColorManagement::PImageDescription getPreferredImageDescription();
|
NColorManagement::PImageDescription getPreferredImageDescription();
|
||||||
void sortSubsurfaces();
|
void sortSubsurfaces();
|
||||||
bool hasVisibleSubsurface();
|
bool hasVisibleSubsurface();
|
||||||
|
bool isTearing();
|
||||||
|
|
||||||
// returns a pair: found surface (null if not found) and surface local coords.
|
// returns a pair: found surface (null if not found) and surface local coords.
|
||||||
// localCoords param is relative to 0,0 of this surface
|
// localCoords param is relative to 0,0 of this surface
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,9 @@ void SSurfaceState::reset() {
|
||||||
barrierSet = false;
|
barrierSet = false;
|
||||||
surfaceLocked = false;
|
surfaceLocked = false;
|
||||||
fifoScheduled = false;
|
fifoScheduled = false;
|
||||||
|
|
||||||
|
pendingTimeout.reset();
|
||||||
|
timer.reset(); // CEventLoopManager::nudgeTimers should handle it eventually
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSurfaceState::updateFrom(SSurfaceState& ref) {
|
void SSurfaceState::updateFrom(SSurfaceState& ref) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../helpers/math/Math.hpp"
|
#include "../../helpers/math/Math.hpp"
|
||||||
|
#include "../../helpers/time/Time.hpp"
|
||||||
|
#include "../../managers/eventLoop/EventLoopTimer.hpp"
|
||||||
#include "../WaylandProtocol.hpp"
|
#include "../WaylandProtocol.hpp"
|
||||||
#include "./Buffer.hpp"
|
#include "./Buffer.hpp"
|
||||||
|
|
||||||
|
|
@ -94,6 +96,10 @@ struct SSurfaceState {
|
||||||
bool surfaceLocked = false;
|
bool surfaceLocked = false;
|
||||||
bool fifoScheduled = false;
|
bool fifoScheduled = false;
|
||||||
|
|
||||||
|
// commit timing
|
||||||
|
std::optional<Time::steady_dur> pendingTimeout;
|
||||||
|
SP<CEventLoopTimer> timer;
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
CRegion accumulateBufferDamage(); // transforms state.damage and merges it into state.bufferDamage
|
CRegion accumulateBufferDamage(); // transforms state.damage and merges it into state.bufferDamage
|
||||||
void updateFrom(SSurfaceState& ref); // updates this state based on a reference state.
|
void updateFrom(SSurfaceState& ref); // updates this state based on a reference state.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue