summaryrefslogtreecommitdiff
path: root/src/effects/private/qgfxshaderbuilder_p.h
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2015-01-19 20:05:22 +0100
committerGunnar Sletta <gunnar@sletta.org>2015-03-13 09:07:20 +0000
commit81a27fa85f5656d3784d7d4fdcd99d3c66ebb446 (patch)
treef9128276b78a4684723b73b4ecb68f20700667aa /src/effects/private/qgfxshaderbuilder_p.h
parent64fdf70c2249c20895101a7428a9828825a00542 (diff)
downloadqtgraphicaleffects-81a27fa85f5656d3784d7d4fdcd99d3c66ebb446.tar.gz
Improve Gaussian Blur.
The shader source generation has been moved to C++ and the following improvements have been made to the algorithm: - Rely on linear sampling to roughly halve the number of samples required to perform blurring, while still mathmatically accurate. - Avoid dependent texture reads by calculating the sample positions in the vertex shader. This only works if the vec2 is used in texture2D() directly from the varying without any arithmetic and no swizzle mask applied. The fragment shader can then in many cases prefetch the texture value. - Implement a fallback shader which is used when samples exceed the maximum number of varyings. The old implementation supported 32 samples. The new one switches to the fallback when the required samples / 2 exceeds the number of available varying registers on the GPU. The fallback shader is equivalent to the old code performance wise, but supports an arbitrary high number of samples. [ChangeLog] Gaussian Blur has a new implementation. Faster for smaller kernels, similar for larger kernels but allows arbitrarily large kernels. The fast version will support at least 15x15 kernels on OpenGL ES and 59x59 kernels on Desktop GL. GaussianBlur.deviation is now a very costly parameter to change. Change-Id: I1ac44633ec6b3b667ebfab2211fa53e706804787 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/effects/private/qgfxshaderbuilder_p.h')
-rw-r--r--src/effects/private/qgfxshaderbuilder_p.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/effects/private/qgfxshaderbuilder_p.h b/src/effects/private/qgfxshaderbuilder_p.h
new file mode 100644
index 0000000..3ec993d
--- /dev/null
+++ b/src/effects/private/qgfxshaderbuilder_p.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Graphical Effects module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGFXSHADERBUILDER_P_H
+#define QGFXSHADERBUILDER_P_H
+
+#include <QtCore/QObject>
+#include <QtCore/QVariantMap>
+
+#include <QtQml/QJSValue>
+
+QT_BEGIN_NAMESPACE
+
+class QGfxShaderBuilder : public QObject
+{
+ Q_OBJECT
+
+public:
+ QGfxShaderBuilder();
+
+ Q_INVOKABLE QVariantMap gaussianBlur(const QJSValue &parameters);
+
+private:
+ int m_maxBlurSamples;
+};
+
+QT_END_NAMESPACE
+
+#endif // QGFXSHADERBUILDER_P_H