File indexing completed on 2024-06-23 05:25:10

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
0006     SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 #pragma once
0011 
0012 #include "core/graphicsbuffer.h"
0013 #include "utils/filedescriptor.h"
0014 
0015 #include <chrono>
0016 
0017 namespace KWin
0018 {
0019 
0020 class DrmGpu;
0021 class DrmFramebuffer;
0022 
0023 class DrmFramebuffer
0024 {
0025 public:
0026     DrmFramebuffer(DrmGpu *gpu, uint32_t fbId, GraphicsBuffer *buffer, FileDescriptor &&readFence);
0027     ~DrmFramebuffer();
0028 
0029     uint32_t framebufferId() const;
0030     /**
0031      * may be nullptr
0032      */
0033     GraphicsBuffer *buffer() const;
0034 
0035     void releaseBuffer();
0036     bool isReadable();
0037 
0038     const FileDescriptor &syncFd() const;
0039     void setDeadline(std::chrono::steady_clock::time_point deadline);
0040 
0041 protected:
0042     const uint32_t m_framebufferId;
0043     DrmGpu *const m_gpu;
0044     GraphicsBufferRef m_bufferRef;
0045     bool m_readable = false;
0046     FileDescriptor m_syncFd;
0047 };
0048 
0049 }