mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
metal engine macos changes
This commit is contained in:
parent
3df7111853
commit
a723e852f7
@ -2,6 +2,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import TGUIKit
|
||||||
#endif
|
#endif
|
||||||
import CoreMedia
|
import CoreMedia
|
||||||
import Accelerate
|
import Accelerate
|
||||||
|
@ -3,6 +3,7 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import TGUIKit
|
||||||
#endif
|
#endif
|
||||||
import CoreMedia
|
import CoreMedia
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
@ -3,6 +3,7 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import TGUIKit
|
||||||
#endif
|
#endif
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
import Postbox
|
||||||
|
@ -5,6 +5,7 @@ import PackageDescription
|
|||||||
|
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "MetalEngine",
|
name: "MetalEngine",
|
||||||
|
platforms: [.macOS(.v10_13)],
|
||||||
products: [
|
products: [
|
||||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||||
.library(
|
.library(
|
||||||
|
@ -666,13 +666,6 @@ public final class MetalEngine {
|
|||||||
fileprivate var computeStates: [ObjectIdentifier: ComputeState] = [:]
|
fileprivate var computeStates: [ObjectIdentifier: ComputeState] = [:]
|
||||||
|
|
||||||
init?(device: MTLDevice) {
|
init?(device: MTLDevice) {
|
||||||
let mainBundle = Bundle(for: Impl.self)
|
|
||||||
guard let path = mainBundle.path(forResource: "MetalEngineMetalSourcesBundle", ofType: "bundle") else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
guard let bundle = Bundle(path: path) else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
self.device = device
|
self.device = device
|
||||||
|
|
||||||
@ -681,15 +674,42 @@ public final class MetalEngine {
|
|||||||
}
|
}
|
||||||
self.commandQueue = commandQueue
|
self.commandQueue = commandQueue
|
||||||
|
|
||||||
guard let library = try? device.makeDefaultLibrary(bundle: bundle) else {
|
let library: MTLLibrary?
|
||||||
return nil
|
|
||||||
}
|
|
||||||
self.library = library
|
|
||||||
|
|
||||||
guard let vertexFunction = library.makeFunction(name: "clearVertex") else {
|
#if os(iOS)
|
||||||
|
let mainBundle = Bundle(for: Impl.self)
|
||||||
|
guard let path = mainBundle.path(forResource: "MetalEngineMetalSourcesBundle", ofType: "bundle") else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
guard let fragmentFunction = library.makeFunction(name: "clearFragment") else {
|
guard let bundle = Bundle(path: path) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
library = try? device.makeDefaultLibrary(bundle: bundle)
|
||||||
|
#else
|
||||||
|
let mainBundle = Bundle(for: Impl.self)
|
||||||
|
guard let path = mainBundle.path(forResource: "MetalEngineMetalSourcesBundle", ofType: "bundle") else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
guard let bundle = Bundle(path: path) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
guard let path = bundle.path(forResource: "MetalEngineShaders", ofType: "metallib") else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
library = try? device.makeLibrary(URL: .init(fileURLWithPath: path))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
guard let lib = library else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
self.library = lib
|
||||||
|
|
||||||
|
guard let vertexFunction = lib.makeFunction(name: "clearVertex") else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
guard let fragmentFunction = lib.makeFunction(name: "clearFragment") else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ public enum WebpagePreviewResult: Equatable {
|
|||||||
case progress
|
case progress
|
||||||
case result(Result?)
|
case result(Result?)
|
||||||
}
|
}
|
||||||
|
#if os(macOS)
|
||||||
|
private typealias UIImage = NSImage
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
public func webpagePreview(account: Account, urls: [String], webpageId: MediaId? = nil, forPeerId: PeerId? = nil) -> Signal<WebpagePreviewResult, NoError> {
|
public func webpagePreview(account: Account, urls: [String], webpageId: MediaId? = nil, forPeerId: PeerId? = nil) -> Signal<WebpagePreviewResult, NoError> {
|
||||||
return webpagePreviewWithProgress(account: account, urls: urls, webpageId: webpageId, forPeerId: forPeerId)
|
return webpagePreviewWithProgress(account: account, urls: urls, webpageId: webpageId, forPeerId: forPeerId)
|
||||||
@ -48,7 +52,7 @@ public func webpagePreviewWithProgress(account: Account, urls: [String], webpage
|
|||||||
}
|
}
|
||||||
return .single(.result(WebpagePreviewResult.Result(webpage: webpage, sourceUrl: sourceUrl)))
|
return .single(.result(WebpagePreviewResult.Result(webpage: webpage, sourceUrl: sourceUrl)))
|
||||||
} else {
|
} else {
|
||||||
if #available(iOS 13.0, *) {
|
if #available(iOS 13.0, macOS 10.15, *) {
|
||||||
if let forPeerId, forPeerId.namespace == Namespaces.Peer.SecretChat, let sourceUrl = urls.first, let url = URL(string: sourceUrl) {
|
if let forPeerId, forPeerId.namespace == Namespaces.Peer.SecretChat, let sourceUrl = urls.first, let url = URL(string: sourceUrl) {
|
||||||
let localHosts: [String] = [
|
let localHosts: [String] = [
|
||||||
"twitter.com",
|
"twitter.com",
|
||||||
|
@ -5,6 +5,7 @@ import PackageDescription
|
|||||||
|
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "LokiRng",
|
name: "LokiRng",
|
||||||
|
platforms: [.macOS(.v10_13)],
|
||||||
products: [
|
products: [
|
||||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||||
.library(
|
.library(
|
||||||
|
@ -5,6 +5,7 @@ import PackageDescription
|
|||||||
|
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "ShelfPack",
|
name: "ShelfPack",
|
||||||
|
platforms: [.macOS(.v10_13)],
|
||||||
products: [
|
products: [
|
||||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||||
.library(
|
.library(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user