KWin
Loading...
Searching...
No Matches
src
utils
damagejournal.h
Go to the documentation of this file.
1
/*
2
SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4
SPDX-License-Identifier: GPL-2.0-or-later
5
*/
6
7
#pragma once
8
9
#include "kwin_export.h"
10
11
#include <QList>
12
#include <QRegion>
13
14
namespace
KWin
15
{
16
20
class
KWIN_EXPORT
DamageJournal
21
{
22
public
:
26
int
capacity
()
const
27
{
28
return
m_capacity;
29
}
30
35
void
setCapacity
(
int
capacity)
36
{
37
m_capacity = capacity;
38
}
39
43
void
add
(
const
QRegion ®ion)
44
{
45
while
(m_log.size() >= m_capacity) {
46
m_log.takeLast();
47
}
48
m_log.prepend(region);
49
}
50
55
void
clear
()
56
{
57
m_log.clear();
58
}
59
66
QRegion
accumulate
(
int
bufferAge,
const
QRegion &fallback = QRegion())
const
67
{
68
QRegion region;
69
if
(bufferAge > 0 && bufferAge <= m_log.size()) {
70
for
(
int
i = 0; i < bufferAge - 1; ++i) {
71
region += m_log[i];
72
}
73
}
else
{
74
region = fallback;
75
}
76
return
region;
77
}
78
79
QRegion
lastDamage
()
const
80
{
81
return
m_log.first();
82
}
83
84
private
:
85
QList<QRegion> m_log;
86
int
m_capacity = 10;
87
};
88
89
}
// namespace KWin
KWin::DamageJournal
Definition
damagejournal.h:21
KWin::DamageJournal::setCapacity
void setCapacity(int capacity)
Definition
damagejournal.h:35
KWin::DamageJournal::add
void add(const QRegion ®ion)
Definition
damagejournal.h:43
KWin::DamageJournal::accumulate
QRegion accumulate(int bufferAge, const QRegion &fallback=QRegion()) const
Definition
damagejournal.h:66
KWin::DamageJournal::lastDamage
QRegion lastDamage() const
Definition
damagejournal.h:79
KWin::DamageJournal::clear
void clear()
Definition
damagejournal.h:55
KWin::DamageJournal::capacity
int capacity() const
Definition
damagejournal.h:26
KWin
Definition
activation_test.cpp:20
Generated on Sat Feb 17 2024 01:42:10 for KWin by
1.10.0