Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/src/main/runtime/display/PerformanceHud.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fun PerformanceHudOverlay(modifier: Modifier = Modifier) {
// value shows N/A rather than dropping the gauge (which would make the row jump around).
val gauges = ArrayList<GaugeSpec>(8)
if (s.enabled.getOrElse(0) { false }) {
gauges.add(GaugeSpec("FPS", s.fps.toInt().toString(), s.fps / 120f, HudAccent))
gauges.add(GaugeSpec("FPS", s.fps.toInt().toString(), s.fps / 120f, fpsColor(s.fps)))
}
if (s.enabled.getOrElse(2) { false }) {
gauges.add(GaugeSpec("GPU", pctText(s.gpuLoad), pctFraction(s.gpuLoad), loadColor(maxOf(s.gpuLoad, 0))))
Expand All @@ -108,7 +108,7 @@ fun PerformanceHudOverlay(modifier: Modifier = Modifier) {
gauges.add(GaugeSpec("RAM", pctText(s.ramPercent), pctFraction(s.ramPercent), loadColor(maxOf(s.ramPercent, 0))))
}
if (s.enabled.getOrElse(6) { false }) {
gauges.add(GaugeSpec("ms", String.format("%.1f", s.frametimeMs), 1f - (s.frametimeMs / 33.3f), HudGood))
gauges.add(GaugeSpec("ms", String.format("%.1f", s.frametimeMs), 1f - (s.frametimeMs / 33.3f), fpsColor(s.fps)))
}
if (s.enabled.getOrElse(5) { false }) {
// Battery + temperature is a single HUD element: watts is the gauge value, temp the sublabel.
Expand Down Expand Up @@ -165,6 +165,9 @@ private fun loadColor(pct: Int): Color =
private fun tempColor(c: Int): Color =
if (c >= 45) HudBad else if (c >= 40) HudWarn else HudGood

private fun fpsColor(fps: Float): Color =
if (fps >= 30f) HudGood else if (fps >= 20f) HudWarn else HudBad

@Composable
private fun HudGauge(
label: String,
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/runtime/display/ui/FrameRating.java
Original file line number Diff line number Diff line change
Expand Up @@ -1509,13 +1509,13 @@ this.lastFPS, this.currentMs, this.gpuLoad, this.cpuPercent, ramPercentValue(),

if (this.enableFps && this.tvFpsBig != null) {
this.tvFpsBig.setText(String.format(Locale.US, "%.0f", this.lastFPS));
this.tvFpsBig.setTextColor(this.C_FPS_OK);
this.tvFpsBig.setTextColor(fpsColor(this.lastFPS));
this.tvFpsBig.setVisibility(View.VISIBLE);
} else if (this.tvFpsBig != null) this.tvFpsBig.setVisibility(View.GONE);

if (this.enableGraph && this.frametimeNumericMode && this.tvFrametime != null) {
this.tvFrametime.setText(String.format(Locale.US, "%.1f ms", this.currentMs));
this.tvFrametime.setTextColor(this.C_FPS_OK);
this.tvFrametime.setTextColor(fpsColor(this.lastFPS));
this.tvFrametime.setVisibility(View.VISIBLE);
} else if (this.tvFrametime != null) {
this.tvFrametime.setVisibility(View.GONE);
Expand All @@ -1524,6 +1524,10 @@ this.lastFPS, this.currentMs, this.gpuLoad, this.cpuPercent, ramPercentValue(),
if (getOrientation() == LinearLayout.HORIZONTAL) updateSeparators(true);
}

private int fpsColor(float fps) {
return fps >= 30f ? C_FPS_OK : fps >= 20f ? C_WARM : C_HOT;
}

private void append(SpannableStringBuilder b, String t, int c) {
int start = b.length();
b.append(t);
Expand Down Expand Up @@ -1677,6 +1681,7 @@ protected void onDraw(Canvas canvas) {
float y = h - ((this.history[idx] / 40.0f) * h);
this.path.lineTo(i * step, Math.max(0.0f, y));
}
this.paintLine.setColor(fpsColor(lastFPS));
canvas.drawPath(this.path, this.paintLine);
}
}
Expand Down