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

0001 /*
0002     SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "renderbackend.h"
0008 #include "renderloop_p.h"
0009 #include "scene/surfaceitem.h"
0010 
0011 #include <drm_fourcc.h>
0012 
0013 namespace KWin
0014 {
0015 
0016 OutputFrame::OutputFrame(RenderLoop *loop)
0017     : m_loop(loop)
0018 {
0019 }
0020 
0021 OutputFrame::~OutputFrame() = default;
0022 
0023 void OutputFrame::addFeedback(std::unique_ptr<PresentationFeedback> &&feedback)
0024 {
0025     m_feedbacks.push_back(std::move(feedback));
0026 }
0027 
0028 void OutputFrame::presented(std::chrono::nanoseconds refreshDuration, std::chrono::nanoseconds timestamp, std::chrono::nanoseconds renderTime, PresentationMode mode)
0029 {
0030     RenderLoopPrivate::get(m_loop)->notifyFrameCompleted(timestamp, renderTime, mode);
0031     for (const auto &feedback : m_feedbacks) {
0032         feedback->presented(refreshDuration, timestamp, mode);
0033     }
0034 }
0035 
0036 void OutputFrame::failed()
0037 {
0038     RenderLoopPrivate::get(m_loop)->notifyFrameFailed();
0039 }
0040 
0041 void OutputFrame::setContentType(ContentType type)
0042 {
0043     m_contentType = type;
0044 }
0045 
0046 std::optional<ContentType> OutputFrame::contentType() const
0047 {
0048     return m_contentType;
0049 }
0050 
0051 void OutputFrame::setPresentationMode(PresentationMode mode)
0052 {
0053     m_presentationMode = mode;
0054 }
0055 
0056 PresentationMode OutputFrame::presentationMode() const
0057 {
0058     return m_presentationMode;
0059 }
0060 
0061 RenderBackend::RenderBackend(QObject *parent)
0062     : QObject(parent)
0063 {
0064 }
0065 
0066 OutputLayer *RenderBackend::cursorLayer(Output *output)
0067 {
0068     return nullptr;
0069 }
0070 
0071 OverlayWindow *RenderBackend::overlayWindow() const
0072 {
0073     return nullptr;
0074 }
0075 
0076 bool RenderBackend::checkGraphicsReset()
0077 {
0078     return false;
0079 }
0080 
0081 GraphicsBufferAllocator *RenderBackend::graphicsBufferAllocator() const
0082 {
0083     return nullptr;
0084 }
0085 
0086 bool RenderBackend::testImportBuffer(GraphicsBuffer *buffer)
0087 {
0088     return false;
0089 }
0090 
0091 QHash<uint32_t, QList<uint64_t>> RenderBackend::supportedFormats() const
0092 {
0093     return QHash<uint32_t, QList<uint64_t>>{{DRM_FORMAT_XRGB8888, QList<uint64_t>{DRM_FORMAT_MOD_LINEAR}}};
0094 }
0095 
0096 std::unique_ptr<SurfaceTexture> RenderBackend::createSurfaceTextureX11(SurfacePixmapX11 *pixmap)
0097 {
0098     return nullptr;
0099 }
0100 
0101 std::unique_ptr<SurfaceTexture> RenderBackend::createSurfaceTextureWayland(SurfacePixmap *pixmap)
0102 {
0103     return nullptr;
0104 }
0105 
0106 } // namespace KWin
0107 
0108 #include "moc_renderbackend.cpp"