Remove QQuickCanvasItemNode.
authorJustin McPherson <justin.mcpherson@nokia.com>
Fri, 2 Mar 2012 06:24:04 +0000 (16:24 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 6 Mar 2012 05:34:29 +0000 (06:34 +0100)
A custom SGNode is not necessary.

Change-Id: Ibde71dd502bc782503dbd7d98e6ad8b811b7aedb
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
src/quick/items/context2d/context2d.pri
src/quick/items/context2d/qquickcanvasitem.cpp
src/quick/items/context2d/qquickcanvasitemnode.cpp [deleted file]
src/quick/items/context2d/qquickcanvasitemnode_p.h [deleted file]

index 84346f6..c73d58b 100644 (file)
@@ -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 \
index 550ab20..3d520d2 100644 (file)
@@ -44,7 +44,7 @@
 #include <private/qquickitem_p.h>
 #include <private/qquickcanvascontext_p.h>
 #include <private/qquickcontext2d_p.h>
-#include <private/qquickcanvasitemnode_p.h>
+#include <qsgsimpletexturenode.h>
 #include <QtQuick/private/qquickpixmapcache_p.h>
 
 #include <qqmlinfo.h>
@@ -560,17 +560,16 @@ QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
     if (!d->contextInitialized)
         return 0;
 
-    QQuickCanvasItemNode *node = static_cast<QQuickCanvasItemNode*>(oldNode);
+    QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode*>(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 (file)
index 5a2dd80..0000000
+++ /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 <QtQuick/private/qsgcontext_p.h>
-#include <QtCore/qmath.h>
-
-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 (file)
index 7eb7d2a..0000000
+++ /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 <QtQuick/qsgnode.h>
-#include <QtQuick/qsgtexturematerial.h>
-
-#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