Coverage Report

Created: 2025-07-23 06:48

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