Skip to content

Commit

Permalink
perf: improves performance of ThumbnailPanel significantly
Browse files Browse the repository at this point in the history
One performance issue we had is related how layers are handled. This commit allows subviews of Cell to be drawn into its layer and the layer be drawn asynchronously. In my test use-case with 16 windows with 3440x1417 sizing this brought the required time from key event reaction to ThumbnailPanel orderOut from 650ms down to 250ms. There is eventually more performance to gain by explicit control of .layerContentsRedrawPolicy. This commit also adds two NSLog statements for easy timing observations in the Run console.

Related to lwouis#45
  • Loading branch information
gingerr committed Nov 26, 2019
1 parent 87647b9 commit 8bf6e8a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions alt-tab-macos/ui/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate {
}

func showUiOrCycleSelection(_ step: Int) {
NSLog("Application.showUiOrCycleSelection")
appIsBeingUsed = true
if isFirstSummon {
isFirstSummon = false
Expand Down
2 changes: 2 additions & 0 deletions alt-tab-macos/ui/Cell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class Cell: NSCollectionViewItem {
private func makeVStackView(_ hStackView: NSStackView) -> NSStackView {
let vStackView = NSStackView()
vStackView.wantsLayer = true
vStackView.canDrawSubviewsIntoLayer = true
vStackView.layer!.drawsAsynchronously = true
vStackView.layer!.backgroundColor = .clear
vStackView.layer!.cornerRadius = Preferences.cellCornerRadius!
vStackView.layer!.borderWidth = Preferences.cellBorderWidth!
Expand Down
6 changes: 6 additions & 0 deletions alt-tab-macos/ui/ThumbnailsPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,10 @@ class ThumbnailsPanel: NSPanel, NSCollectionViewDataSource, NSCollectionViewDele
backgroundView!.setFrameSize(frame.size)
collectionView_!.setFrameOrigin(NSPoint(x: Preferences.windowPadding, y: Preferences.windowPadding))
}

// just for timestamp logging in combination with Application.showUiOrCycleSelection
override func orderOut(_ sender: Any?) {
NSLog("ThumbnailsPanel.orderOut")
super.orderOut(sender)
}
}

0 comments on commit 8bf6e8a

Please sign in to comment.