| 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 "layer_p.h" |
| 5 | #include <Qt3DRender/qlayer.h> |
| 6 | #include <Qt3DRender/private/qlayer_p.h> |
| 7 | #include <Qt3DRender/private/stringtoint_p.h> |
| 8 | #include <QVariant> |
| 9 | |
| 10 | QT_BEGIN_NAMESPACE |
| 11 | |
| 12 | |
| 13 | namespace Qt3DRender { |
| 14 | namespace Render { |
| 15 | |
| 16 | using namespace Qt3DCore; |
| 17 | |
| 18 | Layer::Layer() |
| 19 | : BackendNode() |
| 20 | , m_recursive(false) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | Layer::~Layer() |
| 25 | { |
| 26 | cleanup(); |
| 27 | } |
| 28 | |
| 29 | void Layer::cleanup() |
| 30 | { |
| 31 | QBackendNode::setEnabled(false); |
| 32 | } |
| 33 | |
| 34 | void Layer::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
| 35 | { |
| 36 | const QLayer *node = qobject_cast<const QLayer *>(object: frontEnd); |
| 37 | if (!node) |
| 38 | return; |
| 39 | |
| 40 | const bool oldEnabled = isEnabled(); |
| 41 | BackendNode::syncFromFrontEnd(frontEnd, firstTime); |
| 42 | |
| 43 | if (isEnabled() != oldEnabled || firstTime) |
| 44 | markDirty(changes: AbstractRenderer::LayersDirty); |
| 45 | |
| 46 | if (node->recursive() != m_recursive) { |
| 47 | m_recursive = node->recursive(); |
| 48 | markDirty(changes: AbstractRenderer::LayersDirty); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | bool Layer::recursive() const |
| 53 | { |
| 54 | return m_recursive; |
| 55 | } |
| 56 | |
| 57 | void Layer::setRecursive(bool recursive) |
| 58 | { |
| 59 | m_recursive = recursive; |
| 60 | } |
| 61 | |
| 62 | } // namespace Render |
| 63 | } // namespace Qt3DRender |
| 64 | |
| 65 | QT_END_NAMESPACE |
| 66 |
