Tidy up frame rate display in video examples
* Use a Column element to position QML and video frame rate counters. * When using small-screen layouts, hide frame rate counters when dialogs or menus are displayed. * Do not display instantaneous frame rate. If changes in this rate trigger a repaint, then the rate itself is changed. If the repaint occurs in less time than the QElapsedTimer resolution, the displayed instantaneous rate is always zero. * Add a label, so it is clear which is the QML repaint rate, and which is the video frame rate. Change-Id: Ie58ab162ab44bd7f1c4b297eed929b9baa73552c Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
b6f54c8833
commit
c1ec175b24
@@ -69,16 +69,27 @@ Rectangle {
|
|||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: performanceLoader
|
id: performanceLoader
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: inner
|
||||||
|
onVisibleChanged:
|
||||||
|
if (performanceLoader.item)
|
||||||
|
performanceLoader.item.enabled = !inner.visible
|
||||||
|
ignoreUnknownSignals: true
|
||||||
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
console.log("[qmlvideo] performanceLoader.init logging " + root.perfMonitorsLogging + " visible " + root.perfMonitorsVisible)
|
console.log("[qmlvideo] performanceLoader.init logging " + root.perfMonitorsLogging + " visible " + root.perfMonitorsVisible)
|
||||||
var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
|
var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
|
||||||
source = enabled ? "../performancemonitor/PerformanceItem.qml" : ""
|
source = enabled ? "../performancemonitor/PerformanceItem.qml" : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
item.parent = root
|
item.parent = root
|
||||||
item.anchors.fill = root
|
item.anchors.fill = root
|
||||||
item.logging = root.perfMonitorsLogging
|
item.logging = root.perfMonitorsLogging
|
||||||
item.displayed = root.perfMonitorsVisible
|
item.displayed = root.perfMonitorsVisible
|
||||||
|
item.enabled = false
|
||||||
item.init()
|
item.init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ Rectangle {
|
|||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
property string folder
|
property string folder
|
||||||
|
property bool shown: loader.sourceComponent
|
||||||
|
|
||||||
signal fileSelected(string file)
|
signal fileSelected(string file)
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ Rectangle {
|
|||||||
id: root
|
id: root
|
||||||
color: "white"
|
color: "white"
|
||||||
property int buttonHeight: 35
|
property int buttonHeight: 35
|
||||||
|
property int topMargin: 0
|
||||||
|
|
||||||
signal openImage
|
signal openImage
|
||||||
signal openVideo
|
signal openVideo
|
||||||
@@ -53,9 +54,8 @@ Rectangle {
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors {
|
anchors {
|
||||||
topMargin: 10
|
|
||||||
bottomMargin: 10
|
|
||||||
top: parent.top;
|
top: parent.top;
|
||||||
|
topMargin: root.topMargin
|
||||||
bottom: parent.bottom;
|
bottom: parent.bottom;
|
||||||
horizontalCenter: parent.horizontalCenter
|
horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,8 +79,6 @@ Rectangle {
|
|||||||
item.anchors.top = content.top
|
item.anchors.top = content.top
|
||||||
item.anchors.left = content.left
|
item.anchors.left = content.left
|
||||||
item.anchors.right = content.right
|
item.anchors.right = content.right
|
||||||
item.height = 100
|
|
||||||
item.anchors.margins = 5
|
|
||||||
item.logging = root.perfMonitorsLogging
|
item.logging = root.perfMonitorsLogging
|
||||||
item.displayed = root.perfMonitorsVisible
|
item.displayed = root.perfMonitorsVisible
|
||||||
item.init()
|
item.init()
|
||||||
@@ -123,6 +121,7 @@ Rectangle {
|
|||||||
margins: 5
|
margins: 5
|
||||||
}
|
}
|
||||||
buttonHeight: 32
|
buttonHeight: 32
|
||||||
|
topMargin: 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ Rectangle {
|
|||||||
property bool perfMonitorsLogging: false
|
property bool perfMonitorsLogging: false
|
||||||
property bool perfMonitorsVisible: false
|
property bool perfMonitorsVisible: false
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: d
|
||||||
|
property bool dialogShown: (fileOpenContainer.state == "shown" ||
|
||||||
|
effectSelectionPanel.state == "shown" ||
|
||||||
|
videoFileBrowser.shown ||
|
||||||
|
imageFileBrowser.shown)
|
||||||
|
}
|
||||||
|
|
||||||
// Create ScreenSaver element via Loader, so this app will still run if the
|
// Create ScreenSaver element via Loader, so this app will still run if the
|
||||||
// SystemInfo module is not available
|
// SystemInfo module is not available
|
||||||
Loader {
|
Loader {
|
||||||
@@ -59,18 +67,25 @@ Rectangle {
|
|||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: performanceLoader
|
id: performanceLoader
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: d
|
||||||
|
onDialogShownChanged:
|
||||||
|
if (performanceLoader.item)
|
||||||
|
performanceLoader.item.enabled = !d.dialogShown
|
||||||
|
ignoreUnknownSignals: true
|
||||||
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
console.log("[qmlvideofx] performanceLoader.init logging " + root.perfMonitorsLogging + " visible " + root.perfMonitorsVisible)
|
console.log("[qmlvideofx] performanceLoader.init logging " + root.perfMonitorsLogging + " visible " + root.perfMonitorsVisible)
|
||||||
var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
|
var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
|
||||||
source = enabled ? "../performancemonitor/PerformanceItem.qml" : ""
|
source = enabled ? "../performancemonitor/PerformanceItem.qml" : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
item.parent = root
|
item.parent = root
|
||||||
item.anchors.top = root.top
|
item.anchors.top = root.top
|
||||||
item.anchors.topMargin = 100
|
|
||||||
item.anchors.left = root.left
|
item.anchors.left = root.left
|
||||||
item.anchors.right = root.right
|
|
||||||
item.anchors.bottom = root.verticalCenter
|
|
||||||
item.logging = root.perfMonitorsLogging
|
item.logging = root.perfMonitorsLogging
|
||||||
item.displayed = root.perfMonitorsVisible
|
item.displayed = root.perfMonitorsVisible
|
||||||
item.init()
|
item.init()
|
||||||
@@ -121,8 +136,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
enabled: false
|
state: (enabled && !d.dialogShown) ? "shown" : "baseState"
|
||||||
state: enabled ? "shown" : "baseState"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectSelectionPanel {
|
EffectSelectionPanel {
|
||||||
@@ -295,7 +309,7 @@ Rectangle {
|
|||||||
splashScreen.state = "hidden"
|
splashScreen.state = "hidden"
|
||||||
fileOpenContainer.state = "shown"
|
fileOpenContainer.state = "shown"
|
||||||
}
|
}
|
||||||
enabled: (fileOpenContainer.state != "shown" && effectSelectionPanel.state != "shown")
|
enabled: !d.dialogShown
|
||||||
}
|
}
|
||||||
|
|
||||||
HintedMouseArea {
|
HintedMouseArea {
|
||||||
@@ -313,7 +327,7 @@ Rectangle {
|
|||||||
splashScreen.state = "hidden"
|
splashScreen.state = "hidden"
|
||||||
effectSelectionPanel.state = "shown"
|
effectSelectionPanel.state = "shown"
|
||||||
}
|
}
|
||||||
enabled: (fileOpenContainer.state != "shown" && effectSelectionPanel.state != "shown")
|
enabled: !d.dialogShown
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ Rectangle {
|
|||||||
|
|
||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: "yellow"
|
border.color: "yellow"
|
||||||
width: 3.5 * root.textSize
|
width: 5.5 * root.textSize
|
||||||
height: 3.0 * root.textSize
|
height: 3.0 * root.textSize
|
||||||
color: "black"
|
color: "black"
|
||||||
opacity: 0.5
|
opacity: 0.5
|
||||||
@@ -74,20 +74,22 @@ Rectangle {
|
|||||||
samplingInterval: root.enabled ? root.samplingInterval : 0
|
samplingInterval: root.enabled ? root.samplingInterval : 0
|
||||||
onAverageFrequencyChanged: {
|
onAverageFrequencyChanged: {
|
||||||
if (root.logging) trace()
|
if (root.logging) trace()
|
||||||
instantaneousFrequencyText.text = monitor.instantaneousFrequency.toFixed(2)
|
|
||||||
averageFrequencyText.text = monitor.averageFrequency.toFixed(2)
|
averageFrequencyText.text = monitor.averageFrequency.toFixed(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: instantaneousFrequencyText
|
id: labelText
|
||||||
anchors {
|
anchors {
|
||||||
right: parent.right
|
left: parent.left
|
||||||
top: parent.top
|
top: parent.top
|
||||||
margins: 10
|
margins: 10
|
||||||
}
|
}
|
||||||
color: root.textColor
|
color: root.textColor
|
||||||
font.pixelSize: root.textSize
|
font.pixelSize: 0.6 * root.textSize
|
||||||
|
text: root.label
|
||||||
|
width: root.width - 2*anchors.margins
|
||||||
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
|||||||
@@ -46,65 +46,96 @@ Rectangle {
|
|||||||
property bool logging: true
|
property bool logging: true
|
||||||
property bool displayed: true
|
property bool displayed: true
|
||||||
property bool videoActive
|
property bool videoActive
|
||||||
property int samplingInterval: 500
|
|
||||||
property color textColor: "yellow"
|
|
||||||
property int textSize: 28
|
|
||||||
property int margins: 5
|
property int margins: 5
|
||||||
|
property bool enabled: true
|
||||||
|
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
// This should ensure that the monitor is on top of all other content
|
// This should ensure that the monitor is on top of all other content
|
||||||
z: 999
|
z: 999
|
||||||
|
|
||||||
Loader {
|
Column {
|
||||||
id: videoFrameRateItemLoader
|
id: column
|
||||||
function init() {
|
anchors {
|
||||||
source = "../frequencymonitor/FrequencyItem.qml"
|
fill: root
|
||||||
item.label = "videoFrameRate"
|
margins: 10
|
||||||
item.parent = root
|
|
||||||
item.anchors.left = root.left
|
|
||||||
item.anchors.top = root.top
|
|
||||||
item.anchors.margins = root.margins
|
|
||||||
item.logging = root.logging
|
|
||||||
item.displayed = root.displayed
|
|
||||||
videoFrameRateActiveConnections.target = item
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
id: videoFrameRateActiveConnections
|
|
||||||
ignoreUnknownSignals: true
|
|
||||||
onActiveChanged: root.videoActive = videoFrameRateActiveConnections.target.active
|
|
||||||
}
|
}
|
||||||
|
spacing: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
QtObject {
|
||||||
id: qmlFrameRateItemLoader
|
id: d
|
||||||
function init() {
|
property Item qmlFrameRateItem: null
|
||||||
source = "../frequencymonitor/FrequencyItem.qml"
|
property Item videoFrameRateItem: null
|
||||||
item.label = "qmlFrameRate"
|
|
||||||
item.parent = root
|
|
||||||
item.anchors.left = root.left
|
|
||||||
item.anchors.bottom = root.bottom
|
|
||||||
item.anchors.margins = root.margins
|
|
||||||
item.logging = root.logging
|
|
||||||
item.displayed = root.displayed
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
id: videoFrameRateActiveConnections
|
||||||
|
ignoreUnknownSignals: true
|
||||||
|
onActiveChanged: root.videoActive = videoFrameRateActiveConnections.target.active
|
||||||
|
}
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "hidden"
|
||||||
|
PropertyChanges {
|
||||||
|
target: root
|
||||||
|
opacity: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
transitions: [
|
||||||
|
Transition {
|
||||||
|
from: "*"
|
||||||
|
to: "*"
|
||||||
|
NumberAnimation {
|
||||||
|
properties: "opacity"
|
||||||
|
easing.type: Easing.OutQuart
|
||||||
|
duration: 500
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
state: enabled ? "baseState" : "hidden"
|
||||||
|
|
||||||
|
function createQmlFrameRateItem() {
|
||||||
|
var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml")
|
||||||
|
if (component.status == Component.Ready)
|
||||||
|
d.qmlFrameRateItem = component.createObject(column, { label: "QML frame rate",
|
||||||
|
displayed: root.displayed,
|
||||||
|
logging: root.logging
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function createVideoFrameRateItem() {
|
||||||
|
var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml")
|
||||||
|
if (component.status == Component.Ready)
|
||||||
|
d.videoFrameRateItem = component.createObject(column, { label: "Video frame rate",
|
||||||
|
displayed: root.displayed,
|
||||||
|
logging: root.logging
|
||||||
|
})
|
||||||
|
videoFrameRateActiveConnections.target = d.videoFrameRateItem
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
videoFrameRateItemLoader.init()
|
createQmlFrameRateItem()
|
||||||
qmlFrameRateItemLoader.init()
|
createVideoFrameRateItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
function videoFramePainted() {
|
function videoFramePainted() {
|
||||||
videoFrameRateItemLoader.item.notify()
|
if (d.videoFrameRateItem)
|
||||||
|
d.videoFrameRateItem.notify()
|
||||||
}
|
}
|
||||||
|
|
||||||
function qmlFramePainted() {
|
function qmlFramePainted() {
|
||||||
qmlFrameRateItemLoader.item.notify()
|
if (d.qmlFrameRateItem)
|
||||||
|
d.qmlFrameRateItem.notify()
|
||||||
}
|
}
|
||||||
|
|
||||||
onVideoActiveChanged: {
|
onVideoActiveChanged: {
|
||||||
videoFrameRateItemLoader.item.active = root.videoActive
|
if (d.videoFrameRateItem)
|
||||||
|
d.videoFrameRateItem.active = root.videoActive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user