KWin
Loading...
Searching...
No Matches
virtual_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: 2015 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include "core/outputlayer.h"
13#include <chrono>
14#include <memory>
15
16namespace KWin
17{
18
19class EglSwapchainSlot;
20class EglSwapchain;
21class GraphicsBufferAllocator;
22class VirtualBackend;
23class GLFramebuffer;
24class GLTexture;
25class VirtualEglBackend;
26class GLRenderTimeQuery;
27
29{
30public:
31 VirtualEglLayer(Output *output, VirtualEglBackend *backend);
32
33 std::optional<OutputLayerBeginFrameInfo> beginFrame() override;
34 bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override;
35
36 std::shared_ptr<GLTexture> texture() const;
37 std::chrono::nanoseconds queryRenderTime() const override;
38
39private:
40 VirtualEglBackend *const m_backend;
41 Output *m_output;
42 std::shared_ptr<EglSwapchain> m_swapchain;
43 std::shared_ptr<EglSwapchainSlot> m_current;
44 std::unique_ptr<GLRenderTimeQuery> m_query;
45};
46
51{
52 Q_OBJECT
53
54public:
56 ~VirtualEglBackend() override;
57 std::unique_ptr<SurfaceTexture> createSurfaceTextureWayland(SurfacePixmap *pixmap) override;
58 std::pair<std::shared_ptr<KWin::GLTexture>, ColorDescription> textureForOutput(Output *output) const override;
59 OutputLayer *primaryLayer(Output *output) override;
60 void present(Output *output, const std::shared_ptr<OutputFrame> &frame) override;
61 void init() override;
62
63 VirtualBackend *backend() const;
65
66private:
67 bool initializeEgl();
68 bool initRenderingContext();
69
70 void addOutput(Output *output);
71 void removeOutput(Output *output);
72
73 VirtualBackend *m_backend;
74 std::unique_ptr<GraphicsBufferAllocator> m_allocator;
75 std::map<Output *, std::unique_ptr<VirtualEglLayer>> m_outputs;
76};
77
78} // namespace KWin
OpenGL Backend using Egl on a GBM surface.
void present(Output *output, const std::shared_ptr< OutputFrame > &frame) override
VirtualEglBackend(VirtualBackend *b)
VirtualBackend * backend() const
std::unique_ptr< SurfaceTexture > createSurfaceTextureWayland(SurfacePixmap *pixmap) override
GraphicsBufferAllocator * graphicsBufferAllocator() const override
OutputLayer * primaryLayer(Output *output) override
std::pair< std::shared_ptr< KWin::GLTexture >, ColorDescription > textureForOutput(Output *output) const override
std::optional< OutputLayerBeginFrameInfo > beginFrame() override
std::shared_ptr< GLTexture > texture() const
bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override
std::chrono::nanoseconds queryRenderTime() const override
VirtualEglLayer(Output *output, VirtualEglBackend *backend)