mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Move maxScreenScale to RSImage-Extensions. Mark IconScalerQueue as @unchecked Sendable (because it is).
This commit is contained in:
@@ -20,14 +20,6 @@ public typealias RSImage = UIImage
|
||||
|
||||
public extension RSImage {
|
||||
|
||||
#if os(macOS)
|
||||
static let maxScreenScale = CGFloat(2)
|
||||
#endif
|
||||
|
||||
#if os(iOS)
|
||||
static let maxScreenScale = CGFloat(3)
|
||||
#endif
|
||||
|
||||
/// Create a colored image from the source image using a specified color.
|
||||
///
|
||||
/// - Parameter color: The color with which to fill the mask image.
|
||||
|
||||
@@ -15,15 +15,26 @@ import Core
|
||||
|
||||
extension RSImage {
|
||||
|
||||
static let maxIconSize = 48
|
||||
|
||||
private static let scaledMaxPixelSize: Int = {
|
||||
|
||||
let maxIconSize = 48
|
||||
#if os(iOS)
|
||||
let maxScreenScale = 3
|
||||
#elseif os(macOS)
|
||||
let maxScreenScale = 2
|
||||
#endif
|
||||
|
||||
return maxIconSize * maxScreenScale
|
||||
}()
|
||||
|
||||
|
||||
static func scaledForIcon(_ data: Data, imageResultBlock: @escaping ImageResultBlock) {
|
||||
IconScalerQueue.shared.scaledForIcon(data, imageResultBlock)
|
||||
}
|
||||
|
||||
static func scaledForIcon(_ data: Data) -> RSImage? {
|
||||
let scaledMaxPixelSize = Int(ceil(CGFloat(RSImage.maxIconSize) * maxScreenScale))
|
||||
guard var cgImage = RSImage.scaleImage(data, maxPixelSize: scaledMaxPixelSize) else {
|
||||
|
||||
guard var cgImage = RSImage.scaleImage(data, maxPixelSize: Self.scaledMaxPixelSize) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -38,7 +49,7 @@ extension RSImage {
|
||||
|
||||
// MARK: - IconScalerQueue
|
||||
|
||||
private class IconScalerQueue {
|
||||
private final class IconScalerQueue: @unchecked Sendable {
|
||||
|
||||
static let shared = IconScalerQueue()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user