aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-06-20 16:19:05 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-06-20 16:19:05 +0200
commit2402d3a303f712f4402cc258fcd7c8983227ea31 (patch)
tree3e79afdfd1e4268adecf4ad98bb867025048bd61
parent1037a7f7123dcf9f7b48a6a74118f746ddcbf3d5 (diff)
parent5d4b006181d009e6245d5d38c7798603ddcab06a (diff)
Merge remote-tracking branch 'origin/stable' into dev
-rw-r--r--examples/quick/scenegraph/graph/doc/images/graph-example.jpgbin0 -> 18923 bytes
-rw-r--r--examples/quick/scenegraph/graph/doc/src/graph.qdoc38
-rw-r--r--examples/quick/scenegraph/graph/graph.cpp128
-rw-r--r--examples/quick/scenegraph/graph/graph.h67
-rw-r--r--examples/quick/scenegraph/graph/graph.pro34
-rw-r--r--examples/quick/scenegraph/graph/graph.qrc9
-rw-r--r--examples/quick/scenegraph/graph/gridnode.cpp95
-rw-r--r--examples/quick/scenegraph/graph/gridnode.h59
-rw-r--r--examples/quick/scenegraph/graph/linenode.cpp151
-rw-r--r--examples/quick/scenegraph/graph/linenode.h58
-rw-r--r--examples/quick/scenegraph/graph/main.cpp60
-rw-r--r--examples/quick/scenegraph/graph/main.qml85
-rw-r--r--examples/quick/scenegraph/graph/noisynode.cpp142
-rw-r--r--examples/quick/scenegraph/graph/noisynode.h56
-rw-r--r--examples/quick/scenegraph/graph/shaders/line.fsh54
-rw-r--r--examples/quick/scenegraph/graph/shaders/line.vsh56
-rw-r--r--examples/quick/scenegraph/graph/shaders/noisy.fsh55
-rw-r--r--examples/quick/scenegraph/graph/shaders/noisy.vsh54
-rw-r--r--src/qml/qml/ftw/qhashedstring.cpp6
-rw-r--r--src/qml/qml/qqmlengine.cpp4
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp8
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp7
-rw-r--r--src/quick/items/qquickimage.cpp6
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp4
-rw-r--r--src/quick/scenegraph/qsgdefaultimagenode.cpp8
-rw-r--r--src/quick/scenegraph/qsgdefaultimagenode_p.h6
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode.cpp8
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode_p.h6
-rw-r--r--tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp28
29 files changed, 1262 insertions, 30 deletions
diff --git a/examples/quick/scenegraph/graph/doc/images/graph-example.jpg b/examples/quick/scenegraph/graph/doc/images/graph-example.jpg
new file mode 100644
index 0000000000..74975ee7c4
--- /dev/null
+++ b/examples/quick/scenegraph/graph/doc/images/graph-example.jpg
Binary files differ
diff --git a/examples/quick/scenegraph/graph/doc/src/graph.qdoc b/examples/quick/scenegraph/graph/doc/src/graph.qdoc
new file mode 100644
index 0000000000..d5a07cdc48
--- /dev/null
+++ b/examples/quick/scenegraph/graph/doc/src/graph.qdoc
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example scenegraph/graph
+ \title Scene Graph - Graph
+ \ingroup qtquickexamples
+
+ \brief Demonstrates how one can combine custom materials and geometries
+ under a single QQuickItem.
+
+ \image graph-example.jpg
+
+ */
diff --git a/examples/quick/scenegraph/graph/graph.cpp b/examples/quick/scenegraph/graph/graph.cpp
new file mode 100644
index 0000000000..ad75307e57
--- /dev/null
+++ b/examples/quick/scenegraph/graph/graph.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "graph.h"
+
+#include "noisynode.h"
+#include "gridnode.h"
+#include "linenode.h"
+
+Graph::Graph()
+ : m_samplesChanged(false)
+ , m_geometryChanged(false)
+{
+ setFlag(ItemHasContents, true);
+}
+
+
+void Graph::appendSample(qreal value)
+{
+ m_samples << value;
+ m_samplesChanged = true;
+ update();
+}
+
+
+void Graph::removeFirstSample()
+{
+ m_samples.removeFirst();
+ m_samplesChanged = true;
+ update();
+}
+
+void Graph::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ m_geometryChanged = true;
+ update();
+ QQuickItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+
+class GraphNode : public QSGNode
+{
+public:
+ NoisyNode *background;
+ GridNode *grid;
+ LineNode *line;
+ LineNode *shadow;
+};
+
+
+QSGNode *Graph::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+{
+ GraphNode *n= static_cast<GraphNode *>(oldNode);
+
+ QRectF rect = boundingRect();
+
+ if (rect.isEmpty()) {
+ delete n;
+ return 0;
+ }
+
+ if (!n) {
+ n = new GraphNode();
+
+ n->background = new NoisyNode(window());
+ n->grid = new GridNode();
+ n->line = new LineNode(10, 0.5, QColor("steelblue"));
+ n->shadow = new LineNode(20, 0.2, QColor::fromRgbF(0.2, 0.2, 0.2, 0.4));
+
+ n->appendChildNode(n->background);
+ n->appendChildNode(n->grid);
+ n->appendChildNode(n->shadow);
+ n->appendChildNode(n->line);
+ }
+
+ if (m_geometryChanged) {
+ n->background->setRect(rect);
+ n->grid->setRect(rect);
+ }
+
+ if (m_geometryChanged || m_samplesChanged) {
+ n->line->updateGeometry(rect, m_samples);
+ // We don't need to calculate the geometry twice, so just steal it from the other one...
+ n->shadow->setGeometry(n->line->geometry());
+ }
+
+ m_geometryChanged = false;
+ m_samplesChanged = false;
+
+ return n;
+}
diff --git a/examples/quick/scenegraph/graph/graph.h b/examples/quick/scenegraph/graph/graph.h
new file mode 100644
index 0000000000..28d14f166a
--- /dev/null
+++ b/examples/quick/scenegraph/graph/graph.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GRAPH_H
+#define GRAPH_H
+
+#include <QQuickItem>
+
+class Graph : public QQuickItem
+{
+ Q_OBJECT
+public:
+ Graph();
+
+protected:
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
+
+public slots:
+ void appendSample(qreal value);
+ void removeFirstSample();
+
+private:
+ QList<qreal> m_samples;
+
+ bool m_samplesChanged;
+ bool m_geometryChanged;
+};
+
+#endif // GRAPH_H
diff --git a/examples/quick/scenegraph/graph/graph.pro b/examples/quick/scenegraph/graph/graph.pro
new file mode 100644
index 0000000000..5991f799dc
--- /dev/null
+++ b/examples/quick/scenegraph/graph/graph.pro
@@ -0,0 +1,34 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2013-06-11T13:13:18
+#
+#-------------------------------------------------
+
+QT += core gui quick
+
+TARGET = graph
+
+TEMPLATE = app
+
+SOURCES += main.cpp \
+ graph.cpp \
+ noisynode.cpp \
+ gridnode.cpp \
+ linenode.cpp
+
+HEADERS += \
+ graph.h \
+ noisynode.h \
+ gridnode.h \
+ linenode.h
+
+RESOURCES += \
+ graph.qrc
+
+OTHER_FILES += \
+ main.qml \
+ shaders/noisy.vsh \
+ shaders/noisy.fsh \
+ shaders/line.fsh \
+ shaders/line.vsh
+
diff --git a/examples/quick/scenegraph/graph/graph.qrc b/examples/quick/scenegraph/graph/graph.qrc
new file mode 100644
index 0000000000..2adaeac751
--- /dev/null
+++ b/examples/quick/scenegraph/graph/graph.qrc
@@ -0,0 +1,9 @@
+<RCC>
+ <qresource prefix="/scenegraph/graph">
+ <file>main.qml</file>
+ <file>shaders/noisy.vsh</file>
+ <file>shaders/noisy.fsh</file>
+ <file>shaders/line.vsh</file>
+ <file>shaders/line.fsh</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/scenegraph/graph/gridnode.cpp b/examples/quick/scenegraph/graph/gridnode.cpp
new file mode 100644
index 0000000000..2b5e8cac16
--- /dev/null
+++ b/examples/quick/scenegraph/graph/gridnode.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "gridnode.h"
+
+#include "qmath.h"
+
+#define GRID_SIZE 32
+
+GridNode::GridNode()
+ : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0)
+{
+ setGeometry(&m_geometry);
+ m_geometry.setDrawingMode(GL_LINES);
+
+ setMaterial(&m_material);
+ m_material.setColor(Qt::gray);
+}
+
+/*
+ * The function hardcodes a fixed set of grid lines and scales
+ * those to the bounding rect.
+ */
+void GridNode::setRect(const QRectF &rect)
+{
+ int vCount = int((rect.width() - 1) / GRID_SIZE);
+ int hCount = int((rect.height() - 1) / GRID_SIZE);
+
+ int lineCount = vCount + hCount;
+
+ QSGGeometry *g = geometry();
+
+ g->allocate(lineCount * 2);
+
+ float x = rect.x();
+ float y = rect.y();
+ float w = rect.width();
+ float h = rect.height();
+
+ QSGGeometry::Point2D *v = g->vertexDataAsPoint2D();
+
+ // Then write the vertical lines
+ for (int i=0; i<vCount; ++i) {
+ float dx = (i + 1) * GRID_SIZE;
+ v[i*2].set(dx, y);
+ v[i*2+1].set(dx, y + h);
+ }
+ v += vCount * 2;
+ // Then write the horizontal lines
+ for (int i=0; i<hCount; ++i) {
+ float dy = (i + 1) * GRID_SIZE;
+ v[i*2].set(x, dy);
+ v[i*2+1].set(x + w, dy);
+ }
+
+ // Tell the scenegraph we updated the geometry..
+ markDirty(QSGNode::DirtyGeometry);
+}
diff --git a/examples/quick/scenegraph/graph/gridnode.h b/examples/quick/scenegraph/graph/gridnode.h
new file mode 100644
index 0000000000..8581a993ae
--- /dev/null
+++ b/examples/quick/scenegraph/graph/gridnode.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GRIDNODE_H
+#define GRIDNODE_H
+
+#include <QtQuick/QSGGeometryNode>
+#include <QtQuick/QSGFlatColorMaterial>
+
+class GridNode : public QSGGeometryNode
+{
+public:
+ GridNode();
+
+ void setRect(const QRectF &rect);
+
+private:
+ QSGFlatColorMaterial m_material;
+ QSGGeometry m_geometry;
+};
+
+#endif // GRIDNODE_H
diff --git a/examples/quick/scenegraph/graph/linenode.cpp b/examples/quick/scenegraph/graph/linenode.cpp
new file mode 100644
index 0000000000..0d1229cf1d
--- /dev/null
+++ b/examples/quick/scenegraph/graph/linenode.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "linenode.h"
+
+#include <QtCore/QResource>
+
+#include <QtGui/QColor>
+
+#include <QtQuick/QSGSimpleMaterial>
+
+struct LineMaterial
+{
+ QColor color;
+ float spread;
+ float size;
+};
+
+class LineShader : public QSGSimpleMaterialShader<LineMaterial>
+{
+ QSG_DECLARE_SIMPLE_SHADER(LineShader, LineMaterial)
+
+public:
+ const char *vertexShader() const {
+ QResource r(":/scenegraph/graph/shaders/line.vsh");
+ Q_ASSERT(r.isValid());
+ return (const char *) r.data();
+ }
+
+ const char *fragmentShader() const {
+ QResource r(":/scenegraph/graph/shaders/line.fsh");
+ Q_ASSERT(r.isValid());
+ return (const char *) r.data();
+ }
+
+ QList<QByteArray> attributes() const { return QList<QByteArray>() << "pos" << "t"; }
+
+ void updateState(const LineMaterial *m, const LineMaterial *) {
+ program()->setUniformValue(id_color, m->color);
+ program()->setUniformValue(id_spread, m->spread);
+ program()->setUniformValue(id_size, m->size);
+ }
+
+ void resolveUniforms() {
+ id_spread = program()->uniformLocation("spread");
+ id_size = program()->uniformLocation("size");
+ id_color = program()->uniformLocation("color");
+ }
+
+private:
+ int id_color;
+ int id_spread;
+ int id_size;
+};
+
+struct LineVertex {
+ float x;
+ float y;
+ float t;
+ inline void set(float xx, float yy, float tt) { x = xx; y = yy; t = tt; }
+};
+
+static const QSGGeometry::AttributeSet &attributes()
+{
+ static QSGGeometry::Attribute attr[] = {
+ QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true),
+ QSGGeometry::Attribute::create(1, 1, GL_FLOAT)
+ };
+ static QSGGeometry::AttributeSet set = { 2, 3 * sizeof(float), attr };
+ return set;
+}
+
+LineNode::LineNode(float size, float spread, const QColor &color)
+ : m_geometry(attributes(), 0)
+{
+ setGeometry(&m_geometry);
+ m_geometry.setDrawingMode(GL_TRIANGLE_STRIP);
+
+ QSGSimpleMaterial<LineMaterial> *m = LineShader::createMaterial();
+ m->state()->color = color;
+ m->state()->size = size;
+ m->state()->spread = spread;
+ m->setFlag(QSGMaterial::Blending);
+ setMaterial(m);
+ setFlag(OwnsMaterial);
+}
+
+/*
+ * Assumes that samples have values in the range of 0 to 1 and scales them to
+ * the height of bounds. The samples are stretched out horizontally along the
+ * width of the bounds.
+ *
+ * The position of each pair of points is identical, but we use the third value
+ * "t" to shift the point up or down and to add antialiasing.
+ */
+void LineNode::updateGeometry(const QRectF &bounds, const QList<qreal> &samples)
+{
+ m_geometry.allocate(samples.size() * 2);
+
+ float x = bounds.x();
+ float y = bounds.y();
+ float w = bounds.width();
+ float h = bounds.height();
+
+ float dx = w / (samples.size() - 1);
+
+ LineVertex *v = (LineVertex *) m_geometry.vertexData();
+ for (int i=0; i<samples.size(); ++i) {
+ v[i*2+0].set(x + dx * i, y + samples.at(i) * h, 0);
+ v[i*2+1].set(x + dx * i, y + samples.at(i) * h, 1);
+ }
+
+ markDirty(QSGNode::DirtyGeometry);
+}
diff --git a/examples/quick/scenegraph/graph/linenode.h b/examples/quick/scenegraph/graph/linenode.h
new file mode 100644
index 0000000000..192bedbefc
--- /dev/null
+++ b/examples/quick/scenegraph/graph/linenode.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LINENODE_H
+#define LINENODE_H
+
+#include <QSGGeometryNode>
+
+class LineNode : public QSGGeometryNode
+{
+public:
+ LineNode(float size, float spread, const QColor &color);
+
+ void updateGeometry(const QRectF &bounds, const QList<qreal> &samples);
+
+private:
+ QSGGeometry m_geometry;
+
+};
+
+#endif // LINENODE_H
diff --git a/examples/quick/scenegraph/graph/main.cpp b/examples/quick/scenegraph/graph/main.cpp
new file mode 100644
index 0000000000..ed54ae59b1
--- /dev/null
+++ b/examples/quick/scenegraph/graph/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQuickView>
+
+#include "graph.h"
+#include <QtQml/QQmlContext>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication a(argc, argv);
+
+ qmlRegisterType<Graph>("Graph", 1, 0, "Graph");
+
+ QQuickView view;
+ view.resize(800, 400);
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl("qrc:///scenegraph/graph/main.qml"));
+ view.show();
+
+ return a.exec();
+}
diff --git a/examples/quick/scenegraph/graph/main.qml b/examples/quick/scenegraph/graph/main.qml
new file mode 100644
index 0000000000..ad952bcf1a
--- /dev/null
+++ b/examples/quick/scenegraph/graph/main.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+import Graph 1.0
+
+Item {
+ width: 800
+ height: 400
+
+ Graph {
+ id: graph
+ anchors.fill: parent
+ anchors.margins: 100
+
+ function newSample(i) {
+ return (Math.sin(i / 100.0 * Math.PI * 2) + 1) * 0.4 + Math.random() * 0.05;
+ }
+
+ Component.onCompleted: {
+ for (var i=0; i<100; ++i)
+ appendSample(newSample(i));
+ }
+
+ property int offset: 100;
+ }
+
+ Timer {
+ id: timer
+ interval: 500
+ repeat: true
+ running: true
+ onTriggered: {
+ graph.removeFirstSample();
+ graph.appendSample(graph.newSample(++graph.offset));
+ }
+
+ }
+
+ Rectangle {
+ anchors.fill: graph
+ color: "transparent"
+ border.color: "black"
+ border.width: 2
+ }
+
+}
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp
new file mode 100644
index 0000000000..1fc87a2b97
--- /dev/null
+++ b/examples/quick/scenegraph/graph/noisynode.cpp
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "noisynode.h"
+
+#include <QtCore/QResource>
+
+#include <QtQuick/QSGSimpleMaterialShader>
+#include <QtQuick/QSGTexture>
+#include <QtQuick/QQuickWindow>
+
+#define NOISE_SIZE 64
+
+struct NoisyMaterial
+{
+ ~NoisyMaterial() {
+ delete texture;
+ }
+
+ QColor color;
+ QSGTexture *texture;
+};
+
+class NoisyShader : public QSGSimpleMaterialShader<NoisyMaterial>
+{
+ QSG_DECLARE_SIMPLE_SHADER(NoisyShader, NoisyMaterial)
+
+public:
+ const char *vertexShader() const {
+ QResource r(":/scenegraph/graph/shaders/noisy.vsh");
+ Q_ASSERT(r.isValid());
+ return (const char *) r.data();
+ }
+
+ const char *fragmentShader() const {
+ QResource r(":/scenegraph/graph/shaders/noisy.fsh");
+ Q_ASSERT(r.isValid());
+ return (const char *) r.data();
+ }
+
+ QList<QByteArray> attributes() const { return QList<QByteArray>() << "aVertex" << "aTexCoord"; }
+
+ void updateState(const NoisyMaterial *m, const NoisyMaterial *) {
+
+ // Set the color
+ program()->setUniformValue(id_color, m->color);
+
+ // Bind the texture and set program to use texture unit 0 (the default)
+ m->texture->bind();
+
+ // Then set the texture size so we can adjust the texture coordinates accordingly in the
+ // vertex shader..
+ QSize s = m->texture->textureSize();
+ program()->setUniformValue(id_textureSize, QSizeF(1.0 / s.width(), 1.0 / s.height()));
+ }
+
+ void resolveUniforms() {
+ id_texture = program()->uniformLocation("texture");
+ id_textureSize = program()->uniformLocation("textureSize");
+ id_color = program()->uniformLocation("color");
+
+ // We will only use texture unit 0, so set it only once.
+ program()->setUniformValue(id_texture, 0);
+ }
+
+private:
+ int id_color;
+ int id_texture;
+ int id_textureSize;
+};
+
+NoisyNode::NoisyNode(QQuickWindow *window)
+{
+ // Make some noise...
+ QImage image(NOISE_SIZE, NOISE_SIZE, QImage::Format_RGB32);
+ uint *data = (uint *) image.bits();
+ for (int i=0; i<NOISE_SIZE * NOISE_SIZE; ++i) {
+ uint g = rand() & 0xff;
+ data[i] = 0xff000000 | (g << 16) | (g << 8) | g;
+ }
+
+ QSGTexture *t = window->createTextureFromImage(image);
+ t->setFiltering(QSGTexture::Nearest);
+ t->setHorizontalWrapMode(QSGTexture::Repeat);
+ t->setVerticalWrapMode(QSGTexture::Repeat);
+
+ QSGSimpleMaterial<NoisyMaterial> *m = NoisyShader::createMaterial();
+ m->state()->texture = t;
+ m->state()->color = QColor::fromRgbF(0.95, 0.95, 0.97);
+ m->setFlag(QSGMaterial::Blending);
+
+ setMaterial(m);
+ setFlag(OwnsMaterial, true);
+
+ QSGGeometry *g = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4);
+ QSGGeometry::updateTexturedRectGeometry(g, QRect(), QRect());
+ setGeometry(g);
+ setFlag(OwnsGeometry, true);
+}
+
+void NoisyNode::setRect(const QRectF &bounds)
+{
+ QSGGeometry::updateTexturedRectGeometry(geometry(), bounds, QRectF(0, 0, 1, 1));
+ markDirty(QSGNode::DirtyGeometry);
+}
diff --git a/examples/quick/scenegraph/graph/noisynode.h b/examples/quick/scenegraph/graph/noisynode.h
new file mode 100644
index 0000000000..b5a291330f
--- /dev/null
+++ b/examples/quick/scenegraph/graph/noisynode.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NOISYNODE_H
+#define NOISYNODE_H
+
+#include <QSGGeometryNode>
+
+class QQuickWindow;
+
+class NoisyNode : public QSGGeometryNode
+{
+public:
+ NoisyNode(QQuickWindow *window);
+
+ void setRect(const QRectF &bounds);
+};
+
+#endif // NOISYNODE_H
diff --git a/examples/quick/scenegraph/graph/shaders/line.fsh b/examples/quick/scenegraph/graph/shaders/line.fsh
new file mode 100644
index 0000000000..b07558c2ab
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/line.fsh
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+uniform lowp vec4 color;
+uniform lowp float qt_Opacity;
+uniform lowp float spread;
+
+varying lowp float vT;
+
+#define PI 3.14159265359
+
+void main(void)
+{
+ lowp float tt = smoothstep(spread, 1.0, sin(vT * PI));
+
+ gl_FragColor = color * qt_Opacity * tt;
+}
diff --git a/examples/quick/scenegraph/graph/shaders/line.vsh b/examples/quick/scenegraph/graph/shaders/line.vsh
new file mode 100644
index 0000000000..84353b852c
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/line.vsh
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+attribute highp vec4 pos;
+attribute highp float t;
+
+uniform lowp float size;
+uniform highp mat4 qt_Matrix;
+
+varying lowp float vT;
+
+void main(void)
+{
+ vec4 adjustedPos = pos;
+ adjustedPos.y += (t * size);
+ gl_Position = qt_Matrix * adjustedPos;
+
+ vT = t;
+}
diff --git a/examples/quick/scenegraph/graph/shaders/noisy.fsh b/examples/quick/scenegraph/graph/shaders/noisy.fsh
new file mode 100644
index 0000000000..227c2b5974
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/noisy.fsh
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+uniform sampler2D texture;
+uniform lowp float qt_Opacity;
+uniform lowp vec4 color;
+
+varying highp vec2 vTexCoord;
+varying lowp vec2 vShadeCoord;
+
+#define PI 3.14159265359
+
+void main()
+{
+ lowp float shade = texture2D(texture, vTexCoord).r * 0.05 - length(vec2(0.5, 0.4) - vShadeCoord) * 0.3;
+ lowp vec4 c = vec4(color.xyz + shade, color.w);
+ gl_FragColor = c * qt_Opacity;
+}
diff --git a/examples/quick/scenegraph/graph/shaders/noisy.vsh b/examples/quick/scenegraph/graph/shaders/noisy.vsh
new file mode 100644
index 0000000000..ce648e51b9
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/noisy.vsh
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+attribute highp vec4 aVertex;
+attribute highp vec2 aTexCoord;
+
+uniform highp mat4 qt_Matrix;
+uniform highp vec2 textureSize;
+
+varying highp vec2 vTexCoord;
+varying lowp vec2 vShadeCoord;
+
+void main() {
+ gl_Position = qt_Matrix * aVertex;
+ vTexCoord = aVertex.xy * textureSize;
+ vShadeCoord = aTexCoord;
+}
diff --git a/src/qml/qml/ftw/qhashedstring.cpp b/src/qml/qml/ftw/qhashedstring.cpp
index 212a6757d0..1b7ad38ad1 100644
--- a/src/qml/qml/ftw/qhashedstring.cpp
+++ b/src/qml/qml/ftw/qhashedstring.cpp
@@ -156,7 +156,7 @@ bool QHashedString::compare(const QChar *lhs, const QChar *rhs, int length)
if (a == b || !length)
return true;
- register union {
+ union {
const quint16 *w;
const quint32 *d;
quintptr value;
@@ -181,7 +181,7 @@ bool QHashedString::compare(const QChar *lhs, const QChar *rhs, int length)
// both addresses are 4-bytes aligned
// do a fast 32-bit comparison
- register const quint32 *e = sa.d + (length >> 1);
+ const quint32 *e = sa.d + (length >> 1);
for ( ; sa.d != e; ++sa.d, ++sb.d) {
if (*sa.d != *sb.d)
return false;
@@ -191,7 +191,7 @@ bool QHashedString::compare(const QChar *lhs, const QChar *rhs, int length)
return (length & 1) ? *sa.w == *sb.w : true;
} else {
// one of the addresses isn't 4-byte aligned but the other is
- register const quint16 *e = sa.w + length;
+ const quint16 *e = sa.w + length;
for ( ; sa.w != e; ++sa.w, ++sb.w) {
if (*sa.w != *sb.w)
return false;
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index a304365dfe..673fbfefbb 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -1065,7 +1065,7 @@ QQmlImageProviderBase *QQmlEngine::imageProvider(const QString &providerId) cons
{
Q_D(const QQmlEngine);
QMutexLocker locker(&d->mutex);
- return d->imageProviders.value(providerId).data();
+ return d->imageProviders.value(providerId.toLower()).data();
}
/*!
@@ -1077,7 +1077,7 @@ void QQmlEngine::removeImageProvider(const QString &providerId)
{
Q_D(QQmlEngine);
QMutexLocker locker(&d->mutex);
- d->imageProviders.take(providerId);
+ d->imageProviders.take(providerId.toLower());
}
/*!
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 4144256a38..1b33680361 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -645,7 +645,7 @@ void QQuickCanvasItem::updatePolish()
Q_D(QQuickCanvasItem);
- if (d->context)
+ if (d->context && d->renderStrategy != QQuickCanvasItem::Cooperative)
d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, d->antialiasing);
if (d->animationCallbacks.size() > 0 && isVisible()) {
@@ -683,7 +683,7 @@ QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
{
Q_D(QQuickCanvasItem);
- if (!d->context) {
+ if (!d->context || d->canvasWindow.size().isEmpty()) {
delete oldNode;
return 0;
}
@@ -697,8 +697,10 @@ QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
else
node->setFiltering(QSGTexture::Nearest);
- if (d->renderStrategy == QQuickCanvasItem::Cooperative)
+ if (d->renderStrategy == QQuickCanvasItem::Cooperative) {
+ d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, d->antialiasing);
d->context->flush();
+ }
node->setTexture(d->context->texture());
node->markDirty(QSGNode::DirtyMaterial);
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
index 237bd61c1b..d433efcb69 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
@@ -346,12 +346,9 @@ void QQuickContext2DCommandBuffer::replay(QPainter* p, QQuickContext2D::State& s
case QQuickContext2D::ClearRect:
{
QPainter::CompositionMode cm = p->compositionMode();
- qreal alpha = p->opacity();
- p->setCompositionMode(QPainter::CompositionMode_Source);
- p->setOpacity(0);
- p->fillRect(takeRect(), QColor(qRgba(0, 0, 0, 0)));
+ p->setCompositionMode(QPainter::CompositionMode_Clear);
+ p->fillRect(takeRect(), Qt::white);
p->setCompositionMode(cm);
- p->setOpacity(alpha);
break;
}
case QQuickContext2D::FillRect:
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index 9403b7967e..6fe4b39974 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -233,6 +233,8 @@ void QQuickImagePrivate::setImage(const QImage &image)
Image {
width: 120; height: 120
fillMode: Image.Tile
+ horizontalAlignment: Image.AlignLeft
+ verticalAlignment: Image.AlignTop
source: "qtlogo.png"
}
\endqml
@@ -244,6 +246,7 @@ void QQuickImagePrivate::setImage(const QImage &image)
Image {
width: 120; height: 120
fillMode: Image.TileVertically
+ verticalAlignment: Image.AlignTop
source: "qtlogo.png"
}
\endqml
@@ -255,6 +258,7 @@ void QQuickImagePrivate::setImage(const QImage &image)
Image {
width: 120; height: 120
fillMode: Image.TileHorizontally
+ verticalAlignment: Image.AlignLeft
source: "qtlogo.png"
}
\endqml
@@ -460,7 +464,7 @@ qreal QQuickImage::paintedHeight() const
\qmlproperty enumeration QtQuick2::Image::horizontalAlignment
\qmlproperty enumeration QtQuick2::Image::verticalAlignment
- Sets the horizontal and vertical alignment of the image. By default, the image is top-left aligned.
+ Sets the horizontal and vertical alignment of the image. By default, the image is center aligned.
The valid values for \c horizontalAlignment are \c Image.AlignLeft, \c Image.AlignRight and \c Image.AlignHCenter.
The valid values for \c verticalAlignment are \c Image.AlignTop, \c Image.AlignBottom
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 6d327b8d80..866d678412 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -286,8 +286,8 @@ void QSGContext::precompileMaterials()
QSG_PRECOMPILE_MATERIAL(QSGFlatColorMaterial);
QSG_PRECOMPILE_MATERIAL(QSGOpaqueTextureMaterial);
QSG_PRECOMPILE_MATERIAL(QSGTextureMaterial);
- QSG_PRECOMPILE_MATERIAL(SmoothTextureMaterial);
- QSG_PRECOMPILE_MATERIAL(SmoothColorMaterial);
+ QSG_PRECOMPILE_MATERIAL(QSGSmoothTextureMaterial);
+ QSG_PRECOMPILE_MATERIAL(QSGSmoothColorMaterial);
QSG_PRECOMPILE_MATERIAL(QSGDistanceFieldTextMaterial);
}
}
diff --git a/src/quick/scenegraph/qsgdefaultimagenode.cpp b/src/quick/scenegraph/qsgdefaultimagenode.cpp
index cadd18e833..aed69913fa 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultimagenode.cpp
@@ -87,24 +87,24 @@ protected:
};
-SmoothTextureMaterial::SmoothTextureMaterial()
+QSGSmoothTextureMaterial::QSGSmoothTextureMaterial()
{
setFlag(RequiresFullMatrixExceptTranslate, true);
setFlag(Blending, true);
}
-void SmoothTextureMaterial::setTexture(QSGTexture *texture)
+void QSGSmoothTextureMaterial::setTexture(QSGTexture *texture)
{
m_texture = texture;
}
-QSGMaterialType *SmoothTextureMaterial::type() const
+QSGMaterialType *QSGSmoothTextureMaterial::type() const
{
static QSGMaterialType type;
return &type;
}
-QSGMaterialShader *SmoothTextureMaterial::createShader() const
+QSGMaterialShader *QSGSmoothTextureMaterial::createShader() const
{
return new SmoothTextureMaterialShader;
}
diff --git a/src/quick/scenegraph/qsgdefaultimagenode_p.h b/src/quick/scenegraph/qsgdefaultimagenode_p.h
index d7be5f7c14..723943fd71 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultimagenode_p.h
@@ -48,10 +48,10 @@
QT_BEGIN_NAMESPACE
-class SmoothTextureMaterial : public QSGTextureMaterial
+class Q_QUICK_PRIVATE_EXPORT QSGSmoothTextureMaterial : public QSGTextureMaterial
{
public:
- SmoothTextureMaterial();
+ QSGSmoothTextureMaterial();
void setTexture(QSGTexture *texture);
@@ -90,7 +90,7 @@ private:
QSGOpaqueTextureMaterial m_material;
QSGTextureMaterial m_materialO;
- SmoothTextureMaterial m_smoothMaterial;
+ QSGSmoothTextureMaterial m_smoothMaterial;
uint m_antialiasing : 1;
uint m_mirror : 1;
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
index f642ca8d16..76fbbb4209 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
@@ -211,24 +211,24 @@ const char *SmoothColorMaterialShader::fragmentShader() const
"}";
}
-SmoothColorMaterial::SmoothColorMaterial()
+QSGSmoothColorMaterial::QSGSmoothColorMaterial()
{
setFlag(RequiresFullMatrixExceptTranslate, true);
setFlag(Blending, true);
}
-int SmoothColorMaterial::compare(const QSGMaterial *) const
+int QSGSmoothColorMaterial::compare(const QSGMaterial *) const
{
return 0;
}
-QSGMaterialType *SmoothColorMaterial::type() const
+QSGMaterialType *QSGSmoothColorMaterial::type() const
{
static QSGMaterialType type;
return &type;
}
-QSGMaterialShader *SmoothColorMaterial::createShader() const
+QSGMaterialShader *QSGSmoothColorMaterial::createShader() const
{
return new SmoothColorMaterialShader;
}
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
index 9ca8a96de5..1994e015e9 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
@@ -51,10 +51,10 @@ QT_BEGIN_NAMESPACE
class QSGContext;
-class SmoothColorMaterial : public QSGMaterial
+class Q_QUICK_PRIVATE_EXPORT QSGSmoothColorMaterial : public QSGMaterial
{
public:
- SmoothColorMaterial();
+ QSGSmoothColorMaterial();
int compare(const QSGMaterial *other) const;
@@ -83,7 +83,7 @@ private:
void updateGradientTexture();
QSGVertexColorMaterial m_material;
- SmoothColorMaterial m_smoothMaterial;
+ QSGSmoothColorMaterial m_smoothMaterial;
QRectF m_rect;
QGradientStops m_gradient_stops;
diff --git a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
index a790c7b9de..3eea3c955c 100644
--- a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
+++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
@@ -71,6 +71,9 @@ private slots:
void removeProvider_data();
void removeProvider();
+ void imageProviderId_data();
+ void imageProviderId();
+
void threadTest();
private:
@@ -372,6 +375,31 @@ void tst_qquickimageprovider::removeProvider()
delete obj;
}
+void tst_qquickimageprovider::imageProviderId_data()
+{
+ QTest::addColumn<QString>("providerId");
+
+ QTest::newRow("lowercase") << QStringLiteral("imageprovider");
+ QTest::newRow("CamelCase") << QStringLiteral("ImageProvider");
+ QTest::newRow("UPPERCASE") << QStringLiteral("IMAGEPROVIDER");
+}
+
+void tst_qquickimageprovider::imageProviderId()
+{
+ QFETCH(QString, providerId);
+
+ QQmlEngine engine;
+
+ bool deleteWatch = false;
+ TestQImageProvider *provider = new TestQImageProvider(&deleteWatch);
+
+ engine.addImageProvider(providerId, provider);
+ QVERIFY(engine.imageProvider(providerId) != 0);
+
+ engine.removeImageProvider(providerId);
+ QVERIFY(deleteWatch);
+}
+
class TestThreadProvider : public QQuickImageProvider
{
public: