| 1 | // Copyright (C) 2008-2012 NVIDIA Corporation. |
|---|---|
| 2 | // Copyright (C) 2019 The Qt Company Ltd. |
| 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 4 | |
| 5 | #ifndef QSSG_RENDERER_UTIL_H |
| 6 | #define QSSG_RENDERER_UTIL_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 <QtQuick3DUtils/private/qssgrenderbasetypes_p.h> |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | namespace QSSGRendererUtil |
| 24 | { |
| 25 | inline constexpr quint32 nextMultipleOf4(quint32 value) { |
| 26 | return (value + 3) & ~3; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | class QSSGRenderPath |
| 31 | { |
| 32 | public: |
| 33 | QSSGRenderPath() = default; |
| 34 | explicit inline QSSGRenderPath(const QString &p) noexcept |
| 35 | : m_path(p), m_key(qHash(key: p, seed: QHashSeed::globalSeed())) {} |
| 36 | |
| 37 | inline bool isNull() const { return m_path.isNull(); } |
| 38 | inline bool isEmpty() const { return m_path.isEmpty(); } |
| 39 | QString path() const { return m_path; } |
| 40 | private: |
| 41 | friend bool operator==(const QSSGRenderPath &, const QSSGRenderPath &); |
| 42 | friend size_t qHash(const QSSGRenderPath &, size_t) Q_DECL_NOTHROW; |
| 43 | QString m_path; |
| 44 | size_t m_key = 0; |
| 45 | }; |
| 46 | |
| 47 | inline bool operator==(const QSSGRenderPath &p1, const QSSGRenderPath &p2) |
| 48 | { |
| 49 | return (p1.m_key == p2.m_key) && (p1.m_path == p2.m_path); |
| 50 | } |
| 51 | |
| 52 | inline size_t qHash(const QSSGRenderPath &path, size_t seed) Q_DECL_NOTHROW |
| 53 | { |
| 54 | return (path.m_key) ? path.m_key : qHash(key: path.m_path, seed); |
| 55 | } |
| 56 | |
| 57 | QT_END_NAMESPACE |
| 58 | |
| 59 | #endif |
| 60 |
