performance updates

This commit is contained in:
Mark Gregory
2026-11-06 08:48:12 +00:00
parent 376f027f12
commit 8d33198d21
3 changed files with 47 additions and 1 deletions
+7 -1
View File
@@ -180,7 +180,7 @@ final class DJNativeSpectrumView: DJWaveMouseView {
private var hoverX: Double?
private var tracking: NSTrackingArea?
override init(frame: NSRect) {
super.init(frame:frame)
super.init(frame:frame);clipsToBounds = true
freeze = { [weak self] start in self?.frozenViewport = start;self?.needsDisplay = true }
}
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
@@ -223,6 +223,12 @@ final class DJNativeSpectrumView: DJWaveMouseView {
super.mouseDown(with:event)
}
override func draw(_ dirtyRect: NSRect) {
guard let context = NSGraphicsContext.current?.cgContext else { return }
context.saveGState()
defer { context.restoreGState() }
// Cached sections extend beyond the viewport while scrolling. Neither
// those sections nor their markers may paint into adjacent deck controls.
context.clip(to:bounds)
NSColor.black.setFill();bounds.fill()
guard let player,player.duration > 0,span > 0,!player.waveform.isEmpty else { return }
let time = player.displayTime,start = frozenViewport ?? (time-span/2),width = bounds.width,height = bounds.height