diff --git a/Linphone/core/participant/ParticipantDeviceCore.cpp b/Linphone/core/participant/ParticipantDeviceCore.cpp index 591b67e9d..df7d25f0f 100644 --- a/Linphone/core/participant/ParticipantDeviceCore.cpp +++ b/Linphone/core/participant/ParticipantDeviceCore.cpp @@ -46,6 +46,7 @@ ParticipantDeviceCore::ParticipantDeviceCore(const std::shared_ptrgetAddress()->asStringUriOnly()); mIsMuted = device->getIsMuted(); mIsMe = isMe; + mIsSpeaking = device->getIsSpeaking(); mParticipantDeviceModel = Utils::makeQObject_ptr(device); mParticipantDeviceModel->setSelf(mParticipantDeviceModel); mState = LinphoneEnums::fromLinphone(device->getState()); diff --git a/Linphone/data/CMakeLists.txt b/Linphone/data/CMakeLists.txt index a95c3d007..01282f4df 100644 --- a/Linphone/data/CMakeLists.txt +++ b/Linphone/data/CMakeLists.txt @@ -1,7 +1,7 @@ list(APPEND _LINPHONEAPP_RC_FILES data/assistant/use-app-sip-account.rc data/assistant/create-app-sip-account.rc data/assistant/use-other-sip-account.rc - data/shaders/roundEffect.vert.qsb + data/shaders/opacityMask.frag.qsb data/shaders/roundEffect.frag.qsb ) diff --git a/Linphone/data/shaders/opacityMask.frag b/Linphone/data/shaders/opacityMask.frag new file mode 100644 index 000000000..a3dc6c3f6 --- /dev/null +++ b/Linphone/data/shaders/opacityMask.frag @@ -0,0 +1,16 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; +}; + +layout(binding = 1) uniform sampler2D source; +layout(binding = 2) uniform sampler2D maskSource; + +void main() { + fragColor = texture(source, qt_TexCoord0.st) * (texture(maskSource, qt_TexCoord0.st).a) * qt_Opacity; +} diff --git a/Linphone/data/shaders/opacityMask.frag.qsb b/Linphone/data/shaders/opacityMask.frag.qsb new file mode 100644 index 000000000..deee7fee5 Binary files /dev/null and b/Linphone/data/shaders/opacityMask.frag.qsb differ diff --git a/Linphone/data/shaders/roundEffect.frag b/Linphone/data/shaders/roundEffect.frag index e26263047..24ba57735 100644 --- a/Linphone/data/shaders/roundEffect.frag +++ b/Linphone/data/shaders/roundEffect.frag @@ -1,18 +1,43 @@ #version 440 -layout(location = 0) in vec2 coord; + +//qsb --glsl "100 es,120,150" --hlsl 50 --msl 12 -o roundEffect.frag.qsb roundEffect.frag + +// qt_TexCoord0 E [0.0 , 1.0] +layout(location = 0) in vec2 qt_TexCoord0; layout(location = 0) out vec4 fragColor; layout(std140, binding = 0) uniform buf { mat4 qt_Matrix; float qt_Opacity; - float edge; -}; +// How soft the edges should be (in pixels). Higher values could be used to simulate a drop shadow. = 1.0 + float edgeSoftness; +// The radius of the corners (in pixels). + float radius; + // Apply a drop shadow effect. = 0.5 + float shadowSoftness; +// Drop shadow offset. = 0.5 + float shadowOffset; + float width; + float height; +} ubuf; layout(binding = 1) uniform sampler2D src; -void main() { - float dist = distance(coord, vec2( 0.5 )); - float delta = fwidth(dist); - float alpha = smoothstep( mix(clamp(edge, 0.0, 1.0), 0.0, 0.5) - delta, 0.5, dist ); - - vec4 tex = texture(src, coord); - fragColor = mix( tex, vec4(0.0), alpha) * qt_Opacity; +float roundedBoxSDF(vec2 position, vec2 offset, float radius) { + return length(max(abs(position)-offset+radius,0.0))-radius; +} + +void main(){ + vec2 size = vec2(ubuf.width, ubuf.height); + vec2 center = vec2(0.5); + // Calculate distance to edge. + float dist = roundedBoxSDF( (qt_TexCoord0.xy - center) * size, size/2.0 - 1.0, ubuf.radius); + float smoothedAlpha = max(1.0 - smoothstep(-ubuf.edgeSoftness, ubuf.edgeSoftness * 2.0, dist), 0); + // Return the resultant shape. + vec4 tex = texture(src, qt_TexCoord0.st); + vec4 quadColor = mix(vec4(0.0, 0.0, 0.0, 0.0), vec4(tex.rgb, smoothedAlpha), smoothedAlpha); + // Apply a drop shadow effect. + vec2 shadowOffset = vec2(0.0, ubuf.shadowOffset); + float shadowDistance = roundedBoxSDF((qt_TexCoord0.xy - center) * size, size/2.0, ubuf.radius); + float shadowAlpha = 1.0 - smoothstep(-1.0, ubuf.shadowSoftness, shadowDistance); + vec4 shadowColor = vec4(0.4, 0.4, 0.4, 1.0); + fragColor = mix(quadColor, shadowColor, shadowAlpha - smoothedAlpha) * ubuf.qt_Opacity; } diff --git a/Linphone/data/shaders/roundEffect.frag.qsb b/Linphone/data/shaders/roundEffect.frag.qsb index 3fb5a8a2a..c78465eae 100644 Binary files a/Linphone/data/shaders/roundEffect.frag.qsb and b/Linphone/data/shaders/roundEffect.frag.qsb differ diff --git a/Linphone/data/shaders/roundEffect.vert b/Linphone/data/shaders/roundEffect.vert deleted file mode 100644 index f76842d39..000000000 --- a/Linphone/data/shaders/roundEffect.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 440 -layout(location = 0) in vec4 qt_Vertex; -layout(location = 1) in vec2 qt_MultiTextCoord0; -layout(location = 0) out vec2 coord; -layout(std140, binding = 0) uniform buf { - mat4 qt_Matrix; - float qt_Opacity; -}; - -void main() { - coord = qt_MultiTextCoord0; - gl_Position = qt_Matrix * qt_Vertex; -} diff --git a/Linphone/data/shaders/roundEffect.vert.qsb b/Linphone/data/shaders/roundEffect.vert.qsb deleted file mode 100644 index b16d3443a..000000000 Binary files a/Linphone/data/shaders/roundEffect.vert.qsb and /dev/null differ diff --git a/Linphone/view/Item/Contact/Avatar.qml b/Linphone/view/Item/Contact/Avatar.qml index 48147bd57..d35bbd8bb 100644 --- a/Linphone/view/Item/Contact/Avatar.qml +++ b/Linphone/view/Item/Contact/Avatar.qml @@ -124,7 +124,6 @@ StackView { id: avatarItem height: mainItem.height width: height - Image { id: image visible: false @@ -135,16 +134,20 @@ StackView { fillMode: Image.PreserveAspectCrop anchors.centerIn: parent source: mainItem.account && mainItem.account.core.pictureUri - || mainItem.contact && mainItem.contact.core.pictureUri - || computedAvatarUri + || mainItem.contact && mainItem.contact.core.pictureUri + || computedAvatarUri mipmap: true + layer.enabled: true } ShaderEffect { id: roundEffect property variant src: image - property double edge: 0.9 + property real edge: 0.9 + property real edgeSoftness: 0.9 + property real radius: width / 2.0 + property real shadowSoftness: 0.5 + property real shadowOffset: 0.01 anchors.fill: parent - vertexShader: 'qrc:/data/shaders/roundEffect.vert.qsb' fragmentShader: 'qrc:/data/shaders/roundEffect.frag.qsb' } } diff --git a/Linphone/view/Item/Contact/Sticker.qml b/Linphone/view/Item/Contact/Sticker.qml index 8065d3bcc..1928ea48d 100644 --- a/Linphone/view/Item/Contact/Sticker.qml +++ b/Linphone/view/Item/Contact/Sticker.qml @@ -18,6 +18,7 @@ Item { property AccountGui account: null property ParticipantDeviceGui participantDevice: null property bool previewEnabled: false + property bool displayBorder : participantDevice && participantDevice.core.isSpeaking || false property color color: DefaultStyle.grey_600 property int radius: 15 * DefaultStyle.dp property var peerAddressObj: participantDevice && participantDevice.core @@ -32,10 +33,13 @@ Item { Rectangle { id: background - color: mainItem.color + color: noCameraLayout.visible ? mainItem.color : 'transparent' radius: mainItem.radius anchors.fill: parent + border.color: DefaultStyle.main2_200 + border.width: mainItem.displayBorder ? 3 * DefaultStyle.dp : 0 ColumnLayout { + id: noCameraLayout anchors.centerIn: parent visible: !cameraLoader.active || cameraLoader.status != Loader.Ready || !cameraLoader.item.isReady Avatar{ @@ -85,11 +89,11 @@ Item { Item { height: cameraLoader.height width: cameraLoader.width - property bool isReady: cameraItem.visible + property alias isReady: cameraItem.isReady CameraGui{ id: cameraItem anchors.fill: parent - visible: isReady + visible: false call: mainItem.call participantDevice: mainItem.participantDevice isPreview: mainItem.previewEnabled @@ -98,6 +102,20 @@ Item { console.log("Request new renderer") resetTimer.restart() } + layer.enabled: true + } + + ShaderEffect { + id: roundEffect + property variant src: cameraItem + property real edge: 0.9 + property real edgeSoftness: 0.9 + property real radius: mainItem.radius + property real shadowSoftness: 0.5 + property real shadowOffset: 0.01 + anchors.fill: parent + visible: cameraItem.isReady + fragmentShader: 'qrc:/data/shaders/roundEffect.frag.qsb' } } }