From c196ba7116a7e44ae04eb23791b696f223f75745 Mon Sep 17 00:00:00 2001 From: Exeldro Date: Fri, 25 Oct 2024 08:21:09 +0200 Subject: [PATCH] Fix colors for async columns --- source-profiler.cpp | 16 ++++++++++++---- source-profiler.hpp | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/source-profiler.cpp b/source-profiler.cpp index f80de2c..4b43453 100644 --- a/source-profiler.cpp +++ b/source-profiler.cpp @@ -346,7 +346,7 @@ PerfTreeModel::PerfTreeModel(QObject *parent) : QAbstractItemModel(parent) return QVariant(); return QVariant(ns_to_ms(item->m_perf->async_input_best)); }, - COLUMN_TYPE_DURATION, true), + COLUMN_TYPE_INTERVAL, true), PerfTreeColumn( QString::fromUtf8(obs_module_text("PerfViewer.AsyncWorst")), [](const PerfTreeItem *item) { @@ -354,7 +354,7 @@ PerfTreeModel::PerfTreeModel(QObject *parent) : QAbstractItemModel(parent) return QVariant(); return QVariant(ns_to_ms(item->m_perf->async_input_worst)); }, - COLUMN_TYPE_DURATION, true), + COLUMN_TYPE_INTERVAL, true), PerfTreeColumn( QString::fromUtf8(obs_module_text("PerfViewer.AsyncRenderedFps")), [](const PerfTreeItem *item) { @@ -370,7 +370,7 @@ PerfTreeModel::PerfTreeModel(QObject *parent) : QAbstractItemModel(parent) return QVariant(); return QVariant(ns_to_ms(item->m_perf->async_rendered_best)); }, - COLUMN_TYPE_DURATION, true), + COLUMN_TYPE_INTERVAL, true), PerfTreeColumn( QString::fromUtf8(obs_module_text("PerfViewer.AsyncRenderedWorst")), [](const PerfTreeItem *item) { @@ -378,7 +378,7 @@ PerfTreeModel::PerfTreeModel(QObject *parent) : QAbstractItemModel(parent) return QVariant(); return QVariant(ns_to_ms(item->m_perf->async_rendered_worst)); }, - COLUMN_TYPE_DURATION, true), + COLUMN_TYPE_INTERVAL, true), PerfTreeColumn( QString::fromUtf8(obs_module_text("PerfViewer.Total")), [](const PerfTreeItem *item) { @@ -748,6 +748,14 @@ QVariant PerfTreeModel::data(const QModelIndex &index, int role) const auto item = static_cast(index.internalPointer()); auto column = columns.at(index.column()); return ColorFormPercentage(column.Value(item).toDouble() / frameTime * 100.0); + } else if (column_type == COLUMN_TYPE_INTERVAL) { + if (frameTime <= 0.0) + return {}; + auto item = static_cast(index.internalPointer()); + auto column = columns.at(index.column()); + auto interval = column.Value(item).toDouble(); + if (interval > frameTime) + return ColorFormPercentage((interval - frameTime) / frameTime * 100.0); } return {}; } else if (role == Qt::TextAlignmentRole) { diff --git a/source-profiler.hpp b/source-profiler.hpp index 971fb92..310837f 100644 --- a/source-profiler.hpp +++ b/source-profiler.hpp @@ -13,6 +13,7 @@ enum PerfTreeColumnType { COLUMN_TYPE_DEFAULT, COLUMN_TYPE_BOOL, COLUMN_TYPE_DURATION, + COLUMN_TYPE_INTERVAL, COLUMN_TYPE_PERCENTAGE, COLUMN_TYPE_FPS, COLUMN_TYPE_COUNT