diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-10-21 11:19:02 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2017-01-25 07:32:37 +0000 |
commit | bdaf8742dd6fd21e068c3e9283682cb1f2811370 (patch) | |
tree | c1fec48d94ded4ff7115bd56b95c5e47ec0478a2 /src/quick3d/quick3drender/items | |
parent | 9890652bd50e715603c594d8892582a39f924f8b (diff) |
Add Quick3DMemoryBarrier
Needed to work around the fact that QFlags aren't supported as a QML property
type.
And modify QMemoryBarrier to work with it
-> remove the Q_PROPERTY from QMemoryBarrier (it's in QUick3DMemoryBarrier)
-> properly send the notification change (since there's no Q_PROPERTY)
-> adjust AllBarriers values so that we can use QFlags &= to set it (|= not
available with ints)
Change-Id: Ide5b1c774fbbb1df745857b78ca353038b3cc052
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Diffstat (limited to 'src/quick3d/quick3drender/items')
-rw-r--r-- | src/quick3d/quick3drender/items/items.pri | 6 | ||||
-rw-r--r-- | src/quick3d/quick3drender/items/quick3dmemorybarrier.cpp | 74 | ||||
-rw-r--r-- | src/quick3d/quick3drender/items/quick3dmemorybarrier_p.h | 85 |
3 files changed, 163 insertions, 2 deletions
diff --git a/src/quick3d/quick3drender/items/items.pri b/src/quick3d/quick3drender/items/items.pri index 82fbdebc0..06a33107b 100644 --- a/src/quick3d/quick3drender/items/items.pri +++ b/src/quick3d/quick3drender/items/items.pri @@ -17,7 +17,8 @@ HEADERS += \ $$PWD/quick3dviewport_p.h \ $$PWD/quick3dparameter_p_p.h \ $$PWD/quick3dparameter_p.h \ - $$PWD/quick3drendertargetoutput_p.h + $$PWD/quick3drendertargetoutput_p.h \ + $$PWD/quick3dmemorybarrier_p.h SOURCES += \ $$PWD/quick3drenderpassfilter.cpp \ @@ -37,6 +38,7 @@ SOURCES += \ $$PWD/quick3drendertargetselector.cpp \ $$PWD/quick3dgeometry.cpp \ $$PWD/quick3dbuffer.cpp \ - $$PWD/quick3drendertargetoutput.cpp + $$PWD/quick3drendertargetoutput.cpp \ + $$PWD/quick3dmemorybarrier.cpp INCLUDEPATH += $$PWD diff --git a/src/quick3d/quick3drender/items/quick3dmemorybarrier.cpp b/src/quick3d/quick3drender/items/quick3dmemorybarrier.cpp new file mode 100644 index 000000000..a899d36c5 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dmemorybarrier.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quick3dmemorybarrier_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + + +Quick3DMemoryBarrier::Quick3DMemoryBarrier(QObject *parent) + : QObject(parent) +{ +} + +Quick3DMemoryBarrier::~Quick3DMemoryBarrier() +{ +} + +void Quick3DMemoryBarrier::setBarrierTypesInt(int barrierTypes) +{ + QMemoryBarrier::BarrierTypes types(QMemoryBarrier::AllBarrier); + types &= barrierTypes; // Will only keep flags that are actually set + parentBarrier()->setBarrierTypes(types); +} + +int Quick3DMemoryBarrier::barrierTypesInt() const +{ + return QMemoryBarrier::BarrierTypes::Int(parentBarrier()->barrierTypes()); +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dmemorybarrier_p.h b/src/quick3d/quick3drender/items/quick3dmemorybarrier_p.h new file mode 100644 index 000000000..5e402f006 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dmemorybarrier_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DRENDER_RENDER_QUICK_QUICK3DMEMORYBARRIER_P_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DMEMORYBARRIER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DQuickRender/private/qt3dquickrender_global_p.h> +#include <Qt3DRender/qmemorybarrier.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +// Qt6: Handle QFlags as Q_PROPERTY in QML + +class QT3DQUICKRENDERSHARED_PRIVATE_EXPORT Quick3DMemoryBarrier : public QObject +{ + Q_OBJECT + Q_PROPERTY(int barrierTypes READ barrierTypesInt WRITE setBarrierTypesInt) +public: + explicit Quick3DMemoryBarrier(QObject *parent = nullptr); + ~Quick3DMemoryBarrier(); + + inline QMemoryBarrier *parentBarrier() const { return qobject_cast<QMemoryBarrier*>(parent()); } + + void setBarrierTypesInt(int barrierTypes); + int barrierTypesInt() const; +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DMEMORYBARRIER_P_H |