Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions OpenParsec/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,11 @@ struct MainView: View {
if let window = UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }).flatMap({ $0.windows }).first(where: { $0.isKeyWindow }) {
let scale = window.screen.nativeScale
ParsecResolution.updateClientResolution(width: Int(window.bounds.width * scale), height: Int(window.bounds.height * scale))
} else {
// no key window yet on a launch reconnect, without this it asks the host for 3840x2160
let screen = UIScreen.main
let scale = screen.nativeScale
ParsecResolution.updateClientResolution(width: Int(screen.bounds.width * scale), height: Int(screen.bounds.height * scale))
}

pollTimer?.invalidate()
Expand Down
2 changes: 1 addition & 1 deletion OpenParsec/ParsecMetalRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private let frameCallback: ParsecFrameCallback = { frame, image, opaque in
extension ParsecFrame {
var isWholeNV12: Bool {
let w = Int(width), h = Int(height), stride = Int(fullWidth), rows = Int(fullHeight)
return format == FORMAT_NV12 && w > 0 && h > 0 && stride >= w && rows >= h && Int(size) >= stride * rows + stride * ((h + 1) / 2)
return format == FORMAT_NV12 && w > 0 && h > 0 && stride >= 2 * ((w + 1) / 2) && rows >= h && Int(size) >= stride * rows + stride * ((h + 1) / 2)
}
}

Expand Down
15 changes: 10 additions & 5 deletions OpenParsec/ParsecSDKBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ class ParsecSDKBridge: ParsecService {

func getStatusEx(_ pcs: inout ParsecClientStatus) -> ParsecStatus {
let ans = ParsecClientGetStatus(_parsec, &pcs)
self.hostHeight = Float(pcs.decoder.0.height)
self.hostWidth = Float(pcs.decoder.0.width)
if pcs.decoder.0.width > 0 && pcs.decoder.0.height > 0 {
self.hostHeight = Float(pcs.decoder.0.height)
self.hostWidth = Float(pcs.decoder.0.width)
}

// the teardown release may not have made it out, this one goes over a socket we know is live
if ans == PARSEC_OK && !didReleaseOnConnect {
Expand Down Expand Up @@ -373,6 +375,10 @@ class ParsecSDKBridge: ParsecService {
let size = event.cursor.size
let width = event.cursor.width
let height = event.cursor.height
guard width > 0, height > 0, Int(size) >= Int(width) * Int(height) * 4 else {
ParsecFree(pointer)
return
}
mouseInfo.cursorWidth = Int(width)
mouseInfo.cursorHeight = Int(height)

Expand All @@ -388,9 +394,8 @@ class ParsecSDKBridge: ParsecService {
let render: CGColorRenderingIntent = CGColorRenderingIntent.defaultIntent
let rgbColorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo: CGBitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.last.rawValue)
let providerRef: CGDataProvider? = CGDataProvider(data: NSData(bytes: pointer, length: Int(size)))
let cgimage: CGImage? = CGImage(width: Int(width), height: Int(height), bitsPerComponent: 8, bitsPerPixel: 32, bytesPerRow: Int(width) * elmentLength, space: rgbColorSpace, bitmapInfo: bitmapInfo, provider: providerRef!, decode: nil, shouldInterpolate: true, intent: render)
if cgimage != nil {
if let providerRef = CGDataProvider(data: NSData(bytes: pointer, length: Int(size))),
let cgimage = CGImage(width: Int(width), height: Int(height), bitsPerComponent: 8, bitsPerPixel: 32, bytesPerRow: Int(width) * elmentLength, space: rgbColorSpace, bitmapInfo: bitmapInfo, provider: providerRef, decode: nil, shouldInterpolate: true, intent: render) {
mouseInfo.cursorImg = cgimage
}
ParsecFree(pointer)
Expand Down
Loading