mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Use libtess2 instead of boost graph and earcut
This commit is contained in:
@@ -213,7 +213,7 @@ public final class MediaBox {
|
||||
return ResourceStorePaths(partial: "\(fileNameForId(id))_partial", complete: "\(fileNameForId(id))")
|
||||
}
|
||||
|
||||
private func cachedRepresentationPathsForId(_ id: MediaResourceId, representationId: String, keepDuration: CachedMediaRepresentationKeepDuration) -> ResourceStorePaths {
|
||||
private func cachedRepresentationPathsForId(_ id: String, representationId: String, keepDuration: CachedMediaRepresentationKeepDuration) -> ResourceStorePaths {
|
||||
let cacheString: String
|
||||
switch keepDuration {
|
||||
case .general:
|
||||
@@ -784,14 +784,22 @@ public final class MediaBox {
|
||||
|
||||
public func storeCachedResourceRepresentation(_ resource: MediaResource, representation: CachedMediaResourceRepresentation, data: Data) {
|
||||
self.dataQueue.async {
|
||||
let path = self.cachedRepresentationPathsForId(resource.id, representationId: representation.uniqueId, keepDuration: representation.keepDuration).complete
|
||||
let path = self.cachedRepresentationPathsForId(resource.id.stringRepresentation, representationId: representation.uniqueId, keepDuration: representation.keepDuration).complete
|
||||
let _ = try? data.write(to: URL(fileURLWithPath: path))
|
||||
}
|
||||
}
|
||||
|
||||
public func storeCachedResourceRepresentation(_ resource: MediaResource, representationId: String, keepDuration: CachedMediaRepresentationKeepDuration, data: Data, completion: @escaping (String) -> Void = { _ in }) {
|
||||
self.dataQueue.async {
|
||||
let path = self.cachedRepresentationPathsForId(resource.id, representationId: representationId, keepDuration: keepDuration).complete
|
||||
let path = self.cachedRepresentationPathsForId(resource.id.stringRepresentation, representationId: representationId, keepDuration: keepDuration).complete
|
||||
let _ = try? data.write(to: URL(fileURLWithPath: path))
|
||||
completion(path)
|
||||
}
|
||||
}
|
||||
|
||||
public func storeCachedResourceRepresentation(_ resourceId: String, representationId: String, keepDuration: CachedMediaRepresentationKeepDuration, data: Data, completion: @escaping (String) -> Void = { _ in }) {
|
||||
self.dataQueue.async {
|
||||
let path = self.cachedRepresentationPathsForId(resourceId, representationId: representationId, keepDuration: keepDuration).complete
|
||||
let _ = try? data.write(to: URL(fileURLWithPath: path))
|
||||
completion(path)
|
||||
}
|
||||
@@ -802,7 +810,7 @@ public final class MediaBox {
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
let begin: () -> Void = {
|
||||
let paths = self.cachedRepresentationPathsForId(resource.id, representationId: representation.uniqueId, keepDuration: representation.keepDuration)
|
||||
let paths = self.cachedRepresentationPathsForId(resource.id.stringRepresentation, representationId: representation.uniqueId, keepDuration: representation.keepDuration)
|
||||
if let size = fileSize(paths.complete) {
|
||||
self.timeBasedCleanup.touch(paths: [
|
||||
paths.complete
|
||||
@@ -971,7 +979,7 @@ public final class MediaBox {
|
||||
let begin: () -> Void = {
|
||||
let paths: ResourceStorePaths
|
||||
if let baseResourceId = baseResourceId {
|
||||
paths = self.cachedRepresentationPathsForId(MediaResourceId(baseResourceId), representationId: id, keepDuration: keepDuration)
|
||||
paths = self.cachedRepresentationPathsForId(MediaResourceId(baseResourceId).stringRepresentation, representationId: id, keepDuration: keepDuration)
|
||||
} else {
|
||||
paths = self.storePathsForId(MediaResourceId(id))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user