From be4c74948371ddf6f1ed260783b43b5a3d9e60a7 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Fri, 2 Mar 2012 16:24:04 +1000 Subject: [PATCH] Remove QQuickCanvasItemNode. A custom SGNode is not necessary. Change-Id: Ibde71dd502bc782503dbd7d98e6ad8b811b7aedb Reviewed-by: Yunqiao Yin --- src/quick/items/context2d/context2d.pri | 2 - src/quick/items/context2d/qquickcanvasitem.cpp | 9 +- src/quick/items/context2d/qquickcanvasitemnode.cpp | 112 --------------------- src/quick/items/context2d/qquickcanvasitemnode_p.h | 87 ---------------- 4 files changed, 4 insertions(+), 206 deletions(-) delete mode 100644 src/quick/items/context2d/qquickcanvasitemnode.cpp delete mode 100644 src/quick/items/context2d/qquickcanvasitemnode_p.h diff --git a/src/quick/items/context2d/context2d.pri b/src/quick/items/context2d/context2d.pri index 84346f6..c73d58b 100644 --- a/src/quick/items/context2d/context2d.pri +++ b/src/quick/items/context2d/context2d.pri @@ -2,7 +2,6 @@ SOURCES += \ $$PWD/qquickcanvasitem.cpp \ $$PWD/qquickcanvascontext.cpp \ $$PWD/qquickcontext2d.cpp \ - $$PWD/qquickcanvasitemnode.cpp \ $$PWD/qquickcontext2dtile.cpp \ $$PWD/qquickcontext2dtexture.cpp \ $$PWD/qquickcontext2dcommandbuffer.cpp \ @@ -11,7 +10,6 @@ HEADERS += \ $$PWD/qquickcanvasitem_p.h \ $$PWD/qquickcanvascontext_p.h \ $$PWD/qquickcontext2d_p.h \ - $$PWD/qquickcanvasitemnode_p.h \ $$PWD/qquickcontext2dtile_p.h \ $$PWD/qquickcontext2dtexture_p.h \ $$PWD/qquickcontext2dcommandbuffer_p.h \ diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 550ab20..3d520d2 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include @@ -560,17 +560,16 @@ QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData if (!d->contextInitialized) return 0; - QQuickCanvasItemNode *node = static_cast(oldNode); + QSGSimpleTextureNode *node = static_cast(oldNode); if (!node) { - node = new QQuickCanvasItemNode; + node = new QSGSimpleTextureNode; } if (d->renderStrategy == QQuickCanvasItem::Cooperative) d->context->sync(); node->setTexture(d->context->texture()); - node->setSize(d->canvasWindow.size()); - node->update(); + node->setRect(QRectF(QPoint(0, 0), d->canvasWindow.size())); return node; } diff --git a/src/quick/items/context2d/qquickcanvasitemnode.cpp b/src/quick/items/context2d/qquickcanvasitemnode.cpp deleted file mode 100644 index 5a2dd80..0000000 --- a/src/quick/items/context2d/qquickcanvasitemnode.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickcanvasitemnode_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - - -QQuickCanvasItemNode::QQuickCanvasItemNode() - : QSGGeometryNode() - , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) - , m_texture(0) - , m_size(1, 1) - , m_dirtyGeometry(false) - , m_dirtyTexture(false) -{ - setMaterial(&m_materialO); - setOpaqueMaterial(&m_material); - setGeometry(&m_geometry); -} - -QQuickCanvasItemNode::~QQuickCanvasItemNode() -{ - delete m_texture; -} - -void QQuickCanvasItemNode::setSize(const QSizeF& size) -{ - if (m_size != size) { - m_dirtyGeometry = true; - m_size = size; - } -} - -void QQuickCanvasItemNode::setTexture(QSGDynamicTexture* texture) -{ - if (texture != m_texture) { - m_dirtyTexture = true; - m_texture = texture; - } -} - -void QQuickCanvasItemNode::update() -{ - if (m_dirtyGeometry) - updateGeometry(); - if (m_dirtyTexture) - updateTexture(); - - m_dirtyGeometry = false; - m_dirtyTexture = false; -} - -void QQuickCanvasItemNode::updateTexture() -{ - m_material.setTexture(m_texture); - m_materialO.setTexture(m_texture); - markDirty(DirtyMaterial); -} - -void QQuickCanvasItemNode::updateGeometry() -{ - QRectF source = m_texture->normalizedTextureSubRect(); - QSGGeometry::updateTexturedRectGeometry(&m_geometry, - QRectF(0, 0, m_size.width(), m_size.height()), - source); - markDirty(DirtyGeometry); -} - -QT_END_NAMESPACE - diff --git a/src/quick/items/context2d/qquickcanvasitemnode_p.h b/src/quick/items/context2d/qquickcanvasitemnode_p.h deleted file mode 100644 index 7eb7d2a..0000000 --- a/src/quick/items/context2d/qquickcanvasitemnode_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKCONTEXT2DNODE_P_H -#define QQUICKCONTEXT2DNODE_P_H - -#include -#include - -#include "qquickcanvasitem_p.h" -#include "qquickcontext2dtexture_p.h" -#include "qquickcontext2d_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QSGDynamicTexture; - -class QQuickCanvasItemNode : public QSGGeometryNode -{ -public: - QQuickCanvasItemNode(); - ~QQuickCanvasItemNode(); - - void setTexture(QSGDynamicTexture *texture); - void update(); - void setSize(const QSizeF& size); - -private: - void updateTexture(); - void updateGeometry(); - - QSGOpaqueTextureMaterial m_material; - QSGTextureMaterial m_materialO; - QSGGeometry m_geometry; - QSGTexture* m_texture; - QSizeF m_size; - - bool m_dirtyGeometry; - bool m_dirtyTexture; -}; - -QT_END_HEADER - -QT_END_NAMESPACE - -#endif // QQUICKCONTEXT2DNODE_P_H -- 2.7.4