Coverage Report

Created: 2026-05-31 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/kernel/qpaintdevicewindow_p.h
Line
Count
Source
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#ifndef QPAINTDEVICEWINDOW_P_H
6
#define QPAINTDEVICEWINDOW_P_H
7
8
//
9
//  W A R N I N G
10
//  -------------
11
//
12
// This file is not part of the Qt API.  It exists purely as an
13
// implementation detail.  This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#include <QtGui/private/qtguiglobal_p.h>
20
#include <QtGui/QPaintDeviceWindow>
21
#include <QtCore/QCoreApplication>
22
#include <QtGui/private/qwindow_p.h>
23
#include <QtGui/QPaintEvent>
24
25
QT_BEGIN_NAMESPACE
26
27
class Q_GUI_EXPORT QPaintDeviceWindowPrivate : public QWindowPrivate
28
{
29
0
    Q_DECLARE_PUBLIC(QPaintDeviceWindow)
30
0
31
0
public:
32
0
    QPaintDeviceWindowPrivate();
33
0
    ~QPaintDeviceWindowPrivate() override;
34
0
35
0
    virtual void handleResizeEvent() {}
36
37
    virtual void beginPaint(const QRegion &region)
38
0
    {
39
0
        Q_UNUSED(region);
40
0
    }
41
42
    virtual void endPaint()
43
0
    {
44
0
    }
45
46
    virtual void flush(const QRegion &region)
47
0
    {
48
0
        Q_UNUSED(region);
49
0
    }
50
51
    bool paint(const QRegion &region)
52
0
    {
53
0
        Q_Q(QPaintDeviceWindow);
54
0
        QRegion toPaint = region & dirtyRegion;
55
0
        if (toPaint.isEmpty())
56
0
            return false;
57
58
        // Clear the region now. The overridden functions may call update().
59
0
        dirtyRegion -= toPaint;
60
61
0
        beginPaint(toPaint);
62
63
0
        QPaintEvent paintEvent(toPaint);
64
0
        q->paintEvent(&paintEvent);
65
66
0
        endPaint();
67
68
0
        return true;
69
0
    }
70
71
    void doFlush(const QRegion &region)
72
0
    {
73
0
        QRegion toFlush = region;
74
0
        if (paint(toFlush))
75
0
            flush(toFlush);
76
0
    }
77
78
    void handleUpdateEvent()
79
0
    {
80
0
        if (dirtyRegion.isEmpty())
81
0
            return;
82
0
        doFlush(dirtyRegion);
83
0
    }
84
85
    void markWindowAsDirty()
86
0
    {
87
        Q_Q(QPaintDeviceWindow);
88
0
        dirtyRegion = QRect(QPoint(0, 0), q->size());
89
0
    }
90
91
private:
92
    QRegion dirtyRegion;
93
};
94
95
96
QT_END_NAMESPACE
97
98
#endif //QPAINTDEVICEWINDOW_P_H