From 47fbbbc026d7cca10151a6a7b644626922e79cfc Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 18 Jul 2023 00:26:38 +0200 Subject: [PATCH] Various fixes --- .../Sources/DrawingStickerEntity.swift | 6 +++++- .../Sources/VideoTextureSource.swift | 8 -------- .../Sources/MediaEditorScreen.swift | 19 ------------------- .../StoryItemSetContainerComponent.swift | 12 ++++-------- 4 files changed, 9 insertions(+), 36 deletions(-) diff --git a/submodules/DrawingUI/Sources/DrawingStickerEntity.swift b/submodules/DrawingUI/Sources/DrawingStickerEntity.swift index 5bd95201b5..a21a409a3c 100644 --- a/submodules/DrawingUI/Sources/DrawingStickerEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingStickerEntity.swift @@ -215,13 +215,17 @@ public final class DrawingStickerEntityView: DrawingEntityView { context.draw(image.cgImage!, in: imageRect) } + var synchronous = false + if case let .image(_, type) = self.stickerEntity.content { + synchronous = type == .dualPhoto + } self.imageNode.setSignal(.single({ arguments -> DrawingContext? in let context = DrawingContext(size: arguments.drawingSize, opaque: false, clear: true) context?.withFlippedContext({ ctx in drawImageWithOrientation(image, size: arguments.drawingSize, in: ctx) }) return context - })) + }), attemptSynchronously: synchronous) self.setNeedsLayout() } else if case let .video(videoPath, image, _) = self.stickerEntity.content { let url = URL(fileURLWithPath: videoPath) diff --git a/submodules/TelegramUI/Components/MediaEditor/Sources/VideoTextureSource.swift b/submodules/TelegramUI/Components/MediaEditor/Sources/VideoTextureSource.swift index 7f2ac20368..37e4d6498e 100644 --- a/submodules/TelegramUI/Components/MediaEditor/Sources/VideoTextureSource.swift +++ b/submodules/TelegramUI/Components/MediaEditor/Sources/VideoTextureSource.swift @@ -663,13 +663,9 @@ final class VideoInputScalePass: RenderPass { } func process(input: MTLTexture, secondInput: MTLTexture?, timestamp: CMTime, device: MTLDevice, commandBuffer: MTLCommandBuffer) -> MTLTexture? { -#if targetEnvironment(simulator) - -#else guard max(input.width, input.height) > 1920 || secondInput != nil else { return input } -#endif let scaledSize = CGSize(width: input.width, height: input.height).fitted(CGSize(width: 1920.0, height: 1920.0)) let width: Int @@ -718,10 +714,6 @@ final class VideoInputScalePass: RenderPass { renderCommandEncoder.setRenderPipelineState(self.mainPipelineState!) -#if targetEnvironment(simulator) - let secondInput = input -#endif - let (mainVideoState, additionalVideoState, transitionVideoState) = self.transitionState(for: timestamp, mainInput: input, additionalInput: secondInput) if let transitionVideoState { diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index d8b4439149..d799c6d0e5 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -1974,25 +1974,6 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate } } } -#if targetEnvironment(simulator) - if case let .asset(asset) = subject, asset.mediaType == .video { - let videoEntity = DrawingStickerEntity(content: .dualVideoReference) - videoEntity.referenceDrawingSize = storyDimensions - videoEntity.scale = 1.625 - videoEntity.position = PIPPosition.topRight.getPosition(storyDimensions) - self.entitiesView.add(videoEntity, announce: false) - - mediaEditor.setAdditionalVideo("", positionChanges: [VideoPositionChange(additional: false, timestamp: 0.0), VideoPositionChange(additional: true, timestamp: 3.0)]) - mediaEditor.setAdditionalVideoPosition(videoEntity.position, scale: videoEntity.scale, rotation: videoEntity.rotation) - if let entityView = self.entitiesView.getView(for: videoEntity.uuid) as? DrawingStickerEntityView { - entityView.updated = { [weak videoEntity, weak self] in - if let self, let videoEntity { - self.mediaEditor?.setAdditionalVideoPosition(videoEntity.position, scale: videoEntity.scale, rotation: videoEntity.rotation) - } - } - } - } -#endif self.gradientColorsDisposable = mediaEditor.gradientColors.start(next: { [weak self] colors in if let self, let colors { diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 44e59272a7..41d32216df 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -3481,22 +3481,18 @@ public final class StoryItemSetContainerComponent: Component { let entities = generateChatInputTextEntities(caption) var updatedText: String? var updatedEntities: [MessageTextEntity]? - var updatedPrivacy: EngineStoryPrivacy? if caption.string != item.text || entities != item.entities { updatedText = caption.string updatedEntities = entities } - if privacy.privacy != item.privacy { - updatedPrivacy = privacy.privacy - } - + if let mediaResult { switch mediaResult { case let .image(image, dimensions): updateProgressImpl?(0.0) if let imageData = compressImageToJPEG(image, quality: 0.7) { - updateDisposable.set((context.engine.messages.editStory(id: id, media: .image(dimensions: dimensions, data: imageData, stickers: stickers), text: updatedText, entities: updatedEntities, privacy: updatedPrivacy) + updateDisposable.set((context.engine.messages.editStory(id: id, media: .image(dimensions: dimensions, data: imageData, stickers: stickers), text: updatedText, entities: updatedEntities, privacy: nil) |> deliverOnMainQueue).start(next: { [weak self] result in guard let self else { return @@ -3544,7 +3540,7 @@ public final class StoryItemSetContainerComponent: Component { } } - updateDisposable.set((context.engine.messages.editStory(id: id, media: .video(dimensions: dimensions, duration: duration, resource: resource, firstFrameFile: firstFrameFile, stickers: stickers), text: updatedText, entities: updatedEntities, privacy: updatedPrivacy) + updateDisposable.set((context.engine.messages.editStory(id: id, media: .video(dimensions: dimensions, duration: duration, resource: resource, firstFrameFile: firstFrameFile, stickers: stickers), text: updatedText, entities: updatedEntities, privacy: nil) |> deliverOnMainQueue).start(next: { [weak self] result in guard let self else { return @@ -3565,7 +3561,7 @@ public final class StoryItemSetContainerComponent: Component { })) } } - } else if updatedText != nil || updatedPrivacy != nil { + } else if updatedText != nil { let _ = (context.engine.messages.editStory(id: id, media: nil, text: updatedText, entities: updatedEntities, privacy: updatedPrivacy) |> deliverOnMainQueue).start(next: { [weak self] result in switch result {