perf(menubar): 隔离卡片动效并推进 1.1 低开销版本
This commit is contained in:
@@ -114,6 +114,30 @@ import QuartzCore
|
||||
precondition(!ring.isAnimating && ring.displayedValue == 0.8)
|
||||
ring.configure(NativeMetricRing.Input(value: 0.2, color: .red, lineWidth: 3, trackOpacity: 0.17, inset: 2, animates: true))
|
||||
ring.removeFromSuperview(); precondition(!ring.isAnimating && ring.displayedValue == 0.2)
|
||||
// Shared cleanup must not stop a different motion or a newer replacement.
|
||||
let firstMotion = MetricMotion(), secondMotion = MetricMotion()
|
||||
let firstLayer = CALayer(), secondLayer = CALayer()
|
||||
root.wantsLayer = true
|
||||
for target in [firstLayer, secondLayer] {
|
||||
target.frame = CGRect(x: 10, y: 10, width: 20, height: 20)
|
||||
target.backgroundColor = NSColor.red.cgColor
|
||||
root.layer?.addSublayer(target)
|
||||
}
|
||||
func makeMovement() -> CABasicAnimation {
|
||||
let animation = CABasicAnimation(keyPath: "position.x")
|
||||
animation.fromValue = 0; animation.toValue = 10
|
||||
return animation
|
||||
}
|
||||
firstMotion.start(on: firstLayer, animation: makeMovement())
|
||||
secondMotion.start(on: secondLayer, animation: makeMovement())
|
||||
try? await Task.sleep(for: .milliseconds(180))
|
||||
firstMotion.stop()
|
||||
secondMotion.start(on: secondLayer, animation: makeMovement())
|
||||
try? await Task.sleep(for: .milliseconds(210))
|
||||
precondition(!firstMotion.isRunning && secondMotion.isRunning,
|
||||
"An old batch deadline must not remove a restarted animation")
|
||||
try? await Task.sleep(for: .milliseconds(250))
|
||||
precondition(!secondMotion.isRunning, "The replacement must also finish and release its animation")
|
||||
window.orderOut(nil); window.close()
|
||||
print("PASS: native curve pixels, real gaps, missing series, hover, appearance, duplicate-input invalidation zero/quarter/full ring pixels and finite transitions/gap/policy/unmount cancellation")
|
||||
fflush(stdout); NSApp.terminate(nil)
|
||||
|
||||
Reference in New Issue
Block a user