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
21QT_BEGIN_NAMESPACE
22
23namespace QSSGRendererUtil
24{
25inline constexpr quint32 nextMultipleOf4(quint32 value) {
26 return (value + 3) & ~3;
27}
28}
29
30class QSSGRenderPath
31{
32public:
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; }
40private:
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
47inline 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
52inline 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
57QT_END_NAMESPACE
58
59#endif
60

source code of qtquick3d/src/runtimerender/qssgrendererutil_p.h