summaryrefslogtreecommitdiffstats
path: root/src/render/frontend/qrendertarget.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-08-18 16:57:30 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-08-19 13:02:32 +0200
commitbfe8d71a8a90df5982e40f4b8e373cee25026772 (patch)
tree90310acb76765b2207b12ca92d5e5a9898286750 /src/render/frontend/qrendertarget.cpp
parentd25201871706c9fa7ee52791e60b300010f7f8dd (diff)
Added QRenderTarget
Change-Id: Id1e84ae8f23ddba1d2c97519b8762af801b03a38 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/frontend/qrendertarget.cpp')
-rw-r--r--src/render/frontend/qrendertarget.cpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/render/frontend/qrendertarget.cpp b/src/render/frontend/qrendertarget.cpp
new file mode 100644
index 000000000..fc0859e3b
--- /dev/null
+++ b/src/render/frontend/qrendertarget.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qrendertarget.h"
+#include "qrendertarget_p.h"
+#include "qrenderattachment.h"
+#include <Qt3DCore/qscenepropertychange.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+QRenderTargetPrivate::QRenderTargetPrivate(QRenderTarget *qq)
+ : QComponentPrivate(qq)
+{
+}
+
+QRenderTarget::QRenderTarget(QNode *parent)
+ : QComponent(*new QRenderTargetPrivate(this), parent)
+{
+}
+
+QRenderTarget::QRenderTarget(QRenderTargetPrivate &dd, QNode *parent)
+ : QComponent(dd, parent)
+{
+}
+
+void QRenderTarget::copy(const QNode *ref)
+{
+ QNode::copy(ref);
+}
+
+void QRenderTarget::addAttachment(QRenderAttachment *attachment)
+{
+ Q_D(QRenderTarget);
+ if (!d->m_attachments.contains(attachment)) {
+ d->m_attachments.append(attachment);
+
+ if (!attachment->parent() || attachment->parent() == this)
+ addChild(attachment);
+
+ if (d->m_changeArbiter != Q_NULLPTR) {
+ QScenePropertyChangePtr change(new QScenePropertyChange(NodeAdded, this));
+ change->setPropertyName(QByteArrayLiteral("attachment"));
+ change->setValue(QVariant::fromValue(attachment->clone()));
+ notifyObservers(change);
+ }
+ }
+}
+
+void QRenderTarget::removeAttachment(QRenderAttachment *attachment)
+{
+ Q_D(QRenderTarget);
+
+ if (d->m_changeArbiter != Q_NULLPTR) {
+ QScenePropertyChangePtr change(new QScenePropertyChange(NodeRemoved, this));
+ change->setPropertyName(QByteArrayLiteral("attachment"));
+ change->setValue(QVariant::fromValue(attachment->clone()));
+ notifyObservers(change);
+ }
+ d->m_attachments.removeOne(attachment);
+}
+
+QList<QRenderAttachment *> QRenderTarget::attachments() const
+{
+ Q_D(const QRenderTarget);
+ return d->m_attachments;
+}
+
+QRenderTarget *QRenderTarget::doClone(QNode *clonedParent) const
+{
+ Q_D(const QRenderTarget);
+ QRenderTarget *clone = new QRenderTarget(clonedParent);
+
+ Q_FOREACH (QRenderAttachment *attachment, d->m_attachments)
+ clone->addAttachment(qobject_cast<QRenderAttachment *>(attachment->clone()));
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE