Added documentation for GridMesh.
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>
Wed, 18 May 2011 11:48:18 +0000 (13:48 +0200)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>
Wed, 18 May 2011 13:09:41 +0000 (15:09 +0200)
doc/src/images/declarative-gridmesh.png [new file with mode: 0644]
src/declarative/items/qsgshadereffectmesh.cpp

diff --git a/doc/src/images/declarative-gridmesh.png b/doc/src/images/declarative-gridmesh.png
new file mode 100644 (file)
index 0000000..6007d3b
Binary files /dev/null and b/doc/src/images/declarative-gridmesh.png differ
index 192e95c..4900755 100644 (file)
@@ -50,6 +50,48 @@ QSGShaderEffectMesh::QSGShaderEffectMesh(QObject *parent)
 {
 }
 
+/*!
+    \qmlclass GridMesh QSGGridMesh
+    \since 5.0
+    \ingroup qml-utility-elements
+    \brief GridMesh defines a mesh to be used with \l ShaderEffectItem.
+
+    GridMesh defines a rectangular mesh consisting of vertices arranged in an
+    evenly spaced grid. It can be assigned to the \l ShaderEffectItem's mesh
+    property. The grid resolution is specified with the \l resolution property.
+    
+    \row
+    \o \image declarative-gridmesh.png
+    \o \qml
+        import QtQuick 2.0
+
+        ShaderEffectItem {
+            width: 200
+            height: 200
+            mesh: GridMesh { resolution: Qt.size(20, 20) }
+            property variant source: Image {
+                source: "qt-logo.png"
+                sourceSize {width: 200; height: 200 }
+                smooth: true
+            }
+            vertexShader: "
+                uniform highp mat4 qt_ModelViewProjectionMatrix;
+                attribute highp vec4 qt_Vertex;
+                attribute highp vec2 qt_MultiTexCoord0;
+                varying highp vec2 qt_TexCoord0;
+                uniform highp float width;
+                void main() {
+                    highp vec4 pos = qt_Vertex;
+                    highp float d = .5 * smoothstep(0., 1., qt_MultiTexCoord0.y);
+                    pos.x = width * mix(d, 1.0 - d, qt_MultiTexCoord0.x);
+                    gl_Position = qt_ModelViewProjectionMatrix * pos;
+                    qt_TexCoord0 = qt_MultiTexCoord0;
+                }"
+        }
+        \endqml
+    \endrow
+
+*/
 
 QSGGridMesh::QSGGridMesh(QObject *parent)
     : QSGShaderEffectMesh(parent)
@@ -90,7 +132,7 @@ QSGGeometry *QSGGridMesh::updateGeometry(QSGGeometry *geometry, const QVector<QB
             break;
         default:
             qWarning("QSGGridMesh:: Too many attributes specified.");
-            break;;
+            break;
         }
 
         if (error) {
@@ -147,6 +189,15 @@ QSGGeometry *QSGGridMesh::updateGeometry(QSGGeometry *geometry, const QVector<QB
     return geometry;
 }
 
+/*!
+    \qmlproperty size GridMesh::resolution
+
+    This property holds the grid resolution. The resolution's width and height
+    specify the number of cells or spacings between vertices horizontally and
+    vertically respectively. The minimum and default is 1x1, which corresponds
+    to four vertices in total, one in each corner.
+*/
+
 void QSGGridMesh::setResolution(const QSize &res)
 {
     if (res == m_resolution)