Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsgtransform_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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 QSGTRANSFORM_P_H
5#define QSGTRANSFORM_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 a number of Qt sources files. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QSharedPointer>
19#include <QMatrix4x4>
20#include <QtQuick/qtquickexports.h>
21
23
24class Q_QUICK_EXPORT QSGTransform
25{
26public:
28 {
29 if (matrix.isIdentity())
30 m_matrixPtr.clear();
31 else
33 m_invertedPtr.clear();
34 }
35
37 {
38 return m_matrixPtr ? *m_matrixPtr : m_identity;
39 }
40
41 bool isIdentity() const
42 {
43 return !m_matrixPtr;
44 }
45
46 bool operator==(const QMatrix4x4 &other) const
47 {
48 return m_matrixPtr ? (other == *m_matrixPtr) : other.isIdentity();
49 }
50
51 bool operator!=(const QMatrix4x4 &other) const
52 {
53 return !(*this == other);
54 }
55
56 bool operator==(const QSGTransform &other) const
57 {
58 return (m_matrixPtr == other.m_matrixPtr)
59 || (m_matrixPtr && other.m_matrixPtr && *m_matrixPtr == *other.m_matrixPtr);
60 }
61
62 bool operator!=(const QSGTransform &other) const
63 {
64 return !(*this == other);
65 }
66
67 int compareTo(const QSGTransform &other) const
68 {
69 int diff = 0;
70 if (m_matrixPtr != other.m_matrixPtr) {
71 if (m_matrixPtr.isNull()) {
72 diff = -1;
73 } else if (other.m_matrixPtr.isNull()) {
74 diff = 1;
75 } else {
76 const float *ptr1 = m_matrixPtr->constData();
77 const float *ptr2 = other.m_matrixPtr->constData();
78 for (int i = 0; i < 16 && !diff; i++) {
79 float d = ptr1[i] - ptr2[i];
80 if (d != 0)
81 diff = (d > 0) ? 1 : -1;
82 }
83 }
84 }
85 return diff;
86 }
87
88 const float *invertedData() const
89 {
90 if (!m_matrixPtr)
91 return m_identity.constData();
92 if (!m_invertedPtr)
93 m_invertedPtr = QSharedPointer<QMatrix4x4>::create(m_matrixPtr->inverted());
94 return m_invertedPtr->constData();
95 }
96
97private:
98 static QMatrix4x4 m_identity;
99 QSharedPointer<QMatrix4x4> m_matrixPtr;
100 mutable QSharedPointer<QMatrix4x4> m_invertedPtr;
101};
102
104
105#endif // QSGTRANSFORM_P_H
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
int compareTo(const QSGTransform &other) const
bool operator!=(const QMatrix4x4 &other) const
QMatrix4x4 matrix() const
bool operator==(const QSGTransform &other) const
const float * invertedData() const
bool operator==(const QMatrix4x4 &other) const
bool operator!=(const QSGTransform &other) const
bool isIdentity() const
void setMatrix(const QMatrix4x4 &matrix)
static QSharedPointer create(Args &&...arguments)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Combined button and popup list for selecting options.
GLuint GLenum matrix
QSharedPointer< T > other(t)
[5]