Atom Tools: move performance metrics status bar widgets to base window

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
Guthrie Adams
2022-01-26 16:13:31 -06:00
parent 75d39d9ce5
commit 413ce5a6ab
4 changed files with 46 additions and 50 deletions
@@ -10,7 +10,6 @@
#include <Atom/RPI.Edit/Material/MaterialSourceData.h>
#include <Atom/RPI.Edit/Material/MaterialTypeSourceData.h>
#include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
#include <AtomToolsFramework/PerformanceMonitor/PerformanceMonitorRequestBus.h>
#include <AtomToolsFramework/Util/Util.h>
#include <AzQtComponents/Components/StyleManager.h>
#include <AzQtComponents/Components/WindowDecorationWrapper.h>
@@ -112,14 +111,6 @@ namespace MaterialEditor
}
OnDocumentOpened(AZ::Uuid::CreateNull());
SetupMetrics();
}
MaterialEditorWindow::~MaterialEditorWindow()
{
AtomToolsFramework::PerformanceMonitorRequestBus::Broadcast(
&AtomToolsFramework::PerformanceMonitorRequestBus::Handler::SetProfilerEnabled, false);
}
void MaterialEditorWindow::ResizeViewportRenderTarget(uint32_t width, uint32_t height)
@@ -213,38 +204,6 @@ namespace MaterialEditor
Base::closeEvent(closeEvent);
}
void MaterialEditorWindow::SetupMetrics()
{
m_statusBarCpuTime = new QLabel(this);
statusBar()->addPermanentWidget(m_statusBarCpuTime);
m_statusBarGpuTime = new QLabel(this);
statusBar()->addPermanentWidget(m_statusBarGpuTime);
m_statusBarFps = new QLabel(this);
statusBar()->addPermanentWidget(m_statusBarFps);
static constexpr int UpdateIntervalMs = 1000;
m_metricsTimer.setInterval(UpdateIntervalMs);
m_metricsTimer.start();
connect(&m_metricsTimer, &QTimer::timeout, this, &MaterialEditorWindow::UpdateMetrics);
AtomToolsFramework::PerformanceMonitorRequestBus::Broadcast(
&AtomToolsFramework::PerformanceMonitorRequestBus::Handler::SetProfilerEnabled, true);
UpdateMetrics();
}
void MaterialEditorWindow::UpdateMetrics()
{
AtomToolsFramework::PerformanceMetrics metrics = {};
AtomToolsFramework::PerformanceMonitorRequestBus::BroadcastResult(
metrics, &AtomToolsFramework::PerformanceMonitorRequestBus::Handler::GetMetrics);
m_statusBarCpuTime->setText(tr("CPU Time %1 ms").arg(QString::number(metrics.m_cpuFrameTimeMs, 'f', 2)));
m_statusBarGpuTime->setText(tr("GPU Time %1 ms").arg(QString::number(metrics.m_gpuFrameTimeMs, 'f', 2)));
int frameRate = metrics.m_cpuFrameTimeMs > 0 ? aznumeric_cast<int>(1000 / metrics.m_cpuFrameTimeMs) : 0;
m_statusBarFps->setText(tr("FPS %1").arg(QString::number(frameRate)));
}
} // namespace MaterialEditor
#include <Window/moc_MaterialEditorWindow.cpp>
@@ -14,7 +14,6 @@
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
#include <Viewport/MaterialViewportWidget.h>
#include <Window/ToolBar/MaterialEditorToolBar.h>
#include <QTimer>
AZ_POP_DISABLE_WARNING
#endif
@@ -34,7 +33,6 @@ namespace MaterialEditor
using Base = AtomToolsFramework::AtomToolsDocumentMainWindow;
MaterialEditorWindow(QWidget* parent = 0);
~MaterialEditorWindow();
protected:
void ResizeViewportRenderTarget(uint32_t width, uint32_t height) override;
@@ -49,14 +47,7 @@ namespace MaterialEditor
void closeEvent(QCloseEvent* closeEvent) override;
void SetupMetrics();
void UpdateMetrics();
MaterialViewportWidget* m_materialViewport = {};
MaterialEditorToolBar* m_toolBar = {};
QLabel* m_statusBarFps = {};
QLabel* m_statusBarCpuTime = {};
QLabel* m_statusBarGpuTime = {};
QTimer m_metricsTimer;
};
} // namespace MaterialEditor