mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Make DrawingContext initializer failable
This commit is contained in:
@@ -45,16 +45,17 @@ public func reactionStaticImage(context: AccountContext, animation: TelegramMedi
|
||||
}
|
||||
|
||||
func add(with drawingBlock: (AnimationCacheItemDrawingSurface) -> Double?, proposedWidth: Int, proposedHeight: Int, insertKeyframe: Bool) {
|
||||
let renderContext = DrawingContext(size: CGSize(width: proposedWidth, height: proposedHeight), scale: 1.0, clear: true)
|
||||
let _ = drawingBlock(AnimationCacheItemDrawingSurface(
|
||||
argb: renderContext.bytes.assumingMemoryBound(to: UInt8.self),
|
||||
width: Int(renderContext.scaledSize.width),
|
||||
height: Int(renderContext.scaledSize.height),
|
||||
bytesPerRow: renderContext.bytesPerRow,
|
||||
length: renderContext.length
|
||||
))
|
||||
if let image = renderContext.generateImage() {
|
||||
self.frameReceived(image)
|
||||
if let renderContext = DrawingContext(size: CGSize(width: proposedWidth, height: proposedHeight), scale: 1.0, clear: true) {
|
||||
let _ = drawingBlock(AnimationCacheItemDrawingSurface(
|
||||
argb: renderContext.bytes.assumingMemoryBound(to: UInt8.self),
|
||||
width: Int(renderContext.scaledSize.width),
|
||||
height: Int(renderContext.scaledSize.height),
|
||||
bytesPerRow: renderContext.bytesPerRow,
|
||||
length: renderContext.length
|
||||
))
|
||||
if let image = renderContext.generateImage() {
|
||||
self.frameReceived(image)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user