Krita Source Code Documentation
Loading...
Searching...
No Matches
KisRepaintDebugger.cpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2022 Alvin Wong <alvin@alvinhc.com>
3
*
4
* SPDX-License-Identifier: GPL-3.0-or-later
5
*/
6
7
#include "
KisRepaintDebugger.h
"
8
9
#include <KLocalizedString>
10
11
#include <QPaintDevice>
12
#include <QPainter>
13
#include <QPaintEvent>
14
#include <QThread>
15
#include <QApplication>
16
#include <QMessageBox>
17
#include <QDebug>
18
19
bool
KisRepaintDebugger::enabled
()
20
{
21
static
bool
enabled
= qEnvironmentVariableIntValue(
"KRITA_DEBUG_REPAINT"
) == 1;
22
return
enabled
;
23
}
24
25
void
KisRepaintDebugger::paint
(QPaintDevice *paintDevice,
const
QRect &widgetRect)
26
{
27
paint
(paintDevice, &widgetRect, 1);
28
}
29
30
void
KisRepaintDebugger::paint
(QPaintDevice *paintDevice,
const
QVector<QRect>
&widgetRects)
31
{
32
paint
(paintDevice, widgetRects.constData(), widgetRects.size());
33
}
34
35
void
KisRepaintDebugger::paint
(QPaintDevice *paintDevice,
const
QPaintEvent *event)
36
{
37
paint
(paintDevice, event->rect());
38
}
39
40
void
KisRepaintDebugger::paintFull
(QPaintDevice *pd)
41
{
42
if
(!
enabled
()) {
43
return
;
44
}
45
const
QRect
rect
= QRectF(QPointF(), QSizeF(pd->width(), pd->height()) * pd->devicePixelRatioF())
46
.toAlignedRect();
47
paint
(pd, &
rect
, 1);
48
}
49
50
void
KisRepaintDebugger::paint
(QPaintDevice *paintDevice,
const
QRect *widgetRects,
size_t
count)
51
{
52
if
(!
enabled
()) {
53
return
;
54
}
55
constexpr
int
ALPHA
= 63;
56
static
QVector<QColor>
colors {
57
QColor(255, 0, 0,
ALPHA
),
58
QColor(0, 255, 0,
ALPHA
),
59
QColor(0, 0, 255,
ALPHA
),
60
QColor(255, 255, 0,
ALPHA
),
61
QColor(255, 0, 255,
ALPHA
),
62
QColor(0, 255, 255,
ALPHA
),
63
};
64
m_colorIndex
= (
m_colorIndex
+ 1) % colors.size();
65
QPainter gc(paintDevice);
66
for
(
size_t
i = 0; i < count; i++) {
67
gc.fillRect(widgetRects[i], colors[
m_colorIndex
]);
68
}
69
}
KisRepaintDebugger.h
KisRepaintDebugger::paint
void paint(QPaintDevice *paintDevice, const QRect &widgetRect)
Definition
KisRepaintDebugger.cpp:25
KisRepaintDebugger::paintFull
void paintFull(QPaintDevice *paintDevice)
Definition
KisRepaintDebugger.cpp:40
KisRepaintDebugger::m_colorIndex
unsigned int m_colorIndex
Definition
KisRepaintDebugger.h:57
KisRepaintDebugger::enabled
static bool enabled()
Definition
KisRepaintDebugger.cpp:19
QList
Definition
KisQStringListFwd.h:16
ALPHA
#define ALPHA(rgba)
Definition
pixels.h:51
rect
Definition
xcftools.h:129
libs
widgetutils
KisRepaintDebugger.cpp
Generated at
2026-01-15 02:30:07+01:00
from
Krita
branch
master
, commit
38b517ca06286bb65279453cbf9a2b4fbd1153d1