summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-11-21 10:34:57 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-11-21 10:34:57 +0100
commit10a83691db650fe27666d44223e099df21073b42 (patch)
tree11e566a4a3f316390f8cb557be33b2987ed63779
parentfbcebfb7f8ef8ee0c16ff0a86a7b27c69202fd2e (diff)
parent5d458e1ef23274921295bfbc20bebf439643d1a2 (diff)
downloadqtgraphicaleffects-10a83691db650fe27666d44223e099df21073b42.tar.gz
Merge remote-tracking branch 'origin/5.6' into dev
Change-Id: I83d4e298518a902e078174f9ab45835711252623
-rw-r--r--dist/changes-5.6.055
-rw-r--r--src/effects/GaussianBlur.qml21
-rw-r--r--src/effects/private/DropShadowBase.qml10
-rw-r--r--src/effects/private/qgfxshaderbuilder.cpp13
-rw-r--r--src/effects/private/qmldir1
-rw-r--r--src/effects/qmldir1
-rw-r--r--tests/auto/tst_qtgraphicaleffects.cpp4
7 files changed, 79 insertions, 26 deletions
diff --git a/dist/changes-5.6.0 b/dist/changes-5.6.0
new file mode 100644
index 0000000..276c1f6
--- /dev/null
+++ b/dist/changes-5.6.0
@@ -0,0 +1,55 @@
+Qt 5.6 introduces many new features and improvements as well as bugfixes
+over the 5.6.x series. For more details, refer to the online documentation
+included in this distribution. The documentation is also available online:
+
+ http://doc.qt.io/qt-5.6
+
+The Qt version 5.6 series is binary compatible with the 5.5.x series.
+Applications compiled for 5.5 will continue to run with 5.6.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+ http://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* General
+****************************************************************************
+
+ - 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 potentially costly parameter to change and it should not be
+ animated.
+
+ - When defining blur based effects, like Glow, DropShadow and GaussianBlur,
+ prefer to specify 'samples' to be an odd number and let radius be the default.
+ This gives the best effect. Animate the blur by animating 'radius' from 0 to
+ floor(samples/2). Using a 'radius' which is higher than samples/2 will
+ result in artifacts.
+
+ - The internal SourceProxy class has been moved from QML/JS to C++ to
+ allow better control over when the proxy is used. As a result, the
+ graphical effect library now has a c++ based plugin in addition to
+ QML/JS source files.
+
+ - The 'fast' property of various blur-based implementations no longer has
+ any effect. The blurring algorithm used is the same for all.
+
+ - 'DropShadow::transparentBorder', 'GaussianBlur::transparentBorder' and
+ 'Glow::transparentBorder' have been changed to be true by default.
+
+ - 'MaskedBlur::transparentBorder' has no effect as the mask will anyway
+ have alpha==0 outside the mask source's pixels.
+
+ - 'GaussianBlur::samples', 'DropShadow::samples', 'Glow::samples' and
+ 'MaskedBlur::samples' are 9 by default.
+
+ - When applying an effect to Item::layer.effect, the effect will now update
+ the layer properties to make the effect work, such as setting
+ 'Layer::smooth' to 'true' and changing 'Layer::sourceRect' to take
+ 'transparentBorder' into account.
diff --git a/src/effects/GaussianBlur.qml b/src/effects/GaussianBlur.qml
index 82bc290..70943a0 100644
--- a/src/effects/GaussianBlur.qml
+++ b/src/effects/GaussianBlur.qml
@@ -253,9 +253,9 @@ Item {
// private members...
/*! \internal */
- property int _paddedTexWidth: transparentBorder ? width + 2 * _kernelRadius: width;
+ property int _paddedTexWidth: transparentBorder ? width + 2 * radius: width;
/*! \internal */
- property int _paddedTexHeight: transparentBorder ? height + 2 * _kernelRadius: height;
+ property int _paddedTexHeight: transparentBorder ? height + 2 * radius: height;
/*! \internal */
property int _kernelRadius: Math.max(0, samples / 2);
/*! \internal */
@@ -285,14 +285,13 @@ Item {
/*! \internal */
function _rebuildShaders() {
- if (samples < 1)
- return;
-
var params = {
radius: _kernelRadius,
- deviation: deviation,
+ // Limit deviation to something very small avoid getting NaN in the shader.
+ deviation: Math.max(0.00001, deviation),
alphaOnly: root._alphaOnly,
- masked: _maskSource != undefined
+ masked: _maskSource != undefined,
+ fallback: root.radius != _kernelRadius
}
var shaders = ShaderBuilder.gaussianBlur(params);
horizontalBlur.fragmentShader = shaders.fragmentShader;
@@ -304,7 +303,7 @@ Item {
interpolation: SourceProxy.LinearInterpolation
input: root.source
sourceRect: root.transparentBorder
- ? Qt.rect(-root._kernelRadius, 0, root._paddedTexWidth, parent.height)
+ ? Qt.rect(-root.radius, 0, root._paddedTexWidth, parent.height)
: Qt.rect(0, 0, 0, 0)
}
@@ -320,7 +319,6 @@ Item {
// Used by fallback shader (sampleCount exceeds number of varyings)
property real deviation: root.deviation
- property real radius: root._kernelRadius
// Only in use for DropShadow and Glow
property color color: "white"
@@ -332,7 +330,7 @@ Item {
layer.enabled: true
layer.smooth: true
layer.sourceRect: root.transparentBorder
- ? Qt.rect(0, -root._kernelRadius, width, root._paddedTexHeight)
+ ? Qt.rect(0, -root.radius, width, root._paddedTexHeight)
: Qt.rect(0, 0, 0, 0)
visible: false
blending: false
@@ -340,7 +338,7 @@ Item {
ShaderEffect {
id: verticalBlur
- x: transparentBorder ? -root._kernelRadius : 0
+ x: transparentBorder ? -root.radius : 0
y: x;
width: root.transparentBorder ? root._paddedTexWidth: root.width
height: root.transparentBorder ? root._paddedTexHeight : root.height;
@@ -352,7 +350,6 @@ Item {
property var dirstep: Qt.vector2d(0, 1 / (root._paddedTexHeight * root._dpr));
property real deviation: horizontalBlur.deviation
- property real radius: horizontalBlur.radius
property color color: "black"
property real thickness: horizontalBlur.thickness;
diff --git a/src/effects/private/DropShadowBase.qml b/src/effects/private/DropShadowBase.qml
index 8cc259c..3660619 100644
--- a/src/effects/private/DropShadowBase.qml
+++ b/src/effects/private/DropShadowBase.qml
@@ -46,11 +46,11 @@ Item {
id: root
property variant source
- property int radius: samples / 2
+ property real radius: Math.floor(samples / 2)
property int samples: 9
property color color: "black"
- property int horizontalOffset: 0
- property int verticalOffset: 0
+ property real horizontalOffset: 0
+ property real verticalOffset: 0
property real spread: 0.0
property bool cached: false
property bool transparentBorder: true
@@ -59,8 +59,8 @@ Item {
id: blur
width: parent.width
height: parent.height
- x: horizontalOffset
- y: verticalOffset
+ x: Math.round(horizontalOffset)
+ y: Math.round(verticalOffset)
source: root.source
radius: root.radius
samples: root.samples
diff --git a/src/effects/private/qgfxshaderbuilder.cpp b/src/effects/private/qgfxshaderbuilder.cpp
index 87b1a45..fe1d7fe 100644
--- a/src/effects/private/qgfxshaderbuilder.cpp
+++ b/src/effects/private/qgfxshaderbuilder.cpp
@@ -46,7 +46,11 @@
#endif
#ifndef GL_MAX_VARYING_FLOATS
-#define GL_MAX_VARYING_FLOATS 0x8DFC
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#endif
+
+#ifndef GL_MAX_VARYING_VECTORS
+#define GL_MAX_VARYING_VECTORS 0x8DFC
#endif
QGfxShaderBuilder::QGfxShaderBuilder()
@@ -308,10 +312,11 @@ QVariantMap QGfxShaderBuilder::gaussianBlur(const QJSValue &parameters)
int requestedSamples = requestedRadius * 2 + 1;
int samples = 1 + requestedSamples / 2;
int radius = requestedSamples / 4;
+ bool fallback = parameters.property(QStringLiteral("fallback")).toBool();
QVariantMap result;
- if (samples > m_maxBlurSamples || masked) {
+ if (samples > m_maxBlurSamples || masked || fallback) {
QByteArray fragShader;
if (masked)
fragShader += "uniform mediump sampler2D mask;\n";
@@ -350,9 +355,9 @@ QVariantMap QGfxShaderBuilder::gaussianBlur(const QJSValue &parameters)
fragShader += ".a";
fragShader += ";\n";
}
- fragShader += " const mediump float wSum = ";
+ fragShader += " const mediump float wSum = float(";
fragShader += QByteArray::number(wSum);
- fragShader += ";\n"
+ fragShader += ");\n"
" gl_FragColor = ";
if (alphaOnly)
fragShader += "mix(vec4(0), color, clamp((result / wSum) / thickness, 0.0, 1.0)) * qt_Opacity;\n";
diff --git a/src/effects/private/qmldir b/src/effects/private/qmldir
index aad4a1c..93e78c7 100644
--- a/src/effects/private/qmldir
+++ b/src/effects/private/qmldir
@@ -1,5 +1,6 @@
module QtGraphicalEffects.private
plugin qtgraphicaleffectsprivate
+classname QtGraphicalEffectsPlugin
FastGlow 1.0 FastGlow.qml
FastInnerShadow 1.0 FastInnerShadow.qml
FastMaskedBlur 1.0 FastMaskedBlur.qml
diff --git a/src/effects/qmldir b/src/effects/qmldir
index e16013f..6a78b6b 100644
--- a/src/effects/qmldir
+++ b/src/effects/qmldir
@@ -1,4 +1,3 @@
-classname QtGraphicalEffectsPlugin
Blend 1.0 Blend.qml
BrightnessContrast 1.0 BrightnessContrast.qml
Colorize 1.0 Colorize.qml
diff --git a/tests/auto/tst_qtgraphicaleffects.cpp b/tests/auto/tst_qtgraphicaleffects.cpp
index 8c93f9c..a0104d8 100644
--- a/tests/auto/tst_qtgraphicaleffects.cpp
+++ b/tests/auto/tst_qtgraphicaleffects.cpp
@@ -457,14 +457,11 @@ void tst_qtgraphicaleffects::dropShadow()
QVERIFY(obj != 0);
// Default values
- QEXPECT_FAIL("", "QTBUG-48625", Continue);
QCOMPARE(obj->property("radius").type(), QVariant::Double);
QCOMPARE(obj->property("radius").toDouble(), 4.0);
QCOMPARE(obj->property("samples").toInt(), 9);
- QEXPECT_FAIL("", "QTBUG-48625", Continue);
QCOMPARE(obj->property("horizontalOffset").type(), QVariant::Double);
QCOMPARE(obj->property("horizontalOffset").toDouble(), 0.0);
- QEXPECT_FAIL("", "QTBUG-48625", Continue);
QCOMPARE(obj->property("verticalOffset").type(), QVariant::Double);
QCOMPARE(obj->property("verticalOffset").toDouble(), 0.0);
QCOMPARE(obj->property("cached").toBool(), false);
@@ -583,7 +580,6 @@ void tst_qtgraphicaleffects::glow()
QVERIFY(obj != 0);
// Default values
- QEXPECT_FAIL("", "QTBUG-48625", Continue);
QCOMPARE(obj->property("radius").type(), QVariant::Double);
QCOMPARE(obj->property("radius").toDouble(), 4.0);
QCOMPARE(obj->property("samples").toInt(), 9);