diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/effects/DirectionalBlur.qml | 25 | ||||
-rw-r--r-- | src/effects/GaussianBlur.qml | 12 | ||||
-rw-r--r-- | src/effects/RadialBlur.qml | 30 | ||||
-rw-r--r-- | src/effects/RecursiveBlur.qml | 84 | ||||
-rw-r--r-- | src/effects/ZoomBlur.qml | 23 | ||||
-rw-r--r-- | src/effects/internal/DirectionalGaussianBlur.qml | 78 | ||||
-rw-r--r-- | src/effects/internal/DirectionalGaussianMaskedBlur.qml | 78 | ||||
-rw-r--r-- | src/effects/internal/GaussianGlow.qml | 11 | ||||
-rw-r--r-- | src/effects/internal/GaussianMaskedBlur.qml | 12 | ||||
-rw-r--r-- | src/effects/internal/SourceProxy.qml | 27 |
10 files changed, 210 insertions, 170 deletions
diff --git a/src/effects/DirectionalBlur.qml b/src/effects/DirectionalBlur.qml index 487057c..a53a802 100644 --- a/src/effects/DirectionalBlur.qml +++ b/src/effects/DirectionalBlur.qml @@ -53,6 +53,7 @@ Item { SourceProxy { id: sourceProxy input: rootItem.source + sourceRect: rootItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2.0, parent.height + 2.0) : Qt.rect(0, 0, 0, 0) } ShaderEffectSource { @@ -74,14 +75,12 @@ Item { property real weight: 1 / rootItem.samples property variant expandPixels: transparentBorder ? Qt.size(rootItem.samples, rootItem.samples) : Qt.size(0,0) property variant expand: transparentBorder ? Qt.size(expandPixels.width / width, expandPixels.height / height) : Qt.size(0,0) - property variant pixelSize: Qt.size(1.0 / (width / (1.0 - 2 * expand.width)), 1.0 / (height / (1.0 - 2 * expand.height))) property variant delta: Qt.size(1.0 / rootItem.width * Math.cos((rootItem.angle + 90) * Math.PI/180), 1.0 / rootItem.height * Math.sin((rootItem.angle + 90) * Math.PI/180)) - x: transparentBorder ? -expandPixels.width : 0 - y: transparentBorder ? -expandPixels.height : 0 - width: transparentBorder ? parent.width + 2.0 * expandPixels.width : parent.width - height: transparentBorder ? parent.height + 2.0 * expandPixels.height : parent.height - + x: transparentBorder ? -expandPixels.width - 1: 0 + y: transparentBorder ? -expandPixels.height - 1 : 0 + width: transparentBorder ? parent.width + 2.0 * expandPixels.width + 2 : parent.width + height: transparentBorder ? parent.height + 2.0 * expandPixels.height + 2 : parent.height property string fragmentShaderSkeleton: " varying highp vec2 qt_TexCoord0; @@ -91,15 +90,10 @@ Item { uniform highp float samples; uniform highp float weight; uniform highp vec2 expand; - uniform highp vec2 pixelSize; uniform highp vec2 delta; - highp float linearstep(highp float e0, highp float e1, highp float x) { - return clamp((x - e0) / (e1 - e0), 0.0, 1.0); - } - void main(void) { - highp vec2 shift = vec2(delta.x, delta.y) * len / max(1.0, samples - 1.0); + highp vec2 shift = delta * len / max(1.0, samples - 1.0); mediump vec2 texCoord = qt_TexCoord0; gl_FragColor = vec4(0.0); @@ -116,21 +110,18 @@ Item { function buildFragmentShader() { var shader = fragmentShaderSkeleton var expandSteps = "" - var linearSteps = "" 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 += "highp vec2 stepSize = vec2(1.0 - pixelSize.x, 1.0 - pixelSize.y);" - linearSteps = "* linearstep(0.0, pixelSize.x, texCoord.s) * linearstep(1.0, stepSize.x, texCoord.s) * linearstep(0.0, pixelSize.y, texCoord.t) * linearstep(1.0, stepSize.y, texCoord.t)" } - var unrolledLoop = "gl_FragColor += texture2D(source, texCoord) " + linearSteps + ";\n" + var unrolledLoop = "gl_FragColor += texture2D(source, texCoord);\n" if (rootItem.samples > 1) { unrolledLoop = "" for (var i = 0; i < rootItem.samples; i++) - unrolledLoop += "gl_FragColor += texture2D(source, texCoord) * weight " + linearSteps + "; texCoord += shift;\n" + unrolledLoop += "gl_FragColor += texture2D(source, texCoord) * weight; texCoord += shift;\n" } shader = shader.replace("PLACEHOLDER_EXPAND_STEPS", expandSteps) diff --git a/src/effects/GaussianBlur.qml b/src/effects/GaussianBlur.qml index 423c020..19cd153 100644 --- a/src/effects/GaussianBlur.qml +++ b/src/effects/GaussianBlur.qml @@ -53,6 +53,7 @@ Item { SourceProxy { id: sourceProxy input: rootItem.source + sourceRect: rootItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2.0, parent.height + 2.0) : Qt.rect(0, 0, 0, 0) } ShaderEffectSource { @@ -67,15 +68,16 @@ Item { DirectionalGaussianBlur { id: verticalBlur - x: transparentBorder ? -maximumRadius : 0 - y: transparentBorder ? -maximumRadius : 0 + x: transparentBorder ? -maximumRadius - 1 : 0 + y: transparentBorder ? -maximumRadius - 1 : 0 width: horizontalBlur.width - height: transparentBorder ? horizontalBlur.height + 2 * maximumRadius : horizontalBlur.height + height: horizontalBlur.height horizontalStep: 0.0 verticalStep: 1.0 / parent.height source: ShaderEffectSource { + id: horizontalBlurSource sourceItem: horizontalBlur hideSource: true visible: false @@ -90,8 +92,8 @@ Item { DirectionalGaussianBlur { id: horizontalBlur - width: transparentBorder ? parent.width + 2 * maximumRadius : parent.width - height: parent.height + width: transparentBorder ? parent.width + 2 * maximumRadius + 2 : parent.width + height: transparentBorder ? parent.height + 2 * maximumRadius + 2 : parent.height horizontalStep: 1.0 / parent.width verticalStep: 0.0 diff --git a/src/effects/RadialBlur.qml b/src/effects/RadialBlur.qml index cab19a2..b44d134 100644 --- a/src/effects/RadialBlur.qml +++ b/src/effects/RadialBlur.qml @@ -54,6 +54,7 @@ Item { SourceProxy { id: sourceProxy input: rootItem.source + sourceRect: shaderItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2.0, parent.height + 2.0) : Qt.rect(0, 0, 0, 0) } ShaderEffectSource { @@ -77,15 +78,14 @@ Item { property real angleCosStep: Math.cos(-rootItem.angle * Math.PI/180 / Math.max(1.0, rootItem.samples - 1)) property variant expandPixels: transparentBorder ? Qt.size(0.5 * parent.height, 0.5 * parent.width) : Qt.size(0,0) property variant expand: transparentBorder ? Qt.size(expandPixels.width / width, expandPixels.height / height) : Qt.size(0,0) - property variant pixelSize: Qt.size(1.0 / (width / (1.0 - 2 * expand.width)), 1.0 / (height / (1.0 - 2 * expand.height))) property variant delta: Qt.size(1.0 / rootItem.width, 1.0 / rootItem.height) - property real w: width - property real h: height + property real w: parent.width + property real h: parent.height - x: transparentBorder ? -expandPixels.width : 0 - y: transparentBorder ? -expandPixels.height : 0 - width: transparentBorder ? parent.width + expandPixels.width * 2.0 : parent.width - height: transparentBorder ? parent.height + expandPixels.height * 2.0 : parent.height + x: transparentBorder ? -expandPixels.width - 1 : 0 + y: transparentBorder ? -expandPixels.height - 1 : 0 + width: transparentBorder ? parent.width + expandPixels.width * 2.0 + 2 : parent.width + height: transparentBorder ? parent.height + expandPixels.height * 2.0 + 2 : parent.height property string fragmentShaderSkeleton: " varying highp vec2 qt_TexCoord0; @@ -96,26 +96,21 @@ Item { uniform highp float weight; uniform highp vec2 expand; uniform highp vec2 center; - uniform highp vec2 pixelSize; uniform highp vec2 delta; uniform highp float w; uniform highp float h; - highp float linearstep(highp float e0, highp float e1, highp float x) { - return clamp((x - e0) / (e1 - e0), 0.0, 1.0); - } - void main(void) { highp mat2 m; m[0] = vec2(angleCosStep, -angleSinStep); m[1] = vec2(angleSinStep, angleCosStep); gl_FragColor = vec4(0.0); - highp vec2 dir = vec2(qt_TexCoord0.s * w - w * 0.5, qt_TexCoord0.t * h - h * 0.5); - mediump vec2 texCoord = qt_TexCoord0; PLACEHOLDER_EXPAND_STEPS + highp vec2 dir = vec2(texCoord.s * w - w * 0.5, texCoord.t * h - h * 0.5); + PLACEHOLDER_UNROLLED_LOOP gl_FragColor *= qt_Opacity; @@ -125,21 +120,18 @@ Item { function buildFragmentShader() { var shader = fragmentShaderSkeleton var expandSteps = "" - var linearSteps = "" 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 += "highp vec2 stepSize = vec2(1.0 - pixelSize.x, 1.0 - pixelSize.y);" - linearSteps = "* linearstep(0.0, pixelSize.x, texCoord.s) * linearstep(1.0, stepSize.x, texCoord.s) * linearstep(0.0, pixelSize.y, texCoord.t) * linearstep(1.0, stepSize.y, texCoord.t)" } - var unrolledLoop = "gl_FragColor += texture2D(source, texCoord) " + linearSteps + ";\n" + var unrolledLoop = "gl_FragColor += texture2D(source, texCoord);\n" 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 " + linearSteps + "; dir *= m;\n" + unrolledLoop += "texCoord = vec2(center.x + dir.x * delta.x, center.y + dir.y * delta.y); gl_FragColor += texture2D(source, texCoord) * weight; dir *= m;\n" } shader = shader.replace("PLACEHOLDER_EXPAND_STEPS", expandSteps) diff --git a/src/effects/RecursiveBlur.qml b/src/effects/RecursiveBlur.qml index 935bb3c..4b44aff 100644 --- a/src/effects/RecursiveBlur.qml +++ b/src/effects/RecursiveBlur.qml @@ -58,16 +58,17 @@ Item { SourceProxy { id: sourceProxy input: rootItem.source + sourceRect: rootItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2, parent.height + 2) : Qt.rect(0, 0, 0, 0) } ShaderEffectSource { id: cacheItem - anchors.fill: parent + anchors.fill: verticalBlur smooth: true visible: rootItem.cached hideSource: visible live: true - sourceItem: blurItem + sourceItem: inputItem.visible ? inputItem : verticalBlur } Item { @@ -84,7 +85,7 @@ Item { recursionTimer.counter = 0 if (counter > 0) - recursiveSource.sourceItem = blurItem + recursiveSource.sourceItem = verticalBlur else recursiveSource.sourceItem = inputItem @@ -98,8 +99,37 @@ Item { ShaderEffect { id: inputItem property variant source: sourceProxy.output - anchors.fill: parent - visible: !blurItem.visible + property real expandX: rootItem.transparentBorder ? (horizontalBlur.maximumRadius) / horizontalBlur.width : 0.0 + property real expandY: rootItem.transparentBorder ? (horizontalBlur.maximumRadius) / horizontalBlur.height : 0.0 + + anchors.fill: verticalBlur + visible: !verticalBlur.visible + + vertexShader: " + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp mat4 qt_Matrix; + uniform highp float expandX; + uniform highp float expandY; + varying highp vec2 qt_TexCoord0; + + void main() { + mediump vec2 texCoord = qt_MultiTexCoord0; + texCoord.s = (texCoord.s - expandX) / (1.0 - 2.0 * expandX); + texCoord.t = (texCoord.t - expandY) / (1.0 - 2.0 * expandY); + qt_TexCoord0 = texCoord; + gl_Position = qt_Matrix * qt_Vertex; + } + " + + fragmentShader: " + varying mediump vec2 qt_TexCoord0; + uniform highp float qt_Opacity; + uniform sampler2D source; + void main() { + gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; + } + " } ShaderEffectSource { @@ -114,15 +144,43 @@ Item { onScheduledUpdateCompleted: recursionTimer.nextFrame() } - GaussianBlur { - id: blurItem - visible: loops > 0 - anchors.fill: parent - radius: rootItem.radius - samples: Math.ceil(2.0 * rootItem.radius) + DirectionalGaussianBlur { + id: verticalBlur + x: rootItem.transparentBorder ? -horizontalBlur.maximumRadius - 1 : 0 + y: rootItem.transparentBorder ? -horizontalBlur.maximumRadius - 1 : 0 + width: horizontalBlur.width + 2 + height: horizontalBlur.height + 2 + + horizontalStep: 0.0 + verticalStep: 1.0 / parent.height + + source: ShaderEffectSource { + sourceItem: horizontalBlur + hideSource: true + visible: false + smooth: true + } + deviation: (radius + 1) / 2.3333 - transparentBorder: rootItem.transparentBorder - cached: false + radius: rootItem.radius + maximumRadius: Math.ceil(rootItem.radius) + transparentBorder: false + visible: loops > 0 + } + + DirectionalGaussianBlur { + id: horizontalBlur + width: rootItem.transparentBorder ? parent.width + 2 * maximumRadius + 2 : parent.width + height: rootItem.transparentBorder ? parent.height + 2 * maximumRadius + 2 : parent.height + + horizontalStep: 1.0 / parent.width + verticalStep: 0.0 + source: recursiveSource + deviation: (radius + 1) / 2.3333 + radius: rootItem.radius + maximumRadius: Math.ceil(rootItem.radius) + transparentBorder: false + visible: false } } diff --git a/src/effects/ZoomBlur.qml b/src/effects/ZoomBlur.qml index 419e278..bd13b65 100644 --- a/src/effects/ZoomBlur.qml +++ b/src/effects/ZoomBlur.qml @@ -54,6 +54,7 @@ Item { SourceProxy { id: sourceProxy input: rootItem.source + sourceRect: rootItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2.0, parent.height + 2.0) : Qt.rect(0, 0, 0, 0) } ShaderEffectSource { @@ -76,13 +77,12 @@ Item { property real weight: 1.0 / Math.max(1.0, rootItem.samples) property variant expandPixels: transparentBorder ? Qt.size(rootItem.samples, rootItem.samples) : Qt.size(0,0) property variant expand: transparentBorder ? Qt.size(expandPixels.width / width, expandPixels.height / height) : Qt.size(0,0) - property variant pixelSize: Qt.size(1.0 / (width / (1.0 - 2 * expand.width)), 1.0 / (height / (1.0 - 2 * expand.height))) property variant delta: Qt.size(1.0 / rootItem.width, 1.0 / rootItem.height) - x: transparentBorder ? -expandPixels.width : 0 - y: transparentBorder ? -expandPixels.height : 0 - width: transparentBorder ? parent.width + 2.0 * expandPixels.width : parent.width - height: transparentBorder ? parent.height + 2.0 * expandPixels.height : parent.height + x: transparentBorder ? -expandPixels.width - 1 : 0 + y: transparentBorder ? -expandPixels.height - 1 : 0 + width: transparentBorder ? parent.width + 2.0 * expandPixels.width + 2 : parent.width + height: transparentBorder ? parent.height + 2.0 * expandPixels.height + 2 : parent.height property string fragmentShaderSkeleton: " varying highp vec2 qt_TexCoord0; @@ -93,13 +93,8 @@ Item { uniform highp float samples; uniform highp vec2 center; uniform highp vec2 expand; - uniform highp vec2 pixelSize; uniform highp vec2 delta; - highp float linearstep(highp float e0, highp float e1, highp float x) { - return clamp((x - e0) / (e1 - e0), 0.0, 1.0); - } - void main(void) { mediump vec2 texCoord = qt_TexCoord0; mediump vec2 centerCoord = center; @@ -108,7 +103,6 @@ Item { highp vec2 dir = vec2(centerCoord.x - texCoord.s, centerCoord.y - texCoord.t); dir /= max(1.0, length(dir) * 2.0); - highp vec2 shift = delta * len * dir * 2.0 / max(1.0, samples - 1.0); gl_FragColor = vec4(0.0); @@ -121,23 +115,20 @@ Item { function buildFragmentShader() { var shader = fragmentShaderSkeleton var expandSteps = "" - var linearSteps = "" 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 += "highp vec2 stepSize = vec2(1.0 - pixelSize.x, 1.0 - pixelSize.y);" - linearSteps = "* linearstep(0.0, pixelSize.x, texCoord.s) * linearstep(1.0, stepSize.x, texCoord.s) * linearstep(0.0, pixelSize.y, texCoord.t) * linearstep(1.0, stepSize.y, texCoord.t)" } - var unrolledLoop = "gl_FragColor += texture2D(source, texCoord) " + linearSteps + ";\n" + var unrolledLoop = "gl_FragColor += texture2D(source, texCoord);\n" if (rootItem.samples > 1) { unrolledLoop = "" for (var i = 0; i < rootItem.samples; i++) - unrolledLoop += "gl_FragColor += texture2D(source, texCoord) * weight " + linearSteps + "; texCoord += shift;\n" + unrolledLoop += "gl_FragColor += texture2D(source, texCoord) * weight; texCoord += shift;\n" } shader = shader.replace("PLACEHOLDER_EXPAND_STEPS", expandSteps) diff --git a/src/effects/internal/DirectionalGaussianBlur.qml b/src/effects/internal/DirectionalGaussianBlur.qml index 55d52b5..78dc68f 100644 --- a/src/effects/internal/DirectionalGaussianBlur.qml +++ b/src/effects/internal/DirectionalGaussianBlur.qml @@ -122,55 +122,51 @@ Item { } function buildFragmentShader() { - var linearSteps = "" - - if (transparentBorder) - linearSteps = "* linearstep(0.0, pixelX, texCoord.s) * linearstep(1.0, stepX, texCoord.s) * linearstep(0.0, pixelY, texCoord.t) * linearstep(1.0, stepY, texCoord.t)" var shaderSteps = [ - "gl_FragColor += texture2D(source, texCoord) * factor_0_2.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_0_2.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_0_2.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_0_2.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_0_2.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_0_2.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_3_5.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_3_5.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_3_5.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_3_5.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_3_5.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_3_5.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_6_8.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_6_8.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_6_8.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_6_8.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_6_8.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_6_8.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_9_11.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_9_11.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_9_11.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_9_11.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_9_11.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_9_11.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_12_14.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_12_14.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_12_14.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_12_14.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_12_14.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_12_14.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_15_17.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_15_17.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_15_17.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_15_17.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_15_17.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_15_17.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_18_20.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_18_20.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_18_20.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_18_20.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_18_20.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_18_20.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_21_23.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_21_23.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_21_23.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_21_23.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_21_23.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_21_23.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_24_26.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_24_26.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_24_26.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_24_26.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_24_26.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_24_26.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_27_29.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_27_29.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_27_29.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_27_29.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_27_29.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_27_29.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_30_32.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_30_32.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_30_32.z" + linearSteps + "; texCoord += shift;" + "gl_FragColor += texture2D(source, texCoord) * factor_30_32.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_30_32.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_30_32.z; texCoord += shift;" ] var shader = fragmentShaderBegin @@ -229,14 +225,6 @@ Item { uniform highp float pixelX; uniform highp float pixelY; - highp float linearstep(highp float e0, highp float e1, highp float x) { - return clamp((x - e0) / (e1 - e0), 0.0, 1.0); - } - - highp float dlinearstep(highp float e0, highp float d, highp float x) { - return clamp((x - e0) * d, 0.0, 1.0); - } - void main() { highp vec2 shift = vec2(delta.x, delta.y); highp float index = delta.z; diff --git a/src/effects/internal/DirectionalGaussianMaskedBlur.qml b/src/effects/internal/DirectionalGaussianMaskedBlur.qml index d224c6f..ea975c8 100644 --- a/src/effects/internal/DirectionalGaussianMaskedBlur.qml +++ b/src/effects/internal/DirectionalGaussianMaskedBlur.qml @@ -129,55 +129,51 @@ Item { } function buildFragmentShader() { - var linearSteps = "" - - if (transparentBorder) - linearSteps = "* linearstep(0.0, pixelX, texCoord.s) * linearstep(1.0, stepX, texCoord.s) * linearstep(0.0, pixelY, texCoord.t) * linearstep(1.0, stepY, texCoord.t)" var shaderSteps = [ - "gl_FragColor += texture2D(source, texCoord) * factor_0_2.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_0_2.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_0_2.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_0_2.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_0_2.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_0_2.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_3_5.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_3_5.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_3_5.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_3_5.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_3_5.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_3_5.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_6_8.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_6_8.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_6_8.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_6_8.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_6_8.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_6_8.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_9_11.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_9_11.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_9_11.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_9_11.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_9_11.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_9_11.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_12_14.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_12_14.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_12_14.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_12_14.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_12_14.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_12_14.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_15_17.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_15_17.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_15_17.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_15_17.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_15_17.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_15_17.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_18_20.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_18_20.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_18_20.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_18_20.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_18_20.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_18_20.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_21_23.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_21_23.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_21_23.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_21_23.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_21_23.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_21_23.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_24_26.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_24_26.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_24_26.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_24_26.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_24_26.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_24_26.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_27_29.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_27_29.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_27_29.z" + linearSteps + "; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_27_29.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_27_29.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_27_29.z; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_30_32.x" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_30_32.y" + linearSteps + "; texCoord += shift;", - "gl_FragColor += texture2D(source, texCoord) * factor_30_32.z" + linearSteps + "; texCoord += shift;" + "gl_FragColor += texture2D(source, texCoord) * factor_30_32.x; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_30_32.y; texCoord += shift;", + "gl_FragColor += texture2D(source, texCoord) * factor_30_32.z; texCoord += shift;" ] var shader = fragmentShaderBegin @@ -237,14 +233,6 @@ Item { uniform highp float pixelX; uniform highp float pixelY; - highp float linearstep(highp float e0, highp float e1, highp float x) { - return clamp((x - e0) / (e1 - e0), 0.0, 1.0); - } - - highp float dlinearstep(highp float e0, highp float d, highp float x) { - return clamp((x - e0) * d, 0.0, 1.0); - } - void main() { highp vec2 shift = vec2(delta.x, delta.y) * texture2D(maskSource, qt_TexCoord0).a; highp float index = delta.z; diff --git a/src/effects/internal/GaussianGlow.qml b/src/effects/internal/GaussianGlow.qml index fbb03f1..f0ae37f 100644 --- a/src/effects/internal/GaussianGlow.qml +++ b/src/effects/internal/GaussianGlow.qml @@ -53,6 +53,7 @@ Item { SourceProxy { id: sourceProxy input: rootItem.source + sourceRect: rootItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2.0, parent.height + 2.0) : Qt.rect(0, 0, 0, 0) } ShaderEffectSource { @@ -67,10 +68,10 @@ Item { DirectionalGaussianBlur { id: blur - x: transparentBorder ? -maximumRadius : 0 - y: transparentBorder ? -maximumRadius : 0 + x: transparentBorder ? -maximumRadius - 1 : 0 + y: transparentBorder ? -maximumRadius - 1 : 0 width: horizontalBlur.width - height: transparentBorder ? horizontalBlur.height + 2 * maximumRadius : horizontalBlur.height + height: horizontalBlur.height horizontalStep: 0.0 verticalStep: 1.0 / parent.height @@ -90,8 +91,8 @@ Item { DirectionalGaussianBlur { id: horizontalBlur - width: transparentBorder ? parent.width + 2 * maximumRadius : parent.width - height: parent.height + width: transparentBorder ? parent.width + 2 * maximumRadius + 2 : parent.width + height: transparentBorder ? parent.height + 2 * maximumRadius + 2 : parent.height horizontalStep: 1.0 / parent.width verticalStep: 0.0 diff --git a/src/effects/internal/GaussianMaskedBlur.qml b/src/effects/internal/GaussianMaskedBlur.qml index ae013ca..5d03823 100644 --- a/src/effects/internal/GaussianMaskedBlur.qml +++ b/src/effects/internal/GaussianMaskedBlur.qml @@ -52,11 +52,13 @@ Item { SourceProxy { id: sourceProxy input: rootItem.source + sourceRect: rootItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2.0, parent.height + 2.0) : Qt.rect(0, 0, 0, 0) } SourceProxy { id: maskSourceProxy input: rootItem.maskSource + sourceRect: rootItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2.0, parent.height + 2.0) : Qt.rect(0, 0, 0, 0) } ShaderEffectSource { @@ -71,10 +73,10 @@ Item { DirectionalGaussianMaskedBlur { id: blur - x: transparentBorder ? -maximumRadius : 0 - y: transparentBorder ? -maximumRadius : 0 + x: transparentBorder ? -maximumRadius - 1: 0 + y: transparentBorder ? -maximumRadius - 1: 0 width: horizontalBlur.width - height: transparentBorder ? horizontalBlur.height + 2 * maximumRadius : horizontalBlur.height + height: horizontalBlur.height horizontalStep: 0.0 verticalStep: 1.0 / parent.height @@ -94,8 +96,8 @@ Item { DirectionalGaussianMaskedBlur { id: horizontalBlur - width: transparentBorder ? parent.width + 2 * maximumRadius : parent.width - height: parent.height + width: transparentBorder ? parent.width + 2 * maximumRadius + 2 : parent.width + height: transparentBorder ? parent.height + 2 * maximumRadius + 2 : parent.height horizontalStep: 1.0 / parent.width verticalStep: 0.0 diff --git a/src/effects/internal/SourceProxy.qml b/src/effects/internal/SourceProxy.qml index 8fb8083..f778c7b 100644 --- a/src/effects/internal/SourceProxy.qml +++ b/src/effects/internal/SourceProxy.qml @@ -44,16 +44,35 @@ Item { id: rootItem property variant input property variant output: input + property variant sourceRect visible: false Component.onCompleted: evaluateInput() onInputChanged: evaluateInput() + onSourceRectChanged: evaluateInput() + function evaluateInput() { if (input == undefined) { output = input } + else if (sourceRect != undefined && sourceRect != Qt.rect(0, 0, 0, 0)) { + output = proxySource + proxySource.sourceRect = sourceRect + + if (isQQuickShaderEffectSource(input)) { + proxyEffect.source = input + proxyEffect.width = sourceRect.width + sourceRect.x * 2 + proxyEffect.height = sourceRect.height + sourceRect.y * 2 + proxySource.sourceItem = proxyEffect + } else { + proxyEffect.source = undefined + proxyEffect.width = 0 + proxyEffect.height = 0 + proxySource.sourceItem = input + } + } else if (isQQuickItemLayerEnabled(input)) { output = input } @@ -66,6 +85,9 @@ Item { else { proxySource.sourceItem = input output = proxySource + proxySource.sourceRect = Qt.rect(0, 0, 0, 0) + proxySource.width = 0 + proxySource.height = 0 } } @@ -117,6 +139,11 @@ Item { return false } + ShaderEffect { + id: proxyEffect + property variant source + } + ShaderEffectSource { id: proxySource live: rootItem.input != rootItem.output |