KWin
Loading...
Searching...
No Matches
swapchain.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2023 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
8
9namespace KWin
10{
11namespace QPA
12{
13
15 : m_allocator(allocator)
16 , m_allocationOptions(options)
17{
18 m_buffers.push_back(initialBuffer);
19}
20
22{
23 for (GraphicsBuffer *buffer : std::as_const(m_buffers)) {
24 buffer->drop();
25 }
26}
27
28QSize Swapchain::size() const
29{
30 return m_allocationOptions.size;
31}
32
34{
35 for (GraphicsBuffer *buffer : std::as_const(m_buffers)) {
36 if (!buffer->isReferenced()) {
37 return buffer;
38 }
39 }
40
41 GraphicsBuffer *buffer = m_allocator->allocate(m_allocationOptions);
42 if (!buffer) {
43 return nullptr;
44 }
45
46 m_buffers.append(buffer);
47 return buffer;
48}
49
50uint32_t Swapchain::format() const
51{
52 return m_allocationOptions.format;
53}
54
55QList<uint64_t> Swapchain::modifiers() const
56{
57 return m_allocationOptions.modifiers;
58}
59}
60}
virtual GraphicsBuffer * allocate(const GraphicsBufferOptions &options)=0
GraphicsBuffer * acquire()
Definition swapchain.cpp:33
Swapchain(GraphicsBufferAllocator *allocator, const GraphicsBufferOptions &options, GraphicsBuffer *initialBuffer)
Definition swapchain.cpp:14
QSize size() const
Definition swapchain.cpp:28
QList< uint64_t > modifiers() const
Definition swapchain.cpp:55
uint32_t format() const
Definition swapchain.cpp:50
Options * options
Definition main.cpp:73
uint32_t format
The pixel format of the buffer, see DRM_FORMAT_*.
QList< uint64_t > modifiers
An optional list of modifiers, see DRM_FORMAT_MOD_*.
QSize size
The size of the buffer, in device pixels.