Coverage Report

Created: 2026-08-25 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/painting/qpaintengine_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 QPAINTENGINE_P_H
6
#define QPAINTENGINE_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 for the convenience
13
// of other Qt classes.  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/qpainter.h"
21
#include "QtGui/qpaintengine.h"
22
#include "QtGui/qregion.h"
23
#include "private/qobject_p.h"
24
25
QT_BEGIN_NAMESPACE
26
27
class QPaintDevice;
28
29
class Q_GUI_EXPORT QPaintEnginePrivate
30
{
31
0
    Q_DECLARE_PUBLIC(QPaintEngine)
Unexecuted instantiation: QPaintEnginePrivate::q_func()
Unexecuted instantiation: QPaintEnginePrivate::q_func() const
32
0
public:
33
0
    QPaintEnginePrivate() : pdev(nullptr), q_ptr(nullptr), currentClipDevice(nullptr), hasSystemTransform(0),
34
0
                            hasSystemViewport(0) {}
35
    virtual ~QPaintEnginePrivate();
36
37
    QPaintDevice *pdev;
38
    QPaintEngine *q_ptr;
39
    QRegion baseSystemClip;
40
    QRegion systemClip;
41
    QRect systemRect;
42
    QRegion systemViewport;
43
    QTransform systemTransform;
44
    QPaintDevice *currentClipDevice;
45
    uint hasSystemTransform : 1;
46
    uint hasSystemViewport : 1;
47
48
    inline void updateSystemClip()
49
0
    {
50
0
        systemClip = baseSystemClip;
51
0
        if (systemClip.isEmpty())
52
0
            return;
53
54
0
        if (hasSystemTransform) {
55
0
            if (systemTransform.type() <= QTransform::TxTranslate)
56
0
                systemClip.translate(qRound(systemTransform.dx()), qRound(systemTransform.dy()));
57
0
            else
58
0
                systemClip = systemTransform.map(systemClip);
59
0
        }
60
61
        // Make sure we're inside the viewport.
62
0
        if (hasSystemViewport) {
63
0
            systemClip &= systemViewport;
64
0
            if (systemClip.isEmpty()) {
65
                // We don't want to paint without system clip, so set it to 1 pixel :)
66
0
                systemClip = QRect(systemViewport.boundingRect().topLeft(), QSize(1, 1));
67
0
            }
68
0
        }
69
0
    }
70
71
    inline void setSystemTransform(const QTransform &xform)
72
0
    {
73
0
        systemTransform = xform;
74
0
        hasSystemTransform = !xform.isIdentity();
75
0
        updateSystemClip();
76
0
        if (q_ptr->state)
77
0
            systemStateChanged();
78
0
    }
79
80
    inline void setSystemViewport(const QRegion &region)
81
0
    {
82
0
        systemViewport = region;
83
0
        hasSystemViewport = !systemViewport.isEmpty();
84
0
        updateSystemClip();
85
0
        if (q_ptr->state)
86
0
            systemStateChanged();
87
0
    }
88
89
    inline void setSystemTransformAndViewport(const QTransform &xform, const QRegion &region)
90
0
    {
91
0
        systemTransform = xform;
92
0
        hasSystemTransform = !xform.isIdentity();
93
0
        systemViewport = region;
94
0
        hasSystemViewport = !systemViewport.isEmpty();
95
0
        updateSystemClip();
96
0
        if (q_ptr->state)
97
0
            systemStateChanged();
98
0
    }
99
100
0
    virtual void systemStateChanged() { }
101
102
    void drawBoxTextItem(const QPointF &p, const QTextItemInt &ti);
103
104
0
    static QPaintEnginePrivate *get(QPaintEngine *paintEngine) { return paintEngine->d_func(); }
105
106
0
    virtual QPaintEngine *aggregateEngine() { return nullptr; }
107
0
    virtual Qt::HANDLE nativeHandle() { return nullptr; }
108
};
109
110
QT_END_NAMESPACE
111
112
#endif // QPAINTENGINE_P_H