Enable blurhash in debug
Capping the size at 32x32 means this is fast enough even in un-optimized builds
This commit is contained in:
parent
e0ffa1d9c5
commit
2344275ff9
|
@ -104,11 +104,6 @@
|
||||||
value = ""
|
value = ""
|
||||||
isEnabled = "NO">
|
isEnabled = "NO">
|
||||||
</EnvironmentVariable>
|
</EnvironmentVariable>
|
||||||
<EnvironmentVariable
|
|
||||||
key = "DEBUG_BLUR_HASH"
|
|
||||||
value = "1"
|
|
||||||
isEnabled = "NO">
|
|
||||||
</EnvironmentVariable>
|
|
||||||
</EnvironmentVariables>
|
</EnvironmentVariables>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
|
|
|
@ -2,17 +2,9 @@
|
||||||
/// From https://github.com/woltapp/blurhash/blob/b23214ddcab803fe1ec9a3e6b20558caf33a23a5/Swift/BlurHashDecode.swift
|
/// From https://github.com/woltapp/blurhash/blob/b23214ddcab803fe1ec9a3e6b20558caf33a23a5/Swift/BlurHashDecode.swift
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
// blurhashes are disabled in debug builds because this code is hideously slow when not optimized by the compiler
|
|
||||||
#if DEBUG
|
|
||||||
fileprivate let blurHashesEnabled = ProcessInfo.processInfo.environment.keys.contains("DEBUG_BLUR_HASH")
|
|
||||||
#else
|
|
||||||
fileprivate let blurHashesEnabled = true
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extension UIImage {
|
extension UIImage {
|
||||||
public convenience init?(blurHash: String, size: CGSize, punch: Float = 1) {
|
public convenience init?(blurHash: String, size: CGSize, punch: Float = 1) {
|
||||||
guard blurHashesEnabled,
|
guard blurHash.count >= 6 else { return nil }
|
||||||
blurHash.count >= 6 else { return nil }
|
|
||||||
|
|
||||||
let sizeFlag = String(blurHash[0]).decode83()
|
let sizeFlag = String(blurHash[0]).decode83()
|
||||||
let numY = (sizeFlag / 9) + 1
|
let numY = (sizeFlag / 9) + 1
|
||||||
|
|
Loading…
Reference in New Issue