Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KWin
Commits
eea94660
Commit
eea94660
authored
Feb 14, 2022
by
Vlad Zahorodnii
Browse files
utils: Extract DamageJournal in its own file
parent
dece547a
Pipeline
#137656
passed with stage
in 12 minutes and 58 seconds
Changes
9
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/backends/drm/dumb_swapchain.h
View file @
eea94660
...
...
@@ -9,7 +9,7 @@
#pragma once
#include
"utils/
common
.h"
#include
"utils/
damagejournal
.h"
#include
<QVector>
#include
<QSize>
...
...
src/backends/drm/egl_gbm_backend.h
View file @
eea94660
...
...
@@ -9,7 +9,6 @@
#ifndef KWIN_EGL_GBM_BACKEND_H
#define KWIN_EGL_GBM_BACKEND_H
#include
"abstract_egl_backend.h"
#include
"utils/common.h"
#include
<kwinglutils.h>
...
...
src/backends/drm/gbm_surface.h
View file @
eea94660
...
...
@@ -15,7 +15,7 @@
#include
<optional>
#include
"drm_buffer_gbm.h"
#include
"utils/
common
.h"
#include
"utils/
damagejournal
.h"
struct
gbm_device
;
struct
gbm_surface
;
...
...
src/backends/wayland/egl_wayland_backend.h
View file @
eea94660
...
...
@@ -10,7 +10,7 @@
#ifndef KWIN_EGL_WAYLAND_BACKEND_H
#define KWIN_EGL_WAYLAND_BACKEND_H
#include
"abstract_egl_backend.h"
#include
"utils/
common
.h"
#include
"utils/
damagejournal
.h"
// wayland
#include
<wayland-egl.h>
...
...
src/backends/wayland/scene_qpainter_wayland_backend.h
View file @
eea94660
...
...
@@ -11,7 +11,7 @@
#define KWIN_SCENE_QPAINTER_WAYLAND_BACKEND_H
#include
"qpainterbackend.h"
#include
"utils/
common
.h"
#include
"utils/
damagejournal
.h"
#include
<QObject>
#include
<QImage>
...
...
src/backends/x11/standalone/eglbackend.h
View file @
eea94660
...
...
@@ -8,7 +8,7 @@
#include
"eglonxbackend.h"
#include
"openglsurfacetexture_x11.h"
#include
"utils/
common
.h"
#include
"utils/
damagejournal
.h"
#include
<kwingltexture.h>
#include
<kwingltexture_p.h>
...
...
src/backends/x11/standalone/glxbackend.h
View file @
eea94660
...
...
@@ -11,7 +11,7 @@
#include
"openglbackend.h"
#include
"openglsurfacetexture_x11.h"
#include
"x11eventfilter.h"
#include
"utils/
common
.h"
#include
"utils/
damagejournal
.h"
#include
<xcb/glx.h>
#include
<epoxy/glx.h>
...
...
src/utils/common.h
View file @
eea94660
...
...
@@ -154,73 +154,6 @@ Qt::MouseButton KWIN_EXPORT x11ToQtMouseButton(int button);
Qt
::
MouseButtons
KWIN_EXPORT
x11ToQtMouseButtons
(
int
state
);
Qt
::
KeyboardModifiers
KWIN_EXPORT
x11ToQtKeyboardModifiers
(
int
state
);
/**
* The DamageJournal class is a helper that tracks last N damage regions.
*/
class
KWIN_EXPORT
DamageJournal
{
public:
/**
* Returns the maximum number of damage regions that can be stored in the journal.
*/
int
capacity
()
const
{
return
m_capacity
;
}
/**
* Sets the maximum number of damage regions that can be stored in the journal
* to @a capacity.
*/
void
setCapacity
(
int
capacity
)
{
m_capacity
=
capacity
;
}
/**
* Adds the specified @a region to the journal.
*/
void
add
(
const
QRegion
&
region
)
{
while
(
m_log
.
size
()
>=
m_capacity
)
{
m_log
.
takeLast
();
}
m_log
.
prepend
(
region
);
}
/**
* Clears the damage journal. Typically, one would want to clear the damage journal
* if a buffer swap fails for some reason.
*/
void
clear
()
{
m_log
.
clear
();
}
/**
* Accumulates the damage regions in the log up to the specified @a bufferAge.
*
* If the specified buffer age value refers to a damage region older than the last
* one in the journal, @a fallback will be returned.
*/
QRegion
accumulate
(
int
bufferAge
,
const
QRegion
&
fallback
=
QRegion
())
const
{
QRegion
region
;
if
(
bufferAge
>
0
&&
bufferAge
<=
m_log
.
size
())
{
for
(
int
i
=
0
;
i
<
bufferAge
-
1
;
++
i
)
{
region
|=
m_log
[
i
];
}
}
else
{
region
=
fallback
;
}
return
region
;
}
private:
QList
<
QRegion
>
m_log
;
int
m_capacity
=
10
;
};
KWIN_EXPORT
QPoint
popupOffset
(
const
QRect
&
anchorRect
,
const
Qt
::
Edges
anchorEdge
,
const
Qt
::
Edges
gravity
,
const
QSize
popupSize
);
}
// namespace
...
...
src/utils/damagejournal.h
0 → 100644
View file @
eea94660
/*
SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include
"kwin_export.h"
#include
<QRegion>
namespace
KWin
{
/**
* The DamageJournal class is a helper that tracks last N damage regions.
*/
class
KWIN_EXPORT
DamageJournal
{
public:
/**
* Returns the maximum number of damage regions that can be stored in the journal.
*/
int
capacity
()
const
{
return
m_capacity
;
}
/**
* Sets the maximum number of damage regions that can be stored in the journal
* to @a capacity.
*/
void
setCapacity
(
int
capacity
)
{
m_capacity
=
capacity
;
}
/**
* Adds the specified @a region to the journal.
*/
void
add
(
const
QRegion
&
region
)
{
while
(
m_log
.
size
()
>=
m_capacity
)
{
m_log
.
takeLast
();
}
m_log
.
prepend
(
region
);
}
/**
* Clears the damage journal. Typically, one would want to clear the damage journal
* if a buffer swap fails for some reason.
*/
void
clear
()
{
m_log
.
clear
();
}
/**
* Accumulates the damage regions in the log up to the specified @a bufferAge.
*
* If the specified buffer age value refers to a damage region older than the last
* one in the journal, @a fallback will be returned.
*/
QRegion
accumulate
(
int
bufferAge
,
const
QRegion
&
fallback
=
QRegion
())
const
{
QRegion
region
;
if
(
bufferAge
>
0
&&
bufferAge
<=
m_log
.
size
())
{
for
(
int
i
=
0
;
i
<
bufferAge
-
1
;
++
i
)
{
region
|=
m_log
[
i
];
}
}
else
{
region
=
fallback
;
}
return
region
;
}
private:
QList
<
QRegion
>
m_log
;
int
m_capacity
=
10
;
};
}
// namespace KWin
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment