From fbbfcb93edd2f7cec955f85b8696deccf6e22148 Mon Sep 17 00:00:00 2001 From: kean Date: Tue, 24 Dec 2024 12:19:35 -0500 Subject: [PATCH] Remove GIFPlaybackStrategy --- .../Utility/Media/GIFPlaybackStrategy.swift | 80 ------------------- 1 file changed, 80 deletions(-) delete mode 100644 WordPress/Classes/Utility/Media/GIFPlaybackStrategy.swift diff --git a/WordPress/Classes/Utility/Media/GIFPlaybackStrategy.swift b/WordPress/Classes/Utility/Media/GIFPlaybackStrategy.swift deleted file mode 100644 index 4a4f80a16a50..000000000000 --- a/WordPress/Classes/Utility/Media/GIFPlaybackStrategy.swift +++ /dev/null @@ -1,80 +0,0 @@ -import Foundation - -@objc -public enum GIFStrategy: Int { - case tinyGIFs - case smallGIFs - case mediumGIFs - case largeGIFs - - /// Returns the corresponding playback strategy instance - /// - var playbackStrategy: GIFPlaybackStrategy { - switch self { - case .tinyGIFs: - return TinyGIFPlaybackStrategy() - case .smallGIFs: - return SmallGIFPlaybackStrategy() - case .mediumGIFs: - return MediumGIFPlaybackStrategy() - case .largeGIFs: - return LargeGIFPlaybackStrategy() - } - } -} - -public protocol GIFPlaybackStrategy { - /// Maximum size GIF data can be in order to be animated. - /// - var maxSize: Int { get } - - /// The number of frames that should be buffered. A high number will result in more - /// memory usage and less CPU load, and vice versa. Default is 50. - /// - var frameBufferCount: Int { get } - - /// Returns the coresponding GIFStrategy enum value. - /// - var gifStrategy: GIFStrategy { get } - - /// Verifies the GIF data against the `maxSize` var. - /// - /// - Parameter data: object containg the GIF - /// - Returns: **true** if data is under the maximum size limit (inclusive) and **false** if over the limit - /// - func verifyDataSize(_ data: Data) -> Bool -} - -extension GIFPlaybackStrategy { - func verifyDataSize(_ data: Data) -> Bool { - guard data.count <= maxSize else { - DDLogDebug("⚠️ Maximum GIF data size exceeded \(maxSize) with \(data.count)") - return false - } - return true - } -} -// This is good for thumbnail GIFs used in a collection view -class TinyGIFPlaybackStrategy: GIFPlaybackStrategy { - var maxSize = 2_000_000 // in MB - var frameBufferCount = 5 - var gifStrategy: GIFStrategy = .tinyGIFs -} - -class SmallGIFPlaybackStrategy: GIFPlaybackStrategy { - var maxSize = 8_000_000 // in MB - var frameBufferCount = 50 - var gifStrategy: GIFStrategy = .smallGIFs -} - -class MediumGIFPlaybackStrategy: GIFPlaybackStrategy { - var maxSize = 20_000_000 // in MB - var frameBufferCount = 50 - var gifStrategy: GIFStrategy = .mediumGIFs -} - -class LargeGIFPlaybackStrategy: GIFPlaybackStrategy { - var maxSize = 50_000_000 // in MB - var frameBufferCount = 50 - var gifStrategy: GIFStrategy = .largeGIFs -}