Coverage Report

Created: 2025-09-08 07:52

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