Skip to content

Commit

Permalink
Fix colors for async columns
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Oct 25, 2024
1 parent 567012c commit c196ba7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions source-profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ 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) {
if (!item->m_perf || !item->async)
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) {
Expand All @@ -370,15 +370,15 @@ 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) {
if (!item->m_perf || !item->async)
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) {
Expand Down Expand Up @@ -748,6 +748,14 @@ QVariant PerfTreeModel::data(const QModelIndex &index, int role) const
auto item = static_cast<PerfTreeItem *>(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<PerfTreeItem *>(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) {
Expand Down
1 change: 1 addition & 0 deletions source-profiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c196ba7

Please sign in to comment.