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

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include "drm_egl_cursor_layer.h"
0010 #include "drm_egl_backend.h"
0011 #include "drm_gpu.h"
0012 #include "drm_pipeline.h"
0013 
0014 #include <gbm.h>
0015 
0016 namespace KWin
0017 {
0018 
0019 EglGbmCursorLayer::EglGbmCursorLayer(EglGbmBackend *eglBackend, DrmPipeline *pipeline)
0020     : DrmOverlayLayer(pipeline)
0021     , m_surface(pipeline->gpu(), eglBackend, pipeline->gpu()->atomicModeSetting() ? EglGbmLayerSurface::BufferTarget::Linear : EglGbmLayerSurface::BufferTarget::Dumb, EglGbmLayerSurface::FormatOption::RequireAlpha)
0022 {
0023 }
0024 
0025 std::optional<OutputLayerBeginFrameInfo> EglGbmCursorLayer::beginFrame()
0026 {
0027     return m_surface.startRendering(m_pipeline->gpu()->cursorSize(), m_pipeline->renderOrientation(), DrmPlane::Transformation::Rotate0, m_pipeline->cursorFormats());
0028 }
0029 
0030 void EglGbmCursorLayer::aboutToStartPainting(const QRegion &damagedRegion)
0031 {
0032     m_surface.aboutToStartPainting(m_pipeline->output(), damagedRegion);
0033 }
0034 
0035 bool EglGbmCursorLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion)
0036 {
0037     return m_surface.endRendering(m_pipeline->renderOrientation(), damagedRegion);
0038 }
0039 
0040 QRegion EglGbmCursorLayer::currentDamage() const
0041 {
0042     return {};
0043 }
0044 
0045 std::shared_ptr<DrmFramebuffer> EglGbmCursorLayer::currentBuffer() const
0046 {
0047     return m_surface.currentBuffer();
0048 }
0049 
0050 bool EglGbmCursorLayer::checkTestBuffer()
0051 {
0052     return false;
0053 }
0054 
0055 void EglGbmCursorLayer::releaseBuffers()
0056 {
0057     m_surface.destroyResources();
0058 }
0059 
0060 }