KWin
Loading...
Searching...
No Matches
wayland_egl_backend.h
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: 2013 Martin Gräßlin <mgraesslin@kde.org>
6 SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10#pragma once
11
12#include "core/outputlayer.h"
14#include "utils/damagejournal.h"
15
16#include <memory>
17
18struct wl_buffer;
19
20namespace KWin
21{
22class EglSwapchainSlot;
23class EglSwapchain;
24class GLFramebuffer;
25class GraphicsBufferAllocator;
26class GLRenderTimeQuery;
27
28namespace Wayland
29{
30class WaylandBackend;
31class WaylandOutput;
32class WaylandEglBackend;
33
35{
36public:
38 ~WaylandEglPrimaryLayer() override;
39
40 GLFramebuffer *fbo() const;
41 std::shared_ptr<GLTexture> texture() const;
42 void present();
43
44 std::optional<OutputLayerBeginFrameInfo> beginFrame() override;
45 bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override;
46 std::chrono::nanoseconds queryRenderTime() const override;
47 bool scanout(SurfaceItem *surfaceItem) override;
48
49private:
50 WaylandOutput *m_waylandOutput;
51 DamageJournal m_damageJournal;
52 std::shared_ptr<EglSwapchain> m_swapchain;
53 std::shared_ptr<EglSwapchainSlot> m_buffer;
54 std::unique_ptr<GLRenderTimeQuery> m_query;
55 WaylandEglBackend *const m_backend;
56 wl_buffer *m_presentationBuffer = nullptr;
57
58 friend class WaylandEglBackend;
59};
60
62{
63 Q_OBJECT
64
65public:
67 ~WaylandEglCursorLayer() override;
68
69 std::optional<OutputLayerBeginFrameInfo> beginFrame() override;
70 bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override;
71 std::chrono::nanoseconds queryRenderTime() const override;
72
73private:
74 WaylandOutput *m_output;
75 WaylandEglBackend *m_backend;
76 std::shared_ptr<EglSwapchain> m_swapchain;
77 std::shared_ptr<EglSwapchainSlot> m_buffer;
78 std::unique_ptr<GLRenderTimeQuery> m_query;
79};
80
94{
95 Q_OBJECT
96public:
98 ~WaylandEglBackend() override;
99
100 WaylandBackend *backend() const;
102
103 std::unique_ptr<SurfaceTexture> createSurfaceTextureWayland(SurfacePixmap *pixmap) override;
104
105 void init() override;
106 void present(Output *output, const std::shared_ptr<OutputFrame> &frame) override;
107 OutputLayer *primaryLayer(Output *output) override;
108 OutputLayer *cursorLayer(Output *output) override;
109
110 std::pair<std::shared_ptr<KWin::GLTexture>, ColorDescription> textureForOutput(KWin::Output *output) const override;
111
112private:
113 bool initializeEgl();
114 bool initRenderingContext();
115 bool createEglWaylandOutput(Output *output);
116 void cleanupSurfaces() override;
117
118 struct Layers
119 {
120 std::unique_ptr<WaylandEglPrimaryLayer> primaryLayer;
121 std::unique_ptr<WaylandEglCursorLayer> cursorLayer;
122 };
123
124 WaylandBackend *m_backend;
125 std::unique_ptr<GraphicsBufferAllocator> m_allocator;
126 std::map<Output *, Layers> m_outputs;
127};
128
129} // namespace Wayland
130} // namespace KWin
OpenGL framebuffer object.
Class encapsulating all Wayland data structures needed by the Egl backend.
OpenGL Backend using Egl on a Wayland surface.
GraphicsBufferAllocator * graphicsBufferAllocator() const override
OutputLayer * cursorLayer(Output *output) override
void present(Output *output, const std::shared_ptr< OutputFrame > &frame) override
OutputLayer * primaryLayer(Output *output) override
std::pair< std::shared_ptr< KWin::GLTexture >, ColorDescription > textureForOutput(KWin::Output *output) const override
std::unique_ptr< SurfaceTexture > createSurfaceTextureWayland(SurfacePixmap *pixmap) override
std::optional< OutputLayerBeginFrameInfo > beginFrame() override
std::chrono::nanoseconds queryRenderTime() const override
bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override
WaylandEglCursorLayer(WaylandOutput *output, WaylandEglBackend *backend)
WaylandEglPrimaryLayer(WaylandOutput *output, WaylandEglBackend *backend)
std::shared_ptr< GLTexture > texture() const
std::optional< OutputLayerBeginFrameInfo > beginFrame() override
bool scanout(SurfaceItem *surfaceItem) override
std::chrono::nanoseconds queryRenderTime() const override
bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override