| 1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include <Qt3DQuickRender/private/quick3drendertargetoutput_p.h> |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | namespace Qt3DRender { |
| 9 | namespace Render { |
| 10 | namespace Quick { |
| 11 | |
| 12 | Quick3DRenderTargetOutput::Quick3DRenderTargetOutput(QObject * parent) |
| 13 | : QObject(parent) |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | QQmlListProperty<QRenderTargetOutput> Quick3DRenderTargetOutput::qmlAttachments() |
| 18 | { |
| 19 | using qt_size_type = qsizetype; |
| 20 | using ListContentType = QRenderTargetOutput; |
| 21 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *output) { |
| 22 | Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(object: list->object); |
| 23 | if (rT) |
| 24 | rT->parentRenderTarget()->addOutput(output); |
| 25 | }; |
| 26 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
| 27 | Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(object: list->object); |
| 28 | if (rT) |
| 29 | return rT->parentRenderTarget()->outputs().size(); |
| 30 | return 0; |
| 31 | }; |
| 32 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
| 33 | Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(object: list->object); |
| 34 | if (rT) |
| 35 | return rT->parentRenderTarget()->outputs().at(i: index); |
| 36 | return nullptr; |
| 37 | }; |
| 38 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
| 39 | Quick3DRenderTargetOutput *rT = qobject_cast<Quick3DRenderTargetOutput *>(object: list->object); |
| 40 | if (rT) { |
| 41 | const auto outputs = rT->parentRenderTarget()->outputs(); |
| 42 | for (QRenderTargetOutput *output : outputs) |
| 43 | rT->parentRenderTarget()->removeOutput(output); |
| 44 | } |
| 45 | }; |
| 46 | |
| 47 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
| 48 | } |
| 49 | |
| 50 | } // namespace Quick |
| 51 | } // namespace Render |
| 52 | } // namespace Qt3DRender |
| 53 | |
| 54 | QT_END_NAMESPACE |
| 55 | |
| 56 | #include "moc_quick3drendertargetoutput_p.cpp" |
| 57 |
