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

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 "drm_backend.h"
0011 #include "drm_gpu.h"
0012 #include "drm_output.h"
0013 #include "drm_pipeline.h"
0014 #include "drm_qpainter_layer.h"
0015 #include "drm_virtual_output.h"
0016 
0017 #include <drm_fourcc.h>
0018 
0019 namespace KWin
0020 {
0021 
0022 DrmQPainterBackend::DrmQPainterBackend(DrmBackend *backend)
0023     : QPainterBackend()
0024     , m_backend(backend)
0025 {
0026     m_backend->setRenderBackend(this);
0027 }
0028 
0029 DrmQPainterBackend::~DrmQPainterBackend()
0030 {
0031     m_backend->releaseBuffers();
0032     m_backend->setRenderBackend(nullptr);
0033 }
0034 
0035 GraphicsBufferAllocator *DrmQPainterBackend::graphicsBufferAllocator() const
0036 {
0037     return m_backend->primaryGpu()->graphicsBufferAllocator();
0038 }
0039 
0040 void DrmQPainterBackend::present(Output *output, const std::shared_ptr<OutputFrame> &frame)
0041 {
0042     static_cast<DrmAbstractOutput *>(output)->present(frame);
0043 }
0044 
0045 OutputLayer *DrmQPainterBackend::primaryLayer(Output *output)
0046 {
0047     return static_cast<DrmAbstractOutput *>(output)->primaryLayer();
0048 }
0049 
0050 OutputLayer *DrmQPainterBackend::cursorLayer(Output *output)
0051 {
0052     return static_cast<DrmAbstractOutput *>(output)->cursorLayer();
0053 }
0054 
0055 std::shared_ptr<DrmPipelineLayer> DrmQPainterBackend::createPrimaryLayer(DrmPipeline *pipeline)
0056 {
0057     return std::make_shared<DrmQPainterLayer>(pipeline);
0058 }
0059 
0060 std::shared_ptr<DrmPipelineLayer> DrmQPainterBackend::createCursorLayer(DrmPipeline *pipeline)
0061 {
0062     return std::make_shared<DrmCursorQPainterLayer>(pipeline);
0063 }
0064 
0065 std::shared_ptr<DrmOutputLayer> DrmQPainterBackend::createLayer(DrmVirtualOutput *output)
0066 {
0067     return std::make_shared<DrmVirtualQPainterLayer>(output);
0068 }
0069 
0070 }
0071 
0072 #include "moc_drm_qpainter_backend.cpp"