Coverage Report

Created: 2026-10-14 08:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/painting/qmath_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 QMATH_P_H
6
#define QMATH_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 <qmath.h>
20
#include <private/qglobal_p.h>
21
#include <qtransform.h>
22
23
QT_BEGIN_NAMESPACE
24
25
static const qreal Q_PI   = qreal(M_PI);     // pi
26
static const qreal Q_MM_PER_INCH = 25.4;
27
28
inline QRect qt_mapFillRect(const QRectF &rect, const QTransform &xf)
29
0
{
30
    // Only for xf <= scaling or 90 degree rotations
31
0
    Q_ASSERT(xf.type() <= QTransform::TxScale
32
0
             || (xf.type() == QTransform::TxRotate && qFuzzyIsNull(xf.m11()) && qFuzzyIsNull(xf.m22())));
33
    // Transform the corners instead of the rect to avoid hitting numerical accuracy limit
34
    // when transforming topleft and size separately and adding afterwards,
35
    // as that can sometimes be slightly off around the .5 point, leading to wrong rounding
36
0
    QPoint pt1 = xf.map(rect.topLeft()).toPoint();
37
0
    QPoint pt2 = xf.map(rect.bottomRight()).toPoint();
38
    // cut short if the result will be an empty QRect anyway
39
    // side effect: avoids overflows in the calculations below
40
0
    if (Q_UNLIKELY(pt1.x() == pt2.x() || pt1.y() == pt2.y()))
41
0
        return QRect();
42
    // Normalize and adjust for the QRect vs. QRectF bottomright
43
0
    return QRect::span(pt1, pt2).adjusted(0, 0, -1, -1);
44
0
}
45
46
QT_END_NAMESPACE
47
48
#endif // QMATH_P_H