Skip to content

Commit

Permalink
fix(ULIPCRect): prevent visual artifacts when updating screen partially
Browse files Browse the repository at this point in the history
  • Loading branch information
unstabler committed Oct 6, 2022
1 parent 2c84c9e commit 6906011
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
11 changes: 3 additions & 8 deletions sessionprojector/sessionprojector/SCScreenRecorder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SCScreenRecorder: NSObject, ScreenRecorder {

private var streamQueue = DispatchQueue(
label: "UlalacaStreamRecorder",
qos: .userInteractive
qos: .background
)

private static func createCoreImageContext(useMetal: Bool = true) -> CIContext {
Expand Down Expand Up @@ -215,14 +215,9 @@ extension SCScreenRecorder: SCStreamOutput {

if let dirtyRects = frameInfo.dirtyRects {
subscriptions.forEach { subscriber in
if let mainDisplay = subscriber.mainViewport {
subscriber.screenUpdated(where: frameInfo.contentRect!)
} else {
dirtyRects.forEach { rect in
subscriber.screenUpdated(where: rect)
}
dirtyRects.forEach { rect in
subscriber.screenUpdated(where: rect)
}

}

subscriptions.forEach { subscriber in
Expand Down
8 changes: 4 additions & 4 deletions sessionprojector/sessionprojector/ULIPCRect+scale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import Foundation
extension ULIPCRect {
func scale(x sx: Double, y sy: Double) -> ULIPCRect {
return ULIPCRect(
x: Int16(Double(x) * sx),
y: Int16(Double(y) * sy),
width: Int16(Double(width) * sx),
height: Int16(Double(height) * sy)
x: Int16(floor(Double(x) * sx)),
y: Int16(floor(Double(y) * sy)),
width: Int16(ceil(Double(width) * sx)),
height: Int16(ceil(Double(height) * sy))
)
}
}

0 comments on commit 6906011

Please sign in to comment.