File indexing completed on 2024-11-10 04:56:26

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2021 Xaver Hugl <xaver.hugl@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include "drm_abstract_output.h"
0010 #include "core/renderbackend.h"
0011 #include "drm_backend.h"
0012 #include "drm_gpu.h"
0013 #include "drm_layer.h"
0014 
0015 namespace KWin
0016 {
0017 
0018 DrmAbstractOutput::DrmAbstractOutput(DrmGpu *gpu)
0019     : Output(gpu->platform())
0020     , m_renderLoop(std::make_unique<RenderLoop>(this))
0021     , m_gpu(gpu)
0022 {
0023 }
0024 
0025 RenderLoop *DrmAbstractOutput::renderLoop() const
0026 {
0027     return m_renderLoop.get();
0028 }
0029 
0030 void DrmAbstractOutput::frameFailed() const
0031 {
0032     m_frame->failed();
0033 }
0034 
0035 void DrmAbstractOutput::pageFlipped(std::chrono::nanoseconds timestamp, PresentationMode mode)
0036 {
0037     const auto gpuTime = primaryLayer() ? primaryLayer()->queryRenderTime() : std::chrono::nanoseconds::zero();
0038     m_frame->presented(std::chrono::nanoseconds(1'000'000'000'000 / refreshRate()), timestamp, gpuTime, mode);
0039     m_frame.reset();
0040 }
0041 
0042 DrmGpu *DrmAbstractOutput::gpu() const
0043 {
0044     return m_gpu;
0045 }
0046 
0047 void DrmAbstractOutput::updateEnabled(bool enabled)
0048 {
0049     State next = m_state;
0050     next.enabled = enabled;
0051     setState(next);
0052 }
0053 
0054 }
0055 
0056 #include "moc_drm_abstract_output.cpp"