KWin
Loading...
Searching...
No Matches
drm_egl_cursor_layer.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
10#include "core/iccprofile.h"
11#include "drm_buffer.h"
12#include "drm_egl_backend.h"
13#include "drm_gpu.h"
14#include "drm_output.h"
15#include "drm_pipeline.h"
16
17#include <gbm.h>
18
19namespace KWin
20{
21
22static OutputTransform drmToOutputTransform(DrmPipeline *pipeline)
23{
24 auto angle = DrmPlane::transformationToDegrees(pipeline->renderOrientation());
25 if (angle < 0) {
26 angle += 360;
27 }
28 OutputTransform flip = (pipeline->renderOrientation() & DrmPlane::Transformation::ReflectX) ? OutputTransform::FlipX : OutputTransform();
29 switch (angle % 360) {
30 case 0:
31 return flip;
32 case 90:
33 return flip.combine(OutputTransform::Rotate90);
34 case 180:
35 return flip.combine(OutputTransform::Rotate180);
36 case 270:
37 return flip.combine(OutputTransform::Rotate270);
38 default:
39 Q_UNREACHABLE();
40 }
41}
42
44 : DrmPipelineLayer(pipeline)
45 , m_surface(pipeline->gpu(), eglBackend, pipeline->gpu()->atomicModeSetting() ? EglGbmLayerSurface::BufferTarget::Linear : EglGbmLayerSurface::BufferTarget::Dumb, EglGbmLayerSurface::FormatOption::RequireAlpha)
46{
47}
48
49std::optional<OutputLayerBeginFrameInfo> EglGbmCursorLayer::beginFrame()
50{
51 // note that this allows blending to happen in sRGB or PQ encoding.
52 // That's technically incorrect, but it looks okay and is intentionally allowed
53 // as the hardware cursor is more important than an incorrectly blended cursor edge
55}
56
57bool EglGbmCursorLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion)
58{
59 return m_surface.endRendering(damagedRegion);
60}
61
63{
64 return {};
65}
66
67std::shared_ptr<DrmFramebuffer> EglGbmCursorLayer::currentBuffer() const
68{
69 return m_surface.currentBuffer();
70}
71
73{
74 return false;
75}
76
81
82std::chrono::nanoseconds EglGbmCursorLayer::queryRenderTime() const
83{
84 return m_surface.queryRenderTime();
85}
86
87std::optional<QSize> EglGbmCursorLayer::fixedSize() const
88{
89 return m_pipeline->gpu()->cursorSize();
90}
91}
QSize cursorSize() const
Definition drm_gpu.cpp:801
bool needsColormanagement() const
QVector3D channelFactors() const
QMap< uint32_t, QList< uint64_t > > cursorFormats() const
DrmOutput * output() const
const std::shared_ptr< IccProfile > & iccProfile() const
DrmGpu * gpu() const
const ColorDescription & colorDescription() const
DrmPipeline *const m_pipeline
Definition drm_layer.h:44
static int32_t transformationToDegrees(Transformations transformation)
OpenGL Backend using Egl on a GBM surface.
std::chrono::nanoseconds queryRenderTime() const override
QRegion currentDamage() const override
std::optional< OutputLayerBeginFrameInfo > beginFrame() override
EglGbmCursorLayer(EglGbmBackend *eglBackend, DrmPipeline *pipeline)
std::optional< QSize > fixedSize() const override
std::shared_ptr< DrmFramebuffer > currentBuffer() const override
bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override
std::optional< OutputLayerBeginFrameInfo > startRendering(const QSize &bufferSize, OutputTransform transformation, const QMap< uint32_t, QList< uint64_t > > &formats, const ColorDescription &colorDescription, const QVector3D &channelFactors, const std::shared_ptr< IccProfile > &iccProfile, bool enableColormanagement)
std::chrono::nanoseconds queryRenderTime() const
bool endRendering(const QRegion &damagedRegion)
std::shared_ptr< DrmFramebuffer > currentBuffer() const