on xenial help sign in
improve performance on BlurLayer
d0c9ba0Michael Zanetti
qml/Components/BlurLayer.qml+7−41
@@ -20,54 +20,20 @@ import QtGraphicalEffects 1.0
20Item {
20Item {
21 id: root
21 id: root
22
22
23− property alias source: shaderEffectSource.sourceItem
23+ property alias source: fastBlur.source
24− property real saturation: 1
25 property real brightness: 1
24 property real brightness: 1
26 property real blurRadius: 0
25 property real blurRadius: 0
27
26
28− readonly property alias ready: shaderEffectSource.ready
29−
30− ShaderEffect {
31− id: desaturateEffect
32− anchors.fill: root
33−
34− property real saturationValue: Math.min(Math.max(root.saturation, 0), 1)
35− property real brightnessValue: Math.min(Math.max(root.brightness, 0), 1)
36−
37− property variant source: ShaderEffectSource {
38− id: shaderEffectSource
39− hideSource: root.visible
40− live: !root.visible
41− property bool ready: false;
42− onLiveChanged: {
43− if (!live) {
44− ready = false;
45− scheduleUpdate();
46− }
47− }
48− onScheduledUpdateCompleted: ready = true;
49− }
50−
51− fragmentShader: "
52− varying highp vec2 qt_TexCoord0;
53− uniform sampler2D source;
54− uniform lowp float saturationValue;
55− uniform lowp float brightnessValue;
56− void main(void)
57− {
58− highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
59− highp vec4 scaledColor = sourceColor * vec4(0.3, 0.59, 0.11, 1.0);
60− lowp float luminance = scaledColor.r + scaledColor.g + scaledColor.b ;
61− highp vec4 tmp = mix(vec4(luminance, luminance, luminance, sourceColor.a), sourceColor, saturationValue);
62− gl_FragColor = mix(vec4(0, 0, 0, 1), tmp, brightnessValue);
63− }"
64− }
65−
66 FastBlur {
27 FastBlur {
67 id: fastBlur
28 id: fastBlur
68 anchors.fill: parent
29 anchors.fill: parent
69− source: desaturateEffect
70 visible: radius > 0
30 visible: radius > 0
71 radius: Math.max(root.blurRadius, 0)
31 radius: Math.max(root.blurRadius, 0)
72 }
32 }
33+
34+ Rectangle {
35+ anchors.fill: parent
36+ color: "black"
37+ opacity: 1 - root.brightness
38+ }
73}
39}
qml/Stage/Stage.qml+7−4
@@ -409,7 +409,8 @@ FocusScope {
409 PropertyChanges { target: hoverMouseArea; enabled: true }
409 PropertyChanges { target: hoverMouseArea; enabled: true }
410 PropertyChanges { target: rightEdgeDragArea; enabled: false }
410 PropertyChanges { target: rightEdgeDragArea; enabled: false }
411 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
411 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
412− PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65 }
412+ PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65; opacity: 1 }
413+ PropertyChanges { target: wallpaper; visible: false }
413 },
414 },
414 State {
415 State {
415 name: "stagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "staged"
416 name: "stagedRightEdge"; when: (rightEdgeDragArea.dragging || edgeBarrier.progress > 0) && root.mode == "staged"
@@ -417,7 +418,8 @@ FocusScope {
417 target: blurLayer;
418 target: blurLayer;
418 visible: true;
419 visible: true;
419 blurRadius: 32
420 blurRadius: 32
420− brightness: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, .65, Math.max(rightEdgeDragArea.progress, edgeBarrier.progress))
421+ brightness: .65
422+ opacity: 1
421 }
423 }
422 },
424 },
423 State {
425 State {
@@ -434,8 +436,9 @@ FocusScope {
434 PropertyChanges {
436 PropertyChanges {
435 target: blurLayer;
437 target: blurLayer;
436 visible: true
438 visible: true
437− blurRadius: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 32, Math.max(rightEdgeDragArea.progress, edgeBarrier.progress))
439+ blurRadius: 32
440+ brightness: .65
438− brightness: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 1, .65, Math.max(rightEdgeDragArea.progress, edgeBarrier.progress))
441+ opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.progress, edgeBarrier.progress))
439 }
442 }
440 },
443 },
441 State {
444 State {