From c8007db5903bd7c395dc6b124849fbe8cf18ce2f Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Tue, 13 Jul 2021 22:56:32 -0400 Subject: [PATCH] conference: only load avatars if visible Wrap avatars in a Loader to avoid constantly querying the image provider for remote video participants. Change-Id: Ieca2457416dfd4c33fc3a960a1e36643ea1f11ef --- src/avatarimageprovider.h | 5 +++ .../components/ParticipantOverlay.qml | 42 ++++++++++--------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/avatarimageprovider.h b/src/avatarimageprovider.h index 3351684ad..9340c952c 100644 --- a/src/avatarimageprovider.h +++ b/src/avatarimageprovider.h @@ -38,6 +38,11 @@ public: { Q_UNUSED(size) + if (requestedSize == QSize(0, 0)) { + qWarning() << Q_FUNC_INFO << "Image request has no dimensions"; + return {}; + } + // the first string is the item uri and the second is a uid // that is used for trigger a reload of the underlying image // data and can be discarded at this point diff --git a/src/mainview/components/ParticipantOverlay.qml b/src/mainview/components/ParticipantOverlay.qml index c7ebb70b7..169b7958d 100644 --- a/src/mainview/components/ParticipantOverlay.qml +++ b/src/mainview/components/ParticipantOverlay.qml @@ -54,16 +54,11 @@ Item { function setAvatar(show, uri, isLocal) { if (!show) - avatar.visible = false + avatar.active = false else { - if (isLocal) { - avatar.mode = Avatar.Mode.Account - avatar.imageId = LRCInstance.currentAccountId - } else { - avatar.mode = Avatar.Mode.Contact - avatar.imageId = uri - } - avatar.visible = true + avatar.mode_ = isLocal ? Avatar.Mode.Account : Avatar.Mode.Contact + avatar.imageId_ = isLocal ? LRCInstance.currentAccountId : uri + avatar.active = true } } @@ -167,22 +162,31 @@ Item { } } - Avatar { + Loader { id: avatar anchors.centerIn: parent - property real size: Math.min(parent.width / 2, parent.height / 2) - height: size - width: size + active: false + + property real size_: Math.min(parent.width / 2, parent.height / 2) + height: size_ + width: size_ - // round the avatar source size up to some nearest multiple - readonly property real step: 96 - property real imageSize: Math.floor((size + step - 1) / step) * step - sourceSize: Qt.size(imageSize, imageSize) + property int mode_ + property string imageId_ - visible: false - showPresenceIndicator: false + sourceComponent: Component { + Avatar { + // round the avatar source size up to some nearest multiple + readonly property real step: 96 + property real size: Math.floor((size_ + step - 1) / step) * step + sourceSize: Qt.size(size, size) + mode: mode_ + imageId: size_ ? imageId_ : "" + showPresenceIndicator: false + } + } } // Participant background and buttons for moderation -- GitLab