diff options
author | Marko Niemelä <marko.a.niemela@nokia.com> | 2012-04-03 13:47:57 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-05 09:14:30 +0200 |
commit | 6c901d493c88654ecc649cdc6d65d9e250a5536a (patch) | |
tree | df782c7bee6c307005c42a3ff28a9491303126a9 /src | |
parent | df03a90db11a2a8bb4a9e5dd6ca05723e0bd3d60 (diff) | |
download | qtgraphicaleffects-6c901d493c88654ecc649cdc6d65d9e250a5536a.tar.gz qtgraphicaleffects-6c901d493c88654ecc649cdc6d65d9e250a5536a.tar.bz2 qtgraphicaleffects-6c901d493c88654ecc649cdc6d65d9e250a5536a.zip |
Optimized Directional, Radial and ZoomBlur effects.
Weight multiplication was inside the unrolled loop,
moved that to the end of the shader. Additionally
expand calculation is now done with vectors.
Change-Id: Idc27e9dfd2d6911d3e65d093fb043a07cb912a1c
Reviewed-by: Kim Gronholm <kim.1.gronholm@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/effects/DirectionalBlur.qml | 7 | ||||
-rw-r--r-- | src/effects/RadialBlur.qml | 7 | ||||
-rw-r--r-- | src/effects/ZoomBlur.qml | 10 |
3 files changed, 10 insertions, 14 deletions
diff --git a/src/effects/DirectionalBlur.qml b/src/effects/DirectionalBlur.qml index 47cc2ac..63e1c0a 100644 --- a/src/effects/DirectionalBlur.qml +++ b/src/effects/DirectionalBlur.qml @@ -103,7 +103,7 @@ Item { PLACEHOLDER_UNROLLED_LOOP - gl_FragColor *= qt_Opacity; + gl_FragColor *= weight * qt_Opacity; } " @@ -112,8 +112,7 @@ Item { var expandSteps = "" if (transparentBorder) { - expandSteps += "texCoord.s = (texCoord.s - expand.x) / (1.0 - 2.0 * expand.x);" - expandSteps += "texCoord.t = (texCoord.t - expand.y) / (1.0 - 2.0 * expand.y);" + expandSteps += "texCoord = (texCoord - expand) / (1.0 - 2.0 * expand);" } var unrolledLoop = "gl_FragColor += texture2D(source, texCoord);\n" @@ -121,7 +120,7 @@ Item { if (rootItem.samples > 1) { unrolledLoop = "" for (var i = 0; i < rootItem.samples; i++) - unrolledLoop += "gl_FragColor += texture2D(source, texCoord) * weight; texCoord += shift;\n" + unrolledLoop += "gl_FragColor += texture2D(source, texCoord); texCoord += shift;\n" } shader = shader.replace("PLACEHOLDER_EXPAND_STEPS", expandSteps) diff --git a/src/effects/RadialBlur.qml b/src/effects/RadialBlur.qml index aff3c3d..830ebec 100644 --- a/src/effects/RadialBlur.qml +++ b/src/effects/RadialBlur.qml @@ -121,7 +121,7 @@ Item { PLACEHOLDER_UNROLLED_LOOP - gl_FragColor *= qt_Opacity; + gl_FragColor *= weight * qt_Opacity; } " @@ -130,8 +130,7 @@ Item { var expandSteps = "" if (transparentBorder) { - expandSteps += "texCoord.s = (texCoord.s - expand.x) / (1.0 - 2.0 * expand.x);" - expandSteps += "texCoord.t = (texCoord.t - expand.y) / (1.0 - 2.0 * expand.y);" + expandSteps += "texCoord = (texCoord - expand) / (1.0 - 2.0 * expand);" } var unrolledLoop = "gl_FragColor += texture2D(source, texCoord);\n" @@ -139,7 +138,7 @@ Item { if (rootItem.samples > 1) { unrolledLoop = "" for (var i = 0; i < rootItem.samples; i++) - unrolledLoop += "texCoord = vec2(center.x + dir.x * delta.x, center.y + dir.y * delta.y); gl_FragColor += texture2D(source, texCoord) * weight; dir *= m;\n" + unrolledLoop += "gl_FragColor += texture2D(source, center + dir * delta); dir *= m;\n" } shader = shader.replace("PLACEHOLDER_EXPAND_STEPS", expandSteps) diff --git a/src/effects/ZoomBlur.qml b/src/effects/ZoomBlur.qml index 83c6173..c784014 100644 --- a/src/effects/ZoomBlur.qml +++ b/src/effects/ZoomBlur.qml @@ -108,7 +108,7 @@ Item { PLACEHOLDER_UNROLLED_LOOP - gl_FragColor *= qt_Opacity; + gl_FragColor *= weight * qt_Opacity; } " @@ -117,10 +117,8 @@ Item { var expandSteps = "" if (transparentBorder) { - expandSteps += "centerCoord.s = (centerCoord.s - expand.x) / (1.0 - 2.0 * expand.x);" - expandSteps += "centerCoord.t = (centerCoord.t - expand.y) / (1.0 - 2.0 * expand.y);" - expandSteps += "texCoord.s = (texCoord.s - expand.x) / (1.0 - 2.0 * expand.x);" - expandSteps += "texCoord.t = (texCoord.t - expand.y) / (1.0 - 2.0 * expand.y);" + expandSteps += "centerCoord = (centerCoord - expand) / (1.0 - 2.0 * expand);" + expandSteps += "texCoord = (texCoord - expand) / (1.0 - 2.0 * expand);" } var unrolledLoop = "gl_FragColor += texture2D(source, texCoord);\n" @@ -128,7 +126,7 @@ Item { if (rootItem.samples > 1) { unrolledLoop = "" for (var i = 0; i < rootItem.samples; i++) - unrolledLoop += "gl_FragColor += texture2D(source, texCoord) * weight; texCoord += shift;\n" + unrolledLoop += "gl_FragColor += texture2D(source, texCoord); texCoord += shift;\n" } shader = shader.replace("PLACEHOLDER_EXPAND_STEPS", expandSteps) |