qt: fix CSD window shadow not being rendered within offscreen window
Request review @chub.
This seems a very nasty bug deep down in Qt Scene Graph renderer, not sure what exactly causes this.
Merge request reports
Activity
added MRStatus::Reviewable label
if you're going to provide a shader, you can directly draw the dropshadow yourself, Rectangular glow is pretty easy to achieve
https://github.com/qt/qt5compat/blob/dev/src/imports/graphicaleffects5/RectangularGlow.qml https://github.com/qt/qt5compat/blob/dev/src/imports/graphicaleffects5/shaders_ng/rectangularglow.frag
This would avoid having to require multiple shader pass
Here is my attempt at it (the spread variable meaning varies from Qt code), this can be drawn on top of the interface without having to hide it
//draw the window drop shadow ourselve when the windowing system doesn't //provide them but support extended frame ShaderEffect { id: effect visible: _extendedFrameVisible anchors.fill: parent opacity: 0.5 property real spread: 1.4 property color color: "black" property real relativeSizeX: (MainCtx.windowExtendedMargin / parent.width) property real relativeSizeY: (MainCtx.windowExtendedMargin / parent.height) //states: [ // //FIXME animate //} fragmentShader: "qrc:///shaders/RectGlow.frag.qsb" }
#version 440 layout(location = 0) in vec2 qt_TexCoord0; layout(location = 0) out vec4 fragColor; layout(std140, binding = 0) uniform buf { // qt_Matrix and qt_Opacity must always be both present // if the built-in vertex shader is used. mat4 qt_Matrix; float qt_Opacity; vec4 color; float relativeSizeX; float relativeSizeY; float spread; }; float linearstep(float e0, float e1, float x) { return clamp((x - e0) / (e1 - e0), 0.0, 1.0); } void main() { //discard inner rectangle if (((qt_TexCoord0.x >= relativeSizeX && qt_TexCoord0.x <= (1.0 - relativeSizeX)) && (qt_TexCoord0.y >= relativeSizeY && qt_TexCoord0.y <= (1.0 - relativeSizeY)))) discard; float alpha = smoothstep(0.0, relativeSizeX * spread, 0.5 - abs(0.5 - qt_TexCoord0.x)) * smoothstep(0.0, relativeSizeY * spread, 0.5 - abs(0.5 - qt_TexCoord0.y)); //float spreadMultiplier = linearstep(spread, 1.0 - spread, alpha); fragColor = color * qt_Opacity * alpha * alpha; }
it probably deserve some tweaking to get the best result
While having it done this way would result in better rendering performance, having that if branch in the shader is still bad for the performance.
Ideally, we should not need to place the effect on top of the interface. This seems to be caused due to offscreen rendering (Qt bug). For example, on Wayland (!5247 (merged)), I don't need to do this.
So both solutions here (yours and mine) are worse for the performance. Mine is more practical since I don't need extra files and such (easier to revert when it's fixed), and yours would result in better rendering performance.
My intention here is to have this only as a temporary measure, so that's why I did not come up with a solution as you recommended. I'm not sure how we should proceed with this. Both are fine for me.
So both solutions here (yours and mine) are worse for the performance
that's not the same order of magnitude, you're comparing a branch in a shader to: a first shader pass + an offscreen rendering + the same branch in a shader
My intention here is to have this only as a temporary measure
In the long run should remove our dependency on Qt5Compat, so I don't really see the point in trying to keep compatibility with it
that's not the same order of magnitude, you're comparing a branch in a shader to: a first shader pass + an offscreen rendering + the same branch in a shader
I agree, my concern was with the practicality.
In the long run should remove our dependency on Qt5Compat, so I don't really see the point in trying to keep compatibility with it
I have changed this, can you check again?
added Component::Interface: Qt label
changed milestone to %4.0
added MRStatus::InReview label and removed MRStatus::Reviewable label
mentioned in merge request !5432 (merged)
added 94 commits
-
2689c706...d402227b - 92 commits from branch
videolan:master
- c62e34df - qt: introduce HollowRectangularGlow.frag shader
- b8fb230f - qml: workaround for CSD window shadow is not rendered
-
2689c706...d402227b - 92 commits from branch
337 341 duration: VLCStyle.duration_veryShort 338 342 } 339 343 } 344 345 Component.onCompleted: { 346 console.assert(children[1] instanceof ShaderEffect) 347 children[1].blending = false // we don't need blending 348 349 if (z >= 0) 350 children[1].fragmentShader = "qrc:///shaders/HollowRectangularGlow.frag.qsb" changed this line in version 3 of the diff
added MRStatus::NotCompliant label and removed MRStatus::InReview label
mentioned in merge request !6267 (merged)