forked from qt-creator/qt-creator
Add optional fps counter to 3D edit view
Currently it is enabled via #define FPS_COUNTER in qt5informationnodeinstanceserver.cpp Change-Id: If9af313232fc91fca674a43c7ca70b04db7e59f7 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -59,6 +59,8 @@ Item {
|
|||||||
|
|
||||||
property bool shuttingDown: false
|
property bool shuttingDown: false
|
||||||
|
|
||||||
|
property real fps: 0
|
||||||
|
|
||||||
signal selectionChanged(var selectedNodes)
|
signal selectionChanged(var selectedNodes)
|
||||||
signal commitObjectProperty(var object, var propName)
|
signal commitObjectProperty(var object, var propName)
|
||||||
signal changeObjectProperty(var object, var propName)
|
signal changeObjectProperty(var object, var propName)
|
||||||
@@ -815,5 +817,16 @@ Item {
|
|||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
color: "white"
|
color: "white"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: fpsLabel
|
||||||
|
text: viewRoot.fps
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.margins: 4
|
||||||
|
font.pixelSize: 12
|
||||||
|
color: "white"
|
||||||
|
visible: viewRoot.fps > 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -102,6 +102,14 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Uncomment to display FPS counter on the lower left corner of edit 3D view
|
||||||
|
//#define FPS_COUNTER
|
||||||
|
#ifdef FPS_COUNTER
|
||||||
|
#include <QtCore/qelapsedtimer.h>
|
||||||
|
static QElapsedTimer *_fpsTimer = nullptr;
|
||||||
|
static int _frameCount = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
static QVariant objectToVariant(QObject *object)
|
static QVariant objectToVariant(QObject *object)
|
||||||
@@ -640,6 +648,18 @@ void Qt5InformationNodeInstanceServer::doRender3DEditView()
|
|||||||
m_render3DEditViewTimer.start(0);
|
m_render3DEditViewTimer.start(0);
|
||||||
--m_need3DEditViewRender;
|
--m_need3DEditViewRender;
|
||||||
}
|
}
|
||||||
|
#ifdef FPS_COUNTER
|
||||||
|
// Force constant rendering for accurate fps count
|
||||||
|
if (!m_render3DEditViewTimer.isActive())
|
||||||
|
m_render3DEditViewTimer.start(0);
|
||||||
|
++_frameCount;
|
||||||
|
if (_fpsTimer->elapsed() > 1000) {
|
||||||
|
QQmlProperty fpsProperty(m_editView3DData.rootItem, "fps", context());
|
||||||
|
fpsProperty.write(_frameCount);
|
||||||
|
_frameCount = 0;
|
||||||
|
_fpsTimer->start();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -870,6 +890,13 @@ Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceC
|
|||||||
m_render3DEditViewTimer.setSingleShot(true);
|
m_render3DEditViewTimer.setSingleShot(true);
|
||||||
m_inputEventTimer.setSingleShot(true);
|
m_inputEventTimer.setSingleShot(true);
|
||||||
m_renderModelNodeImageViewTimer.setSingleShot(true);
|
m_renderModelNodeImageViewTimer.setSingleShot(true);
|
||||||
|
|
||||||
|
#ifdef FPS_COUNTER
|
||||||
|
if (!_fpsTimer) {
|
||||||
|
_fpsTimer = new QElapsedTimer;
|
||||||
|
_fpsTimer->start();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt5InformationNodeInstanceServer::~Qt5InformationNodeInstanceServer()
|
Qt5InformationNodeInstanceServer::~Qt5InformationNodeInstanceServer()
|
||||||
|
Reference in New Issue
Block a user