File indexing completed on 2025-04-20 10:57:36

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 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include "drm_qpainter_backend.h"
0010 #include "core/renderloop_p.h"
0011 #include "drm_backend.h"
0012 #include "drm_buffer.h"
0013 #include "drm_gpu.h"
0014 #include "drm_output.h"
0015 #include "drm_pipeline.h"
0016 #include "drm_qpainter_layer.h"
0017 #include "drm_virtual_output.h"
0018 
0019 #include <drm_fourcc.h>
0020 
0021 namespace KWin
0022 {
0023 
0024 DrmQPainterBackend::DrmQPainterBackend(DrmBackend *backend)
0025     : QPainterBackend()
0026     , m_backend(backend)
0027 {
0028     m_backend->setRenderBackend(this);
0029 }
0030 
0031 DrmQPainterBackend::~DrmQPainterBackend()
0032 {
0033     m_backend->releaseBuffers();
0034     m_backend->setRenderBackend(nullptr);
0035 }
0036 
0037 void DrmQPainterBackend::present(Output *output)
0038 {
0039     static_cast<DrmAbstractOutput *>(output)->present();
0040 }
0041 
0042 OutputLayer *DrmQPainterBackend::primaryLayer(Output *output)
0043 {
0044     return static_cast<DrmAbstractOutput *>(output)->primaryLayer();
0045 }
0046 
0047 std::shared_ptr<DrmPipelineLayer> DrmQPainterBackend::createPrimaryLayer(DrmPipeline *pipeline)
0048 {
0049     return std::make_shared<DrmQPainterLayer>(pipeline);
0050 }
0051 
0052 std::shared_ptr<DrmOverlayLayer> DrmQPainterBackend::createCursorLayer(DrmPipeline *pipeline)
0053 {
0054     return std::make_shared<DrmCursorQPainterLayer>(pipeline);
0055 }
0056 
0057 std::shared_ptr<DrmOutputLayer> DrmQPainterBackend::createLayer(DrmVirtualOutput *output)
0058 {
0059     return std::make_shared<DrmVirtualQPainterLayer>(output);
0060 }
0061 
0062 }