补充 GPU 渲染分块、内存与利用率统计,增加只读 SMC 温度及风扇信息和旋转动效。完善电池功率与耗电进程列表,统一首排布局并固定异步加载区域高度。同步验证用例、架构说明和 GPU 能力调研工具。
42 lines
1.8 KiB
Swift
42 lines
1.8 KiB
Swift
import SwiftUI
|
|
|
|
/// Memory bars share a byte scale, not a used/allocated capacity ratio.
|
|
struct GPUStatisticsView: View {
|
|
let inUse: UInt64?
|
|
let allocated: UInt64?
|
|
let average: Double?
|
|
let peak: Double?
|
|
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
|
|
|
private var reference: Double { max(1, Double(max(inUse ?? 0, allocated ?? 0))) }
|
|
|
|
var body: some View {
|
|
HStack(spacing: 10) {
|
|
VStack(spacing: 5) {
|
|
memoryRow("gpu.driverMemory", bytes: inUse, color: Color("MetricMemory"))
|
|
memoryRow("gpu.allocatedMemory", bytes: allocated, color: Color("MetricNetwork"))
|
|
}.frame(maxWidth: .infinity).help(Text("gpu.memoryComparisonHelp"))
|
|
Divider()
|
|
HStack(spacing: 6) {
|
|
MetricRingGauge(title: "gpu.recentAverage", value: average, color: Color("MetricCPU"))
|
|
MetricRingGauge(title: "gpu.peak", value: peak, color: Color("MetricGPU"))
|
|
}.frame(maxWidth: .infinity).help(Text("gpu.summaryHelp"))
|
|
}.frame(height: 42)
|
|
}
|
|
|
|
private func memoryRow(_ title: LocalizedStringKey, bytes: UInt64?, color: Color) -> some View {
|
|
VStack(spacing: 3) {
|
|
HStack(spacing: 4) {
|
|
Text(title).foregroundStyle(.secondary)
|
|
Spacer(minLength: 0)
|
|
AnimatedMetricText(value: MetricFormat.bytes(bytes)).fontWeight(.medium)
|
|
}.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.7)
|
|
MetricProgressBar(value: bytes.map { Double($0) / reference } ?? 0, color: color)
|
|
.frame(height: 3)
|
|
.animation(reduceMotion ? nil : .easeInOut(duration: 0.35), value: bytes)
|
|
.animation(reduceMotion ? nil : .easeInOut(duration: 0.35), value: reference)
|
|
.accessibilityHidden(true)
|
|
}
|
|
}
|
|
}
|