Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
shima11 committed Apr 11, 2024
1 parent 189f94e commit e3453a9
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public final class ImagePreviewView: PixelEditorCodeBasedView {
private weak var currentLoadingOverlay: UIView?

private var isBinding = false
private var cachedCroppedImage: (EditingStack.State.Loaded, CIImage)? = nil

// MARK: - Initializers

Expand Down Expand Up @@ -123,10 +124,23 @@ public final class ImagePreviewView: PixelEditorCodeBasedView {
}

private func requestPreviewImage(state: EditingStack.State.Loaded) {
let croppedImage = editingStack.makeCroppedCIImage(loadedState: state)

let croppedImage: CIImage
if
let cachedCroppedImage,
state.editingSourceCGImage == cachedCroppedImage.0.editingSourceCGImage,
state.metadata == cachedCroppedImage.0.metadata,
state.currentEdit.crop == cachedCroppedImage.0.currentEdit.crop
{
croppedImage = cachedCroppedImage.1
} else {
croppedImage = editingStack.makeCroppedCIImage(loadedState: state)
cachedCroppedImage = (state, croppedImage)
}
imageView.display(image: croppedImage)
imageView.postProcessing = state.currentEdit.filters.apply
originalImageView.display(image: croppedImage)

}

private func updateLoadingOverlay(displays: Bool) {
Expand Down

0 comments on commit e3453a9

Please sign in to comment.